Error Codes

All Pie API error responses follow a standard format:

{
  "success": false,
  "status": 401,
  "message": "Human-readable error description",
  "data": null
}

Authentication Errors

StatusMessageCauseResolution
401API key is requiredNo X-API-Key or Authorization header providedAdd your API key header: X-API-Key: YOUR_KEY
401Invalid API keyAPI key not found or revokedRegenerate your API key in Settings > API Keys
401Authorization header is requiredEndpoint requires auth but no header providedAdd Authorization: Bearer <token> header
401Invalid authorization header formatAuthorization header doesn’t follow Bearer <token> formatUse format: Authorization: Bearer YOUR_TOKEN
401Invalid Firebase ID tokenFirebase token expired, malformed, or revokedRefresh your Firebase session token
401X-App-ID header is requiredBearer auth used without specifying target appAdd X-App-ID: YOUR_APP_ID header
401User does not have access to this appAuthenticated user isn’t in the app’s permission listContact your app admin to grant access

Authorization Errors

StatusMessageCauseResolution
403Only admin users can switch appsNon-admin user tried to use X-App-ID header override with API Key authUse the API key associated with the target app, or request admin role

Client Errors

StatusMessageCauseResolution
400Invalid request bodyRequest body is not valid JSON or doesn’t match expected schemaCheck your JSON syntax and required fields
400<field_name> is requiredA required field is missing from the request bodyInclude the specified field in your request
400At least one <item> is requiredBulk operation called with an empty arrayProvide at least one item in the array
400X-App-ID header required for scheduler requestsScheduler auth used without specifying target appAdd X-App-ID header for scheduler requests
404<resource> not foundThe requested resource (test case, issue, run, etc.) doesn’t existVerify the ID exists. Use the corresponding GET endpoint to list available resources
404Endpoint not foundInvalid URL pathCheck the API endpoint URL against the API reference
404No runs found for this appApp has no test runs yetCreate a run first using POST /v1/runs or POST /v1/discovery
405Method not allowedHTTP method not supported for this endpointCheck allowed methods in the API reference
409User already has an appUser tried to create a second app (one-app-per-user limit)Use GET /v1/apps to get your existing app
413File too largeUploaded build file exceeds the 2GB limitReduce file size or contact support for larger builds

Server Errors

StatusMessageCauseResolution
500Failed to fetch <resource>Database read failureRetry the request. If persistent, check service status
500Failed to create <resource>Database write failureRetry the request. Verify your request body is valid
500Failed to update <resource>Database update failureRetry the request
500Storage client not initializedInternal storage service unavailableRetry after a few seconds. Contact support if persistent
501Not implementedEndpoint or feature not yet availableCheck the API reference for available endpoints

MCP Server Errors

When using the MCP server (https://mcp.pie.inc), tool call errors are returned as MCP protocol error responses:

ErrorCauseResolution
Invalid API keyMCP request sent without valid API keyCheck your MCP config includes the correct X-API-Key header or api_key query parameter
App not foundAPI key not associated with any appVerify the API key was created for the correct app
Tool not foundCalled a tool name that doesn’t existCheck the MCP Tool Reference for valid tool names

Best Practices

Retry strategy: For 500-level errors, retry with exponential backoff (1s, 2s, 4s). Do not retry 400-level errors - fix the request first.

Error handling in code:

response = requests.get("https://api.pie.inc/v1/test-cases",
    headers={"X-API-Key": api_key})

if response.status_code == 200:
    data = response.json()["data"]
elif response.status_code == 401:
    # Re-authenticate
elif response.status_code >= 500:
    # Retry with backoff
else:
    error_msg = response.json()["message"]
    # Handle specific error