Authentication

Pie supports three authentication methods. The API checks them in priority order: Scheduler Secret > API Key > Firebase Bearer Token. Most integrations use API Key auth.

Quick Reference

MethodHeaderUse Case
API KeyX-API-Key: <key>Programmatic access, CI/CD, MCP integrations
Firebase Bearer TokenAuthorization: Bearer <token>Browser sessions, user-specific operations
Scheduler SecretX-API-Key: <secret> + X-App-ID: <id>Internal scheduled jobs

API Key Authentication

The primary method for programmatic access. Generate keys from the Pie dashboard.

Setup

  1. Log in to app.pie.inc
  2. Go to Settings > API Keys
  3. Click + Create API Key
  4. Name your key and click Create
  5. Copy the key immediately - it won’t be shown again

Headers

HeaderRequiredDescription
X-API-KeyYesYour API key
X-App-IDNoOverride app ID (admin users only). If omitted, uses the app associated with your key

Example

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

How It Works

  • The key is validated against the api-keys collection in Firestore
  • The app ID is automatically resolved from the key
  • Admin users (checked via Firebase Auth custom claims) can override the app with the X-App-ID header

Error Responses

StatusMessageCause
401API key is requiredNo X-API-Key header and no Authorization header provided
401Invalid API keyKey not found in the database or has been revoked
403Only admin users can switch appsNon-admin user tried to use X-App-ID to override the app

Firebase Bearer Token Authentication

Used for browser-based sessions and user-specific operations like app setup.

Headers

HeaderRequiredDescription
AuthorizationYesBearer <firebase_id_token>
X-App-IDYes*Your app identifier. *Not required for /v1/apps and /v1/setup-app

Example

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

How It Works

  • The Firebase ID token is verified using Firebase Admin SDK
  • The user’s UID is extracted from the token
  • Access is validated against the userAppPermissions collection
  • Admin/superadmin users (via Firebase custom claims) bypass app access checks

Error Responses

StatusMessageCause
401Authorization header is requiredNo auth header provided
401Invalid authorization header formatHeader doesn’t follow Bearer <token> format
401X-App-ID header is requiredMissing X-App-ID on endpoints that require it
401Invalid Firebase ID tokenToken is expired, malformed, or revoked
401User does not have access to this appUser not in the app’s permission list

Scheduler Secret Authentication

Used for internal scheduled jobs and automated pipelines. The secret is set via the SCHEDULER_SECRET_KEY environment variable on the server.

Headers

HeaderRequiredDescription
X-API-KeyYesThe scheduler secret value
X-App-IDYesTarget app identifier (always required for scheduler auth)

Example

curl -X POST "https://api.pie.inc/v1/discovery" \
  -H "X-API-Key: SCHEDULER_SECRET" \
  -H "X-App-ID: YOUR_APP_ID" \
  -H "Content-Type: application/json"

Error Responses

StatusMessageCause
400X-App-ID header required for scheduler requestsMissing X-App-ID header

Common Headers

These headers are used alongside authentication on specific endpoints:

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

Admin Capabilities

Users with admin or superadmin roles (set via Firebase Auth custom claims) have additional capabilities:

  • App switching: Can use X-App-ID header with API Key auth to access any app
  • Bypass access checks: Skip userAppPermissions validation when using Bearer auth
  • MCP admin tools: Access to get_apps, search_apps, and switch_app MCP tools

MCP Server Authentication

The MCP server at https://mcp.pie.inc uses the same API Key authentication:

MethodFormat
HeaderX-API-Key: YOUR_API_KEY
Query parameter?api_key=YOUR_API_KEY

For setup instructions per platform (Claude Desktop, Cursor, VS Code, Claude Code), see Connect Pie to Your AI Workspace.


Response Format

All API responses follow a standard envelope:

Success:

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

Error:

{
  "success": false,
  "status": 401,
  "message": "API key is required",
  "data": null
}