Developer API
Build on CerebroChain with OAuth 2.1.
Give your app or agent scoped, per-user access to CerebroChain's metered bot API through a standard OAuth 2.1 authorization-code + PKCE flow — consent screen, granular scopes, refresh-token rotation, and revocation. Calls draw from prepaid credits (1 credit = $0.001).
Two ways to authenticate
- OAuth 2.1 (per-user). Best for apps acting on behalf of a CerebroChain user. The user signs in and consents; your app receives a scoped, revocable Bearer token. Covered below.
- API key (machine-to-machine). For your own backend
agents, issue a key in
the
console and send it as the
X-API-Keyheader. Both paths bill the same tenant credit pool.
Register an OAuth app
Sign in to the console and open
Settings → OAuth apps. Give the app a name, one or more redirect URIs
(https, or http loopback for local development), and the
scopes it may request. You'll receive a
client_id and, for confidential apps, a
client_secret shown once — store it
securely; you can rotate it later but it is never shown again.
Programmatic clients may instead self-register via Dynamic Client Registration (RFC 7591).
Public vs confidential clients
- Public (
token_endpoint_auth_method: none) — SPAs, mobile, and CLI tools that can't hold a secret. Security comes from PKCE (S256) and exact redirect-URI matching. - Confidential (
client_secret_basicorclient_secret_post) — server-side apps. They additionally present aclient_secretat the token endpoint. Only a hash of the secret is ever stored.
The authorization-code + PKCE flow
-
Generate a PKCE
code_verifierand itscode_challenge(S256, required). -
Redirect the user to
/api/oauth/authorizewithclient_id,redirect_uri,response_type=code,code_challenge,code_challenge_method=S256, your requestedscope, and astate. -
The user signs in on
cerebrochain.comand approves the listed scopes. Your password and credentials never touch the app. -
We redirect back to your
redirect_uriwith a single-usecode(and yourstate). -
Exchange the code at
/api/oauth/token(grant_type=authorization_code) with thecode_verifier— and, for confidential clients, theclient_secret(HTTP Basic or in the body). You receive anaccess_tokenand arefresh_token.
Scopes
Request only what you need — every requested scope must be one the app is registered to hold (downscoping only). The consent screen lists each grant in plain English.
| Scope | Grants |
|---|---|
bot:read | Read priced market & supply-chain data feeds and on-chain monitoring status |
bot:invoke | Run priced compute, AI inference, intelligence, and route optimization |
chain:write | Tokenize warehouse receipts and manage on-chain monitoring (state-changing) |
credits:read | View developer-API credit balance and usage |
keys:manage | Issue and revoke developer API keys and OAuth apps |
wms:read | Read warehouse-management data (inventory, orders) |
logistics:read | Read logistics & fleet data |
executive:read | Read executive analytics (financial metrics, KPIs) |
mcp | Legacy composite used by the AI-assistant connector; expands to read + invoke + the hemisphere reads |
Calling the API
Send the access token as a Bearer credential to a priced
/api/bot/* endpoint:
curl https://cerebrochain.com/api/bot/data/market/forex \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Each priced call deducts credits from the tenant's pool and requires
the route's scope. A token missing the required scope gets
403 insufficient_scope; an invalid or expired token gets
401 with a WWW-Authenticate challenge. Top up
credits in
the console.
Token lifetime, refresh & revocation
- Access tokens expire after 1 hour. Use the
refresh_tokengrant at/api/oauth/tokento get a new pair; refresh tokens rotate on every use. - Reuse detection. If a rotated (already-used) refresh token is replayed, the entire token family is revoked — so a stolen refresh token can't outlive detection.
- Revocation. Revoke any token at
/api/oauth/revoke(RFC 7009). Tenants can also review and revoke connected apps from Settings → OAuth apps.
Endpoints & discovery
Issuer: https://cerebrochain.com. Metadata is published per RFC 8414 / RFC 9728:
| Endpoint | Purpose |
|---|---|
GET /.well-known/oauth-authorization-server | AS metadata (endpoints, scopes, auth methods) |
GET /.well-known/oauth-protected-resource | Protected-resource metadata |
POST /api/oauth/register | Dynamic Client Registration (RFC 7591) |
GET /api/oauth/authorize | Start the flow (PKCE S256 required) |
POST /api/oauth/token | Code exchange + refresh rotation |
POST /api/oauth/revoke | Token revocation (RFC 7009) |
Support
Questions or a bug? Email [email protected], call 775-719-9177, or use the contact form. Connecting an AI assistant instead? See the MCP connector guide.