Error codes

Every Pie API error response uses the same envelope:

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

An error response has no data field. Some errors also carry an errorId.

Authentication and authorization errors

StatusMessageCauseResolution
401Authentication required: provide either X-API-Key header or Authorization Bearer tokenNo X-API-Key header, and no Authorization header in the Bearer <token> formAdd your API key header: X-API-Key: YOUR_KEY
401Invalid API keyAPI key not found or revokedCreate a new key in Settings > API Keys, then update the place that used the old one. See Create an API key
401Invalid Firebase ID tokenThe bearer token isn’t a valid or current Pie session tokenSign in to the Pie web app again, or send your API key in X-API-Key
401X-App-ID header is requiredBearer auth used without naming the target app. The message continues: please hit /v1/apps to get the app ids you have access toAdd an X-App-ID: YOUR_APP_ID header. Call /v1/apps to list the app IDs you can use
401User does not have access to this appThe signed-in user isn’t in the app’s permission listAsk someone on the team to invite you. See Invite your team
403API key cannot access the requested appThe API key doesn’t have access to the app the request asked forUse the API key created for the target app
503Authentication service temporarily unavailablePie couldn’t check your credentialsRetry after a few seconds. Contact support if it persists

Client errors

StatusMessageCauseResolution
400Invalid request bodyRequest body isn’t valid JSON or doesn’t match the expected schemaCheck your JSON syntax and required fields
400<field_name> is requiredA required field is missing from the request bodyInclude the named field in your request
400At least one <item> is requiredA bulk operation was called with an empty arrayProvide at least one item in the array
400No runs found for this appThe app has no test runs yetCreate a run first with POST /v1/runs
400Default is your test library and cannot be started as a run…POST /v1/runs named Default, the library of tests that sit in no suite, as the suiteName a test suite, or pass testCaseIds to run specific tests
404<resource> not foundThe requested resource (test case, issue, run and so on) doesn’t existCheck the ID. Use the matching GET endpoint to list available resources
404Endpoint not foundInvalid URL pathCheck the path against the API reference
405Method not allowedHTTP method not supported for this endpointCheck the allowed methods in the API reference
413Build file exceeds the <bytes> byte limitThe uploaded build file is larger than the allowed sizeReduce the build size, or contact support for larger builds
413Build upload exceeds the maximum request sizeThe upload request is larger than the allowed sizeReduce the build size, or contact support for larger builds

Server errors

StatusMessageCauseResolution
500Failed to fetch <resource>A read failedRetry the request. If it persists, contact support
500Failed to create <resource>A write failedRetry the request. Check that your request body is valid
500Failed to update <resource>An update failedRetry the request

MCP server errors

On the MCP server at https://mcp.pie.inc, the two API key errors come back as MCP protocol errors when your client connects. A call to a tool that doesn’t exist comes back as a tool result marked as an error.

ErrorCauseResolution
API key required in X-API-Key headerThe request carried no API keyCheck that your MCP configuration sends the X-API-Key header
Failed to validate API key: API key not foundThe key you sent isn’t a Pie API keyCheck the key, or create a new one. See Create an API key
Unknown tool: <name>The tool name doesn’t existCheck the tool name against MCP tools

Retry and error handling

Retry 500-level errors with exponential backoff (1 second, 2 seconds, 4 seconds). Don’t retry 400-level errors. Fix the request first.

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
    pass
elif response.status_code >= 500:
    # Retry with backoff
    pass
else:
    error_msg = response.json()["message"]
    # Handle specific error

Related

Last updated on