Authentication

Authenticate with the Pie API using an API key or a bearer token. Most integrations use an API key.

MethodHeaderUse case
API keyX-API-Key: <key>Programmatic access, CI/CD, MCP integrations
Bearer tokenAuthorization: Bearer <token>Pie web app sessions. Use an API key for scripts, CI and agents

API key authentication

Use an API key for programmatic access. Create one in Settings > API Keys (see Create an API key). Pie shows the key once, so store it when you create it.

Headers

HeaderRequiredDescription
X-API-KeyYesYour API key. Pie resolves the app from the key.

Example

curl -X GET "https://api.pie.inc/v1/test-cases" \
  -H "X-API-Key: YOUR_API_KEY"

Error responses

StatusMessageCause
401Authentication required: provide either X-API-Key header or Authorization Bearer tokenNo X-API-Key header, and no Authorization header in the Bearer <token> form
401Invalid API keyKey not found or has been revoked
403API key cannot access the requested appThe API key doesn’t have access to the app the request asked for
503Authentication service temporarily unavailablePie couldn’t check your credentials. Retry the request

Bearer token authentication

A bearer token carries a signed-in session from the Pie web app. For scripts, CI and agents, use an API key instead.

Headers

HeaderRequiredDescription
AuthorizationYesBearer <token>, where the token is a Pie web app session token
X-App-IDYes*Your app identifier. *Not required for /v1/apps.

Example

curl -X GET "https://api.pie.inc/v1/apps" \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN"
curl -X GET "https://api.pie.inc/v1/test-cases" \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN" \
  -H "X-App-ID: YOUR_APP_ID"

Error responses

StatusMessageCause
401Invalid Firebase ID tokenThe bearer token isn’t a valid or current Pie session token
401X-App-ID header is requiredMissing X-App-ID on endpoints that require it. The message continues: please hit /v1/apps to get the app ids you have access to
401User does not have access to this appUser isn’t in the app’s permission list

Common headers

Some endpoints also take these headers:

HeaderDescriptionUsed by
Content-Type: application/jsonRequired for POST, PUT and PATCH request bodiesAll write endpoints
Accept: text/csvRequests a CSV responseGET endpoints (test cases, issues, results, runs)
X-Export-Format: csvAlternative CSV export triggerGET endpoints

MCP server authentication

The MCP server at https://mcp.pie.inc uses the same API key, sent in a header:

MethodFormat
HeaderX-API-Key: YOUR_API_KEY

For setup per platform (Claude Desktop, Cursor, VS Code, Claude Code), see Connect your agent.

Response format

All API responses use one envelope.

Success:

{
  "success": true,
  "status": 200,
  "message": "Operation completed successfully",
  "data": { ... }
}

Error:

{
  "success": false,
  "status": 401,
  "message": "Authentication required: provide either X-API-Key header or Authorization Bearer token"
}

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

Related

Last updated on