mastra-ai/mastra · error

No organizations found. Create one at ${MASTRA_STUDIO_URL}

Error message

No organizations found. Create one at ${MASTRA_STUDIO_URL}

What it means

`resolveOrg` fetches the authenticated user's organizations from Mastra Cloud to determine which org the deploy targets. If the API returns zero organizations, the CLI throws this error directing the user to create an organization in Mastra Studio, since a deployment must belong to one.

Source

Thrown at packages/cli/src/commands/server/deploy.ts:212

    }
  }

  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(`No organizations found. 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

  1. Create an organization at the Mastra Studio URL, then re-authenticate and retry
  2. Pass the org explicitly with --org-id if you have one
  3. Run `mastra auth login` (or equivalent) to switch to an account that belongs to an organization

Example fix

// before
# account has zero orgs
mastra server deploy
// after
# create org in Studio, then
mastra auth login && mastra server deploy
Defensive patterns

Strategy: try-catch

Validate before calling

const orgs = await fetchOrganizations(token);
if (!orgs.length) {
  console.error('No organizations on this account — create one at ' + MASTRA_STUDIO_URL);
  process.exit(1);
}

Type guard

const hasOrg = (orgs: { id: string; name: string }[]): boolean => orgs.length > 0;

Try / catch

try {
  await runServerDeploy(opts);
} catch (e) {
  if ((e as Error).message.startsWith('No organizations found')) {
    console.error('Create an org in Mastra Studio, then re-authenticate.');
  } else throw e;
}

Prevention

When it happens

Trigger: Running `mastra server deploy` while authenticated with a token/account that has no organizations, and no --org-id was supplied.

Common situations: Using a freshly created or personal access token with no org membership; wrong account logged in; org deleted or user removed from it; auth against a stale token for a different environment.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/cfce28226706cd7f. Report an issue: GitHub.