Authentication

API keys, scopes, key binding, rotation, IP allowlists and end-user identity.

API keys

Send your key as a bearer token over HTTPS on every request.

HTTP
GET /v1/workspaces HTTP/1.1
Host: api.heyllo.co
Authorization: Bearer hk_live_7Qf2cN1xZpLm_...
  • Format. hk_live_ or hk_test_, then a 12-character key ID, an underscore and a 43-character secret (256 bits). Secret scanners can match the hk_ prefix.
  • Shown once. The full key is returned only by the call that creates or rotates it. Heyllo stores a keyed hash, so a lost key cannot be recovered, only replaced. Later reads return the prefix and last4.
  • Generic failures. A missing, malformed, unknown, expired or revoked key always returns 401 invalid_api_key. Repeated failures from one IP address are rate-limited.
  • Environment. A live key only works against live data and a test key only against test data. See environments.
Keep secret keys on your servers. Never put them in browser code, mobile apps or source control.

Scopes

Each key carries a list of scopes. A request to an endpoint whose scope the key lacks returns 403 missing_scope.

ScopeAllows
workspaces:readList and read workspaces
workspaces:writeCreate, update, suspend and delete workspaces (organisation keys only)
bots:readList and read bots, and fetch the widget embed snippet
bots:writeCreate, configure and deactivate bots
knowledge:readList a bot's documents and knowledge sources, and read knowledge jobs
knowledge:writeAdd, replace and delete a bot's documents, websites, files, text and Q&A pairs
actions:manageCreate, change, test and delete actions, and link them to bots (organisation keys only)
chat:writeCreate conversations and send messages (runs the agent)
conversations:readList and read conversations and their messages
handoff:writeRequest, accept and resolve handoffs, and send human-agent replies
webhooks:manageManage webhook endpoints, list events and redeliver them
usage:readRead month-to-date usage and limits
keys:manageCreate, list, rotate and revoke API keys (organisation keys only)

Keys can also hold sessions:write, end_users:write and voice:invoke. They are reserved for browser session tokens, end-user data export and deletion, and a voice endpoint, none of which are available yet.

A key can only create keys whose scopes are a subset of its own. Asking for more returns 403 scope_escalation.

Key binding

A key always belongs to your organisation. When you create it you can narrow it to one workspace (workspace) or one bot (bot).

  • Organisation keys see every workspace in their environment. Use them for provisioning.
  • Workspace-bound keys only see objects in that workspace. They cannot hold workspaces:write or keys:manage, and cannot create, suspend or delete workspaces.
  • Bot-bound keys only see that bot and its conversations, jobs and knowledge. They cannot create bots.

An object outside the key's organisation, environment or binding returns 404 resource_missing, so a key holder cannot learn whether it exists.

Create a workspace-bound key
curl https://api.heyllo.co/v1/api_keys \
  -H "Authorization: Bearer $HEYLLO_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: key-cust-881-chat" \
  -d '{
    "name": "Acme chat service",
    "scopes": ["chat:write", "conversations:read"],
    "workspace": "ws_4hT8kQ2mZx7LpR1vN9cW3yBd",
    "ip_allowlist": ["203.0.113.0/24"]
  }'

The response contains the key object and, once, its secret.

Expiry, rotation and revocation

  • Expiry. Set expires_at (ISO 8601, in the future) when creating a key. After that time the key returns 401.
  • Rotation. POST /v1/api_keys/{id}/rotate issues a replacement with the same name, scopes, binding, allowlist and expiry. The old key keeps working for expire_old_in_seconds (0 to 604800, default 86400), so you can deploy the new key without downtime. Requires an Idempotency-Key.
  • Revocation. DELETE /v1/api_keys/{id} revokes the key. It stops working within 30 seconds everywhere.
  • Deleting a workspace revokes every key bound to it.
Shell
curl https://api.heyllo.co/v1/api_keys/key_9Rt2Wc6Yz3Kq8Xp1Lm4Vn7Bd/rotate \
  -H "Authorization: Bearer $HEYLLO_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: rotate-2026-11" \
  -d '{"expire_old_in_seconds": 3600}'

The response contains the new key object with its secret, replaces (the old key ID) and old_key_expires_at.

IP allowlists

Set ip_allowlist to up to 20 IPv4 or IPv6 addresses or CIDR ranges to restrict where a key can be used. Requests from other addresses return 403 ip_not_allowed. An empty or missing list allows any address. Invalid entries are rejected with 400 ip_allowlist_invalid.

End-user identity

End users are identified by your own external_id, passed in end_user when you create a conversation. Because it arrives from your server with a secret key, Heyllo treats that user as verified: the agent can use memory from that user's earlier conversations. Conversations created without an end_user are anonymous and only have the context of their own thread.

JSON
{
  "bot": "bot_k3x9q2m7v1p8z4w6t5r0y2",
  "end_user": { "external_id": "cust-881-user-42", "name": "Amina", "email": "[email protected]" }
}

Only send identifiers you are entitled to share. Use the same external_id for the same person every time, and never one chosen by the end user.