mastra-ai/mastra · error · Error
You have no organizations. Please create one at ${MASTRA_STU
Error message
You have no organizations. Please create one at ${MASTRA_STUDIO_URL} What it means
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.
Source
Thrown at packages/cli/src/commands/deploy/index.ts:155
}
}
const currentOrgId = await getCurrentOrgId();
const orgs = await fetchOrgs(token);
if (currentOrgId) {
const match = orgs.find(o => o.id === currentOrgId);
if (match) {
return { orgId: match.id, orgName: match.name };
}
}
if (orgs.length === 1) {
return { orgId: orgs[0]!.id, orgName: orgs[0]!.name };
}
if (orgs.length === 0) {
throw new Error(`You have no organizations. Please create one at ${MASTRA_STUDIO_URL}`);
}
const selected = await p.select({
message: 'Select an organization',
options: orgs.map(o => ({ value: o.id, label: `${o.name} (${o.id})` })),
});
if (p.isCancel(selected)) {
p.cancel('Deploy cancelled.');
process.exit(0);
}
const selectedOrg = orgs.find(o => o.id === selected)!;
return { orgId: selectedOrg.id, orgName: selectedOrg.name };
}
/* ------------------------------------------------------------------ */
/* Resolve project */View on GitHub (pinned to 75dd419e61)
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
Example fix
// before mastra deploy // token account has 0 orgs -> error // after // create org at MASTRA_STUDIO_URL, then: mastra login && mastra deploy
Defensive patterns
Strategy: validation
Validate before calling
// Pre-flight: ensure the authenticated account has at least one organization before deploying
const orgs = await listOrgs(token);
if (!Array.isArray(orgs) || orgs.length === 0) {
throw new Error('Create an organization at ' + MASTRA_STUDIO_URL + ' before deploying');
} Type guard
function hasOrganizations(orgs: unknown): orgs is Array<{ id: string; name: string }> {
return Array.isArray(orgs) && orgs.length > 0 && typeof orgs[0]!.id === 'string';
} Try / catch
try {
await deploy(opts);
} catch (err) {
if (err instanceof Error && err.message.includes('no organizations')) {
console.error('Onboarding required: create an org at ' + MASTRA_STUDIO_URL);
} else throw err;
} Prevention
- 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
When it happens
Trigger: `mastra deploy` (or the deploy flow calling resolveOrg) with a token whose account lists no organizations — the orgs array is length 0.
Common situations: 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.
Related errors
- Found ${projects.length} existing project(s) in this organiz
- Could not determine project name from package.json. Use --pr
- No env file found for deploy. Add a .env or .env.* file befo
- No env file found for deploy. Add a .env or .env.* file befo
- Could not resolve the sandbox home directory. Pass `remoteDi
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/b8810ec2e9ccca6c.
Report an issue: GitHub.