Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Authentication: Bearer Tokens and Personal API Keys

Use a personal API key for a backend integration. Send it in Authorization: Bearer <personal-api-key> for the REST examples. Bearer is a header scheme, not a separate kind of credential: supported endpoints can use either a personal key or a user access token in that header. Legacy inference and analytics have different credential restrictions.

Authenticate from your backend

Two supported header forms for v2 runs. Set STACKAI_BASE_URL to your deployment’s documented API base URL. Legacy inference requires the Authorization form.

Copy the example
# Load STACKAI_API_KEY from your secret manager.
curl "$STACKAI_BASE_URL/v2/runs/$RUN_ID" \
  -H "Authorization: Bearer $STACKAI_API_KEY"

# Alternative accepted by the v2 run endpoints:
curl "$STACKAI_BASE_URL/v2/runs/$RUN_ID" \
  -H "X-API-Key: $STACKAI_API_KEY"

# Choose one header. Keep the key out of browser code.

Before you begin

A valid credential with the required permissions and resource access.

Authentication methods

Term
Definition

Authentication

Verification of the account or credential making a request. It identifies the caller but does not grant every resource permission.

Bearer authentication

An Authorization header whose value begins with Bearer followed by a supported credential. Anyone possessing the credential may be able to use it within its permissions.

X-API-Key

A header accepted by supported routes for a raw personal API key. Do not add a Bearer prefix inside this header value.

API key

A secret credential accepted by a supported API or connector. Send it only through the documented authentication field or header.

Access token

A credential used to authorize requests for its valid lifetime. Expiration or revocation can prevent an otherwise valid operation.

Authenticate an API request

  1. Create a personal key in Settings → API Keys in the organization containing the resource. Give it only the scopes needed by your application.

  2. Send the key through Authorization: Bearer over HTTPS. Keep it in your backend; do not put it in browser code.

  3. Call an operation allowed by both the key scopes and its owner’s current access. For a workflow run, the key needs projects.run; reading its result also needs analytics.read.

  4. For a 401, check the credential and expiry. For a 403, check scope and resource access. Do not retry an unchanged rejected credential.

The request is authenticated as the intended account or key.

Behavior and limitations

The /v2/runs operations also accept X-API-Key for a personal key. Legacy /inference/v0/... and /analytics/org/... routes require the Authorization form. For endpoints supporting X-API-Key, send the raw key as its value. Do not prefix that header value with Bearer. Personal keys can also use Authorization: Bearer on supported routes. Older routes can require the Authorization form. Do not send conflicting credentials in multiple headers.

Or, where supported:

API Versions and Compatibility

API authentication and endpoint restrictions

Run your first workflow through the API

Was this helpful?