API Authentication
How to authenticate API requests to AlonChat using API keys
API Authentication#
Programmatic access uses a credential AlonChat can verify. The same project operations are available through the API, SDK, CLI, and MCP; the credential type changes, not the business contract.
| Method | Use it for | How it is sent |
|---|---|---|
| Project API key | Servers, CI, the SDK, the CLI, and unattended MCP | Authorization: Bearer sk-… |
| Account OAuth | Interactive MCP clients such as Codex, Claude, OpenClaw, and Hermes | Browser consent at https://alonchat.com/api/mcp |
OAuth is not a second API key. It cannot call chat_with_agent, and an API key cannot approve its
own held operation. See Connect with MCP.
API Keys#
API keys are managed at the project level. Create them in Project Settings → API Keys, and optionally restrict a key to a single agent. (Older agent-scoped keys still work where they exist.)
Keys use the sk- prefix (for example sk-a1b2c3…) and are shown in full only once at
creation.
Permissions#
API keys have configurable permissions. Common ones:
| Permission | Description |
|---|---|
chat | Send messages and receive agent responses |
read_sources | Read knowledge sources for the scoped agents. This does not allow uploads. |
read_agents | Read agent metadata for the project |
read_conversations | Read bounded production transcripts for the scoped agents |
agent_design_read | Inspect setup, validate proposals, and read design sessions |
agent_design_write | Save review-gated agent-design drafts; does not publish them |
billing_read | Read subscription, plans, usage, and invoices. Card changes stay in the dashboard. |
activity_cases_write | Turns on the dashboard's Write activity cases flag. Confirm the effect with discovery. |
The create dialog also offers automation scopes such as knowledge.write and billing.read. Those
scopes are the allowlist for project operations. A legacy flag does not grant every related scope:
document and spreadsheet uploads need knowledge.write, and all four billing reads need
billing_read. Enable only what that integration uses. Discovery, not the installed package, shows
which operations the key can run.
Creating, listing, and revoking keys#
Create a key in Project Settings → API Keys. You can create up to 20 keys per project. The full secret is shown once. Restrict the key to selected agents when it does not need the whole project.
Revoke a key from the same page. Revocation takes effect immediately and cannot be undone.
Key management uses your signed-in AlonChat account. It is not available to the project API key itself. The older request that posted only a name and a permissions object is no longer accepted.
Using an API Key#
Include the API key in the Authorization header:
curl -X POST https://alonchat.com/api/v1/chat/{agentId} \
-H "Authorization: Bearer sk-xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: hello-001" \
-d '{"message": "Hello!"}'
Rate Limits#
The Chat API is rate-limited to 60 requests per minute per API key. Rate-limit headers are returned on responses. Exceeding the limit returns 429 with retry guidance.
When a Call Is Refused#
Project operations return one receipt. A refusal looks like this:
{
"operation": { "id": "billing.usage.get", "contractVersion": 1 },
"requestId": "request-id",
"correlationId": "correlation-id",
"occurredAt": "2026-03-15T10:30:00Z",
"status": "failed",
"error": {
"code": "SCOPE_DENIED",
"message": "The actor does not have the required operation scope",
"retryable": false,
"details": { "missingScopes": ["billing.read"] },
"resolution": {
"actor": "key_owner",
"summary": "This API key does not carry billing.read. Ask a project owner to enable the matching permission on the key in Project settings → API.",
"url": "https://alonchat.com/dashboard"
}
}
}
The Chat API uses its own flat error object, such as
{ "error": "API key does not have chat permission" }, and does not use this receipt.
retryable answers the transport: should the same request be sent again. resolution answers the
actor: who can lift the refusal and where. Most denials are retryable: false and still resolvable,
so an agent should read resolution before deciding a call is permanently blocked.
actor is one of:
| Value | Meaning |
|---|---|
caller | Change the request and try again — no human needed |
key_owner | Whoever issued the API key or approved the MCP connection must act |
project_owner | A project owner or admin must act in the AlonChat dashboard |
The CLI prints the summary and URL to stderr. MCP sets isError: true and includes the receipt when
the API returned one. An error with no resolution has no known route out — treat it as a genuine
failure and report it.
Security Best Practices#
- Never commit API keys to version control
- Use environment variables or a secrets manager in production
- Restrict keys to one agent when an integration only needs one bot
- Rotate keys if they may have been exposed
- Use server-side code only — never embed keys in browsers or mobile apps