Authentication and authorization
Bearer is the header scheme, not the credential type
For the documented REST operations, the portable default is:
Authorization: Bearer YOUR_CREDENTIALA personal API key and a user access token are different credentials even when both use this header. Personal keys begin with sk_. They are tied to an owner and organization, can expire or be revoked, and remain bounded by the owner's live permissions. A JWT is a user session access token governed by the organization's sign-in and MFA rules. Do not use an ID token or refresh token in place of an access token.
v1 knowledge bases and v2 REST
Personal API key in Bearer; authenticated user JWT where supported
Resource access and permission checks still apply
/inference/v0/...
Personal API key in Bearer; legacy organization public key where still enabled
These are API-key routes; do not assume a user JWT works
Legacy /analytics/org/...
Personal API key in Bearer; legacy organization private key where still enabled
The legacy public key is not the analytics credential
SCIM Users and Groups
Dedicated SCIM token in Bearer
Not a normal personal API key or user session token
Webhook deliveries to your server
Verify webhook signature headers
The signing secret is not a StackAI REST API key
What about X-API-Key?
Some endpoints accept the raw personal key as X-API-Key: sk_.... Other public routes explicitly read the Bearer authorization header. X-API-Key is not a universal substitute across these APIs. All examples in this documentation use Bearer. Do not send both headers: mixed JWT/key credentials or different keys can be rejected as ambiguous or conflicting. Use the exact Bearer spelling in examples.
/v2/runs and its run detail, resume, and cancel operations
Authorization: Bearer sk_... or X-API-Key: sk_...
/inference/v0/... and legacy /analytics/org/...
Use Authorization: Bearer sk_...; do not substitute X-API-Key
Other REST examples in this guide
Use the documented Authorization: Bearer sk_... form
/scim/v2/...
Use the dedicated SCIM token in Authorization: Bearer; a personal key is not interchangeable
For example, read a run with the alternative personal-key header:
curl --fail-with-body -sS "$STACKAI_BASE_URL/v2/runs/$RUN_ID" \
-H "X-API-Key: $STACKAI_API_KEY"Obtain personal API keys in StackAI settings. Obtain user access tokens through your organization’s supported sign-in flow. These API routes do not provide a public password-grant login endpoint.
Scope and resource access both matter
A scope grants no extra access beyond the key owner's current permissions. A key can carry kbs.read and still fail to read a knowledge base the owner cannot access. A project can be in the same organization yet unavailable because of folder permissions. Review the permission note on each endpoint.
Typical minimum sets:
Inspect a project's IO
projects.read
Start/resume/cancel v2 runs
projects.run
Poll/list v2 runs
analytics.read
Read a v2 pause token
Both analytics.read and projects.run
Create, upload, poll, search a KB
kbs.create, kbs.index, kbs.read, kbs.query
Sync a KB
kbs.sync
Browse providers/connections; run action
connections.read; connections.use
Manage evals
Relevant evals.read/create/update/delete/run; trace-backed operations also require analytics.read
Manage skills
Relevant skills.read/create/update/delete
Manage outbound webhook subscriptions
org.webhooks.manage
Webhook management is not an assignable scope in the current personal-key scope picker. Use an authorized user session for this administrative workflow; an existing unscoped key remains subject to its owner's live permissions. Do not widen a production integration's credential just to avoid a scope error.
Store keys in a server-side secret manager. Do not embed them in browser JavaScript, mobile binaries, URLs, screenshots, or logs. Put your own authenticated backend between an end-user interface and these APIs. Rotate compromised credentials and update dependent services. An embed-session credential has a restricted surface and is not a general-purpose REST key.
Last updated
Was this helpful?

