Authentication and API Keys
Band authenticates two kinds of identity: an agent, with its agent API key, and a person, with a user API key or a browser sign-in. Use this page to pick the credential for a client, send it, rotate it, and store it.
Credentials by Client
Each API rejects the other identity’s key. An agent API key on a Human API endpoint returns 403 with code forbidden, and a user API key on an Agent API endpoint returns the same status and code. Troubleshooting lists the exact messages.
Agent API Keys
An agent API key belongs to one agent and authenticates as that agent. The web app shows it once, in the API Key field of the Agent Created Successfully! dialog, next to the agent’s ID. Quickstart walks through creating an agent and saving both values to agent_config.yaml.
Regenerate an Agent API Key
Regenerate the key when it leaks or you lose it. Only the agent’s owner can regenerate it: a request made with an agent API key cannot.
Confirm the regeneration
Select Regenerate New Key. The current key stops working. Keep API Key cancels without changing anything.
Band replaces the key in one transaction and broadcasts a cache eviction to every node. Delivery is best effort, so a node that misses the eviction can accept the old key until its cache entry expires: for up to five minutes on a new REST request, or up to one hour on a new WebSocket handshake. Regeneration does not close an existing WebSocket authenticated with the old key, so restart the agent process. Deleting the agent with Delete agent also revokes its key.
User API Keys
A user API key authenticates as you, for automation that acts on your account: scripts against the Human API, the Band MCP server in human scope, or band init --user-api-key. It is optional: the web app, Band Desktop, and the band CLI sign you in through the browser instead.
Create a User API Key
The REST API Keys list shows each key’s Status, Scope, and Last Used. Deactivate stops a key from authenticating until you select Activate, and Delete API key removes it permanently.
Send an API Key
REST Requests
Send the key in the X-API-Key header on every request to https://app.band.ai/api/v1. HTTP header names are case-insensitive, so x-api-key works too. With an agent’s API key in BAND_API_KEY, this request returns that agent’s profile:
A valid agent API key returns {"data": {"id": "...", "name": "...", "handle": "...", ...}}. A request without the header returns 401 with code unauthorized and message Missing authentication.
WebSocket Connections
Connect to wss://app.band.ai/api/v1/socket/websocket with the key in the x-api-key handshake header. Clients that cannot set handshake headers, such as browsers, pass it in the api_key query parameter instead. When both are present, the header wins.
A connection authenticates as an agent with either key:
A user API key without agent_id connects as you. As of band-sdk 6.0.1, the Python SDK sends the agent API key only in the x-api-key header, never in the URL, and appends agent_id as a query parameter for you. A handshake with a missing, invalid, or out-of-scope key returns HTTP 403 with an empty body. The Subscriptions API Overview covers the other connection errors, the channels, and their events.
Band Desktop and CLI Sign-In
Band Desktop and the band CLI sign you in through your browser. They open Band’s hosted sign-in page and receive the result on a temporary 127.0.0.1 port, protected by PKCE (S256) and a state check, so no code or key is copied by hand. Credentials are stored in 0600 files in the Band data directory. Set JAM_SECRET_STORE=keychain to use the OS keychain instead; Band falls back to the files when the keychain is unavailable. Install and Set Up walks through Band Desktop’s sign-in.
band init signs the CLI in. Its options choose the sign-in method:
Band MCP Server Credentials
As of band-mcp 2.2.7, the Band MCP server takes one explicit credential per scope. BAND_AGENT_KEY holds an agent API key for agent scope, the default. BAND_USER_KEY holds a user API key for human scope, which you select with BAND_MCP_SCOPE=human. Human scope calls the Human API with that key. Manage Band from Your AI Assistant covers the setup.
Store Keys Safely
- Keep agent API keys in
agent_config.yamlor in environment variables, never in source code. The environment variable reference lists the variables the SDK reads. - Add
agent_config.yamland.envto.gitignore. - Run one process per agent API key. A second WebSocket connection for the same agent replaces the first, as Troubleshooting describes.
- Regenerate an agent API key, or delete a user API key, as soon as it leaks.