/agent/identity endpoint and no agent_auth block in the authorization server metadata, so do not try to register yourself.
Protected resources
Step 1: Discover
Current behavior to plan around:
- The MCP server answers
401withWWW-Authenticate: Bearer realm="Blaxel MCP", resource_metadata="...". Follow it. - The Blaxel API answers
401with{"code":401,"error":"Unauthorized"}and noWWW-Authenticateheader. Come back to this file. https://api.blaxel.ai/.well-known/oauth-protected-resourcedescribes the MCP server (resourceishttps://api.blaxel.ai/v0/mcp). The Blaxel API has no protected resource metadata of its own yet.- The metadata only advertises the
openid,email,profileandoffline_accessscopes. Access follows the role of the user or service account in each workspace, not the token scope. - The CLI device login and the client credentials grant are not advertised in the metadata. Use them as described below.
Step 2: Pick a method
- You can run the Blaxel CLI and a human can open a URL: use CLI login.
- You are an MCP client: use MCP OAuth.
- You run unattended (CI, backend, scheduled job) and a workspace admin created a service account for you: use service account client credentials.
- None of the above: use the API key fallback.
Step 3: Get a credential
CLI login
- The user confirms the login in a browser. The CLI waits about 3 minutes for that confirmation.
- Without a terminal (for example when a coding agent runs the command),
bl loginasks nothing. It prints the login URL on its own line and how long it waits. Show that URL to the user and wait for the command to exit. This needs CLI version 0.1.123 or later. - Without a workspace argument,
bl loginpicks the current workspace if the login can use it, or else the first workspace by name, and says which one. - With a workspace argument,
bl loginusesBL_CLIENT_CREDENTIALSorBL_API_KEYwhen one is set. - The CLI saves the credential in its local configuration and refreshes it. The Blaxel SDKs reuse it.
bl tokenprints a current access token. - The login token reaches every workspace of the user. Select one per request (see Step 4).
MCP OAuth
Connect tohttps://api.blaxel.ai/v0/mcp and let your MCP client run the OAuth flow. The authorization server is https://signin.blaxel.ai. It supports authorization code with PKCE (S256), public clients, dynamic client registration and Client ID Metadata Documents. The user signs in to Blaxel in a browser and approves the client.
Reference: https://docs.blaxel.ai/skills-mcp
Service account client credentials
A workspace admin creates a service account in the Blaxel console and gives you its client ID and client secret through your environment. Exchange them for a short-lived access token:- The token is valid for 2 hours. Request a new one when it expires. There is no refresh token.
- The token only works in the service account’s workspace, with the service account’s role.
- The CLI and SDKs read the same credentials from
BL_CLIENT_CREDENTIALS, set to the base64 encoding ofclient_id:client_secret, withBL_WORKSPACE.
API key fallback
Use an API key only when no OAuth method fits. A human creates it in the Blaxel console (Profile > Security for a personal key, workspace settings for a service account key) and sets it in your environment:- An API key never expires unless an expiry was set when it was created.
- A personal API key reaches every workspace of its user. Prefer a service account key, which only reaches one workspace.
- The
blCLI readsBL_WORKSPACEandBL_API_KEYdirectly, sobl loginis not needed.
Step 4: Call the API
X-Blaxel-Authorization: Bearer ...is accepted in place ofAuthorization.- Send
X-Blaxel-Workspacewhen the identity belongs to more than one workspace. Without it, those requests fail with400.
Step 5: Create a sandbox
The same credential works on the sandbox URL that the create call returns:DELETE /v0/sandboxes/my-sandbox. SDKs and the full sandbox API: https://docs.blaxel.ai/Sandboxes/Overview
Errors
Revocation
- There is no token revocation endpoint. Access tokens expire after 2 hours.
- Users delete their API keys in the Blaxel console. Workspace admins delete service account keys and service accounts.
bl logoutremoves the credential saved by the CLI. It does not revoke tokens on the server.
Not supported
Do not attempt these flows. Blaxel does not offer them today:- agentic registration (
/agent/identity), including anonymous registration - verified-email claim ceremonies (
service_auth) - ID-JAG identity assertions and the JWT-bearer grant
- token exchange
- revocation events (Security Event Tokens)
- issuing a credential to an agent before a human signs in to Blaxel or a workspace admin creates it