{"record":{"id":"4197e38a4adaff2a","repo":"mastra-ai/mastra","slug":"you-have-no-organizations-please-create-one-at-4197e3","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/studio/deploy.ts","lineNumber":237,"sourceCode":"  // 3. credentials currentOrgId\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  // 4. Auto-select if only 1 org\n  if (orgs.length === 1) {\n    return { orgId: orgs[0]!.id, orgName: orgs[0]!.name };\n  }\n\n  // 5. Interactive picker\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":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/cli/src/commands/studio/deploy.ts#L219-L255","documentation":"resolveOrg fetches the caller's organizations from the Mastra Studio API during deploy. If the authenticated account belongs to zero organizations, deployment cannot proceed (a project must live inside an org), so the command throws and points you at MASTRA_STUDIO_URL to create one.","triggerScenarios":"Calling `mastra studio deploy` with an API token / login belonging to a brand-new account that has never created an organization; an org previously existing but deleted, or the token lacking access to any org.","commonSituations":"Fresh sign-ups automating deploys before creating an org in the Studio UI; service tokens scoped to nothing; org removed by an admin while CI still holds old credentials.","solutions":["Sign in at the Mastra Studio URL and create an organization, then re-run deploy","If the org exists, check that your MASTRA_API_TOKEN belongs to an account with org membership","Verify you are authenticating against the intended Studio instance (correct base URL / token pair)","Set MASTRA_ORG_ID explicitly along with MASTRA_API_TOKEN for headless runs once the org exists"],"exampleFix":"// before\nexport MASTRA_API_TOKEN=tok_xxx\nmastra studio deploy --yes\n// Error: You have no organizations. Please create one at https://studio.mastra.ai\n// after (create org 'Acme' in Studio UI first)\nexport MASTRA_API_TOKEN=tok_xxx\nexport MASTRA_ORG_ID=org_acme\nexport MASTRA_PROJECT_ID=prj_xxx\nmastra studio deploy --yes","handlingStrategy":"validation","validationCode":"const orgs = await fetchOrgs(token);\nif (orgs.length === 0) {\n  throw new Error(`No organizations for this token. Create one at ${STUDIO_URL} or use a token with org access.`);\n}","typeGuard":"function hasOrganizations(orgs: Org[]): orgs is [Org, ...Org[]] {\n  return orgs.length > 0;\n}","tryCatchPattern":"try {\n  await studioDeploy();\n} catch (e) {\n  if (e instanceof Error && e.message.includes('You have no organizations')) {\n    console.error(`Create an organization at ${STUDIO_URL}, then retry.`);\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Create the org before setting up CI deploy credentials","Provision via `mastra init --observability` so org/project ids are seeded into .env","Rotate tokens only to accounts that retain org membership","Pin MASTRA_ORG_ID in CI so headless deploys fail fast and clearly if org access is lost"],"tags":["cli","auth","organization"],"backgroundTag":"missing-organization","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}