Installation keys

An installation key is an API key your app gets through Stackbone sign-in instead of a person pasting one. A workspace owner or admin signs in, reads what your app is asking for, and approves it. Your app then holds a key for that one box, with exactly the grants that were approved, until somebody revokes it in Studio.

Use it when you build a product on top of Stackbone and each of your customers has their own box: a "Connect Stackbone" button in your app replaces the step where the customer copies a key out of Studio.

How it works

  1. You register your app once in Stackbone and get a client id.
  2. Your app knows the customer's box URL and nothing else.
  3. It reads the box's installation document to find where to send the customer.
  4. The customer signs in at Stackbone and approves your app on a consent screen that names your app and lists every grant.
  5. Your app receives a short-lived access token and trades it, once, at the box for an sbk_live_ key.

The key is minted by the box and stored there as a digest. Stackbone never sees it. It belongs to the installation, not to the person who approved it, so it keeps working after that person signs out or leaves the organization.

Grants

Your app asks for installation:connect plus one scope per grant it needs. Each scope becomes a grant on the key, on every agent and workflow of the box.

Scope What the key may do Routes
agent:chat Chat with the box's agents the three chat wires
workflow:start Start a workflow run POST /api/workflows/{name}/start
workflow:chat Stream a workflow run POST /api/workflows/{name}/chat
runs:read Read every run, its steps and its output GET /api/runs, GET /api/runs/names, GET /api/runs/{id}, GET /api/runs/{id}/steps
config:read Read the agent configuration GET /api/config
config:write Write a new configuration version PUT /api/config
recordings:read Read a voice call's recording, with a one-hour audio URL GET /api/voice/recordings?session_id=

Ask for the fewest grants your app needs. The consent screen shows each one in plain words, and a customer is more likely to approve a short list.

A key never reads the Studio assistant's runs: those belong to the person who chatted with it.

Connect a box

1. Read the installation document

curl https://customer-box.example.com/.well-known/stackbone-installation
{
  "resource": "https://customer-box.example.com/mcp",
  "authorization_server": "https://app.stackbone.ai",
  "scopes_supported": ["installation:connect", "agent:chat", "workflow:start", "…"],
  "key_endpoint": "https://customer-box.example.com/api/api-keys/exchange"
}
Field Use it for
resource The resource parameter of the authorization request. It names this one box.
authorization_server Where the customer signs in. Read its metadata at /.well-known/oauth-authorization-server.
key_endpoint Where you trade the access token for the key.

A box that answers 503 with code: "installation_not_ready" cannot run this flow: it is self-hosted with an operator token, or it is not registered yet. Ask the customer for a key made in Studio instead (API keys).

2. Register your app

Only an app registered in Stackbone can be installed on a box. An owner or admin of your own organization registers it once, at Settings → Apps → Register app on app.stackbone.ai:

Field What to enter
Name What the customer sees on the consent screen and in Studio, for example Misato.
Homepage Optional. An https URL.
Logo URL Optional. An https URL to an image.
Redirect URIs One per line, up to ten. https, or http on localhost or 127.0.0.1 for local development.
Confidential On for an app with a server that can keep a secret. Off for an app that runs in a browser.

You get a client id and, for a confidential app, a client secret. The secret is shown once. Store both as secrets of your app, for example STACKBONE_CLIENT_ID and STACKBONE_CLIENT_SECRET.

The consent screen shows your app's name with "Registered by" and your organization's name, and Studio lists the key the same way. That is what tells the customer the name was set by somebody accountable for it.

A client that registered itself (dynamic registration, or a Client ID Metadata Document) still works for MCP, but not for an installation: Stackbone refuses installation:connect to it with code: "installation_requires_registered_app" before the customer can approve.

3. Send the customer to sign in

Run an ordinary authorization code flow with PKCE (S256):

https://app.stackbone.ai/api/auth/oauth2/authorize
  ?response_type=code
  &client_id=<your client id>
  &redirect_uri=https://your-app.example.com/stackbone/callback
  &scope=installation:connect runs:read config:read config:write recordings:read
  &resource=https://customer-box.example.com/mcp
  &code_challenge=<S256 of your verifier>
  &code_challenge_method=S256
  &state=<your state>

The customer must be an owner or admin of the workspace. Anyone else can approve the screen, but the box refuses the key exchange.

Trade the code that comes back to your redirect_uri at the server's token_endpoint, with your verifier and the same resource. A confidential app also sends its client id and secret in an Authorization: Basic header:

curl -X POST https://app.stackbone.ai/api/auth/oauth2/token \
  -u "$STACKBONE_CLIENT_ID:$STACKBONE_CLIENT_SECRET" \
  -d grant_type=authorization_code \
  -d code="$CODE" \
  -d redirect_uri=https://your-app.example.com/stackbone/callback \
  -d code_verifier="$VERIFIER" \
  -d resource=https://customer-box.example.com/mcp

You receive an access token that lives five minutes.

4. Trade the token for the key

curl -X POST https://customer-box.example.com/api/api-keys/exchange \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{ "name": "Your app" }'
{
  "key": "sbk_live_4f3c2b1a9e8d7c6b_zK7Wq2xR-4nT8vB1yE0sM6dH3jL5pC9fG2aU4iO7rQ8",
  "api_key": {
    "id": "5d1e0d5e-6f6b-4f3f-9a0d-1a2b3c4d5e6f",
    "name": "Your app",
    "client_id": "<your client id>",
    "client_name": "Your app",
    "client_publisher": "Your organization",
    "permissions": [{ "action": "runs:read", "resourceNames": ["*"] }],
    "…": "…"
  }
}

The key is in the response once. Store it as a secret, one per box. name is optional and defaults to your app's registered name. It is how the key is listed in Studio.

Each access token is exchanged once. A second exchange answers 409.

Use the key

Send it as Authorization: Bearer <key>, as with any API key:

curl https://customer-box.example.com/api/runs?limit=20 \
  -H "Authorization: Bearer $STACKBONE_KEY"

A route the key holds no grant for answers 403 with code: "invocation_not_permitted". A route no key may reach answers 401 with code: "api_key_not_accepted".

When the exchange is refused

Status code What happened
400 no_grants The token carries installation:connect and no grant scope.
401 invalid_token No token, an expired one, or one issued for another box.
403 insufficient_scope The token lacks installation:connect.
403 access_denied The person who approved is not an owner or admin of this workspace.
409 already_exchanged This token was already traded for a key. Run the flow again.
503 installation_not_ready This box cannot verify a Stackbone sign-in. Use a key made in Studio.

Rotate and revoke

The key lists in Studio under Integrations → API keys, marked "Installed by" with your app's name and your organization. An owner or admin revokes it there, and the next request with it fails.

To rotate, run the connect flow again, switch your app to the new key, and ask the customer to revoke the old one.

Every key minted this way lands in the box's activity log with the person who approved it, your client id and your app's name.

Deleting your app in Settings → Apps stops it signing anyone in again. Keys it already holds belong to each box and keep working until revoked in Studio.

On a local box

A box under stackbone dev runs the same flow through its tunnel address. The key is stored in the local database and survives a restart, but the tunnel address may change, so update the URL your app calls.

What's next

  • API keys: the key format, the grants and the refusals in full.
  • MCP: the same sign-in, used by coding agents to act as you.
  • Security and auth: how the box decides who gets in.
BUILT WITH ❤️ FROM CANADA AND SPAIN