{"record":{"id":"b8810ec2e9ccca6c","repo":"mastra-ai/mastra","slug":"you-have-no-organizations-please-create-one-at","errorCode":null,"errorMessage":"You have no organizations. Please create one at ${MASTRA_STUDIO_URL}","messagePattern":"You have no organizations\\. Please create one at (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/deploy/index.ts","lineNumber":155,"sourceCode":"    }\n  }\n\n  const currentOrgId = await getCurrentOrgId();\n  const orgs = await fetchOrgs(token);\n\n  if (currentOrgId) {\n    const match = orgs.find(o => o.id === currentOrgId);\n    if (match) {\n      return { orgId: match.id, orgName: match.name };\n    }\n  }\n\n  if (orgs.length === 1) {\n    return { orgId: orgs[0]!.id, orgName: orgs[0]!.name };\n  }\n\n  if (orgs.length === 0) {\n    throw new Error(`You have no organizations. Please create one at ${MASTRA_STUDIO_URL}`);\n  }\n\n  const selected = await p.select({\n    message: 'Select an organization',\n    options: orgs.map(o => ({ value: o.id, label: `${o.name} (${o.id})` })),\n  });\n\n  if (p.isCancel(selected)) {\n    p.cancel('Deploy cancelled.');\n    process.exit(0);\n  }\n\n  const selectedOrg = orgs.find(o => o.id === selected)!;\n  return { orgId: selectedOrg.id, orgName: selectedOrg.name };\n}\n\n/* ------------------------------------------------------------------ */\n/*  Resolve project                                                   */","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/cli/src/commands/deploy/index.ts#L137-L173","documentation":"resolveOrg, used by the deploy command to pick the target organization, throws when the authenticated account has zero organizations. Since deploying requires an org (and then a project) to deploy into, the CLI aborts and points the developer at MASTRA_STUDIO_URL to create one. It is a pre-flight account-state check, not an API failure.","triggerScenarios":"`mastra deploy` (or the deploy flow calling resolveOrg) with a token whose account lists no organizations — the orgs array is length 0.","commonSituations":"Fresh sign-up on Mastra Studio with no org created yet; using a brand-new/bot account token; org was deleted while a stale token still authenticates; wrong account logged in via CLI.","solutions":["Sign in at MASTRA_STUDIO_URL and create an organization, then re-run the deploy","Ensure the CLI is logged into the intended account (`mastra login`) — an empty org list may mean the wrong identity","If your org was deleted, create a replacement org and update scripts referencing the old orgId"],"exampleFix":"// before\nmastra deploy  // token account has 0 orgs -> error\n// after\n// create org at MASTRA_STUDIO_URL, then:\nmastra login && mastra deploy","handlingStrategy":"validation","validationCode":"// Pre-flight: ensure the authenticated account has at least one organization before deploying\nconst orgs = await listOrgs(token);\nif (!Array.isArray(orgs) || orgs.length === 0) {\n  throw new Error('Create an organization at ' + MASTRA_STUDIO_URL + ' before deploying');\n}","typeGuard":"function hasOrganizations(orgs: unknown): orgs is Array<{ id: string; name: string }> {\n  return Array.isArray(orgs) && orgs.length > 0 && typeof orgs[0]!.id === 'string';\n}","tryCatchPattern":"try {\n  await deploy(opts);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('no organizations')) {\n    console.error('Onboarding required: create an org at ' + MASTRA_STUDIO_URL);\n  } else throw err;\n}","preventionTips":["Complete Studio onboarding (org creation) before wiring up CLI deploys","Verify `mastra login` identity matches the account that owns your orgs","Handle org deletion: update scripts when an org is removed","In CI, assert org existence in a pre-deploy check step"],"tags":["onboarding","configuration","cli","deploy"],"backgroundTag":"missing-organization","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}