Authentication and API keys

Every request carries one header:

Authorization: Bearer sk-sf-...

Getting a key

Your Organization Owner creates keys in the portal: Developer → API keys. The secret is shown once — store it in a secrets manager, never in code.

Four decisions are made at creation time:

  1. Project. A key belongs to one project. It sees that project's agents and knowledge, and its usage is attributed there.
  2. Scopes. What the key may do: chat, embeddings, rag.read, rag.write, agents.run, workflows.run, sessions.mint, usage.read, … A call outside the key's scopes is refused with Key lacks scope(s): ….
  3. Model allowlist. The models this key may call. GET /v1/models returns only these, and calling anything else returns key_model_access_denied. Set the allowlist when you create the key — changing it later requires rotating it.
  4. Mode: live or test. A test key mints end-user sessions only for agents in the dev environment, and those sessions and their runs are marked as tests. A live key works with any agent. Each key is labelled live or test in Developer → API keys.

Session tokens for your end users

An API key (sk-sf-…) never leaves your server. To let one of your users talk to an agent from a browser or app, your server uses the key (scope sessions.mint) to mint a session token (sst-sf-…) for that user. The token works only on the /v1/channel endpoints, for one agent, until it expires. Those endpoints refuse API keys with api_key_not_allowed. See End-user sessions for the whole flow.

Workflow binding

Workflow runs have one extra lock: the key must be explicitly bound to each workflow it may start (portal → API key → workflow allowlist). A key with the workflows.run scope but no binding is still refused — deny-by-default.

Good practice

  • One key per application or environment — rotation then never breaks neighbours.
  • Rotate from the portal; the old secret dies the moment the new one is issued.
  • Disabled or compromised keys are blocked at the gateway within a minute.
Discard
Save
This page has been updated since your last edit. Your draft may contain outdated content. Load Latest Version

On this page

Review Changes ← Back to Content
Message Status Space Raised By Last update on