mastra-ai/mastra · error
Failed to create project (${res.status})
Error message
Failed to create project (${res.status}) What it means
The CLI attempted to create an observability project via POST /v1/studio/projects and received a non-2xx response. The HTTP status is included in the message.
Source
Thrown at packages/cli/src/commands/init/observability-provision.ts:195
async function createProjectByName({
token,
orgId,
name,
}: {
token: string;
orgId: string;
name: string;
}): Promise<ObservabilityProject> {
// Create as observability-only: no Studio or Server runtime attached. The first
// `mastra studio deploy` / `mastra server deploy` flips the matching flag
// on the platform side.
const res = await platformFetch(`${MASTRA_PLATFORM_API_URL}/v1/studio/projects`, {
method: 'POST',
headers: { ...authHeaders(token, orgId), 'Content-Type': 'application/json' },
body: JSON.stringify({ name, studioEnabled: false, serverEnabled: false }),
});
if (!res.ok) {
throw new Error(`Failed to create project (${res.status})`);
}
const body = (await res.json()) as { project: ObservabilityProject };
return body.project;
}
async function mintOrgToken({
token,
orgId,
keyName,
}: {
token: string;
orgId: string;
keyName: string;
}): Promise<string> {
const res = await platformFetch(`${MASTRA_PLATFORM_API_URL}/v1/auth/tokens`, {
method: 'POST',
headers: { ...authHeaders(token, orgId), 'Content-Type': 'application/json' },
body: JSON.stringify({ name: keyName }),View on GitHub (pinned to 75dd419e61)
Solutions
- Check the status: on 409/422 the name likely exists or is invalid — pick a different project name.
- On 401/403 re-authenticate (`mastra login`) and confirm you have permission to create projects in the org.
- Retry after a delay on 429/5xx (rate limiting or transient outage).
- Verify network access to the Mastra platform API (proxy/VPN).
Defensive patterns
Strategy: try-catch
Validate before calling
const token = await getValidPlatformToken();
const name = projectName.trim();
if (!name || name.length > 100) throw new Error('Project name must be non-empty and reasonably sized'); Try / catch
try {
await provisionObservabilityProject(...);
} catch (err) {
if (err.message.startsWith('Failed to create project')) {
const status = err.message.match(/\((\d+)\)/)?.[1];
if (status === '409' || status === '422') {
// retry with a different project name
} else if (status === '401' || status === '403') {
await reauth();
}
}
} Prevention
- Use a unique project name to avoid conflicts.
- Confirm your role allows project creation in the org.
- Refresh auth tokens before provisioning.
When it happens
Trigger: provisionObservabilityProject or createProject calls createProjectByName and the platform rejects the request: 401/403 (bad token/permissions), 409 or 422 (duplicate/invalid project name), 429 (rate limit), 5xx.
Common situations: Creating a project whose name already exists in the org, token lacking org admin rights, expired auth token, or platform-side validation rejecting the name.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- Perplexity Search request failed with status ${response.stat
- Failed to fetch Copilot models: ${response.status} ${respons
- Failed to list projects (${res.status})
- Failed to create access token (${res.status})
- Failed to fetch templates: ${response.statusText}
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/845254585c081c08.
Report an issue: GitHub.