API keys

Scopes, creation, rotation and revocation.

Raw Markdown for agents: api_keys.md. MCP: read_docs("api_keys").

API keys authenticate scripts, integrations and agents against the public REST API (/v1/) and the operations endpoint POST /api/v1/operations/<key>/invoke/ (also POST /api/v1/operations/invoke/ with {"key", "input"}), as Authorization: Bearer adl_<env>_...; paths are relative to the API host in read_docs("getting_started"). Each key carries scopes of the form <domain>:<read|write|destroy> plus *:read; a write scope includes read.

Who a key acts as:

  • A personal key (api_keys.create without tenant_id) acts as its user in every workspace the user is seated in; name an organization with tenant_id or a Space id as with any token. An organization may refuse personal keys (personal_api_keys_disabled) or cap their age (api_key_lifetime_exceeded).
  • An organization key (tenant_id of an organization you administer) acts as the organization's own service user, an admin of that organization and nowhere else (api_key_wrong_tenant); limited to spaces, see Rules. It holds no connections: it uses one only through a grant shared in a Space (read_docs("integrations")).

Operations endpoint with an API key (actor api, audited with the key id, same rate limits and request log as /v1/):

  • An operation with a /v1/ route needs the scope of that route.
  • Any other operation needs <domain>:read for a pure read, <domain>:write for a write or external side effect and <domain>:destroy when it is irreversible; it must be one an agent may call (not reserved for people in the app or for the platform) in a domain that has API key scopes.
  • Never with a key (api_key_not_supported): api_keys.create, api_keys.rotate, integrations.proxy.token, collaboration tickets, inbox.secrets.*, organization administration and operator operations.
  • Searching and describing operations (/api/v1/operations/, describe/, context/, docs/) still need an OAuth token (MCP, adlass login) or the app session; /v1/openapi.json documents the REST routes.

Authentication errors:

  • 401 unauthorized: the token is not adl_<env>_ plus 43 characters of this environment, the key is unknown, or its user is archived or no longer in the organization that issued it.
  • 401 api_key_revoked: revoked.
  • 401 api_key_expired: past expires_at, or an old secret past its 24-hour rotation grace.
  • 403: insufficient_scope (details.required_scope), api_key_wrong_tenant, personal_api_keys_disabled, api_key_lifetime_exceeded, api_key_space_restricted, tenant_suspended.

Operations: api_keys.list, api_keys.get and api_keys.usage read metadata and request counts (never the secret). api_keys.update renames a key or narrows its scopes. api_keys.revoke ends a key permanently. api_keys.create and api_keys.rotate return the secret once; both are for people signed in to the app (human_only for agents and API keys).

Keys for local scripts (agents): an agent with a shell never sees the secret.

  1. Agree with the user on label, purpose (shown on approval), scopes, lifetime_days (default 30, at most 90) and kind: personal (acts as the user in every workspace they belong to) or organization (with tenant_id of an organization the user administers, optionally limited to space_ids with space_role).
  2. api_keys.request answers request_id, approve_url, valid_until (15 minutes), file and, in the first answer only, claim_token and commands (posix, powershell). A replay of the same idempotency key has no commands: request again with a new key.
  3. The user opens approve_url, may untick scopes and approves or denies. An approved request can be claimed for 10 minutes.
  4. Poll api_keys.request_get until status is approved, then run the command once, unchanged. It POSTs Authorization: Claim <token> to /api/v1/keys/claim/ and writes ADLASS_API_KEY=... and ADLASS_API_URL=... into ~/.config/adlass/keys/<label>.env (Windows %APPDATA%\adlass\keys\<label>.env), mode 0600, never over an existing file. Load it with set -a; . <file>; set +a; never print or copy it.
  • Scopes an agent may request: <domain>:read or :write of spaces, documents, records, data, todos, pages, scripts, routines, guides, workflows, queues, integrations, rules, derivations, summaries and watch. Never *:read, :destroy, users, tenant, audit, api_keys, organization, shares, partners, approvals or inbox: a person creates such keys in the app.
  • api_keys.request is for agent logins (MCP, CLI; agent_clients_only otherwise), at most 5 per hour per user. Approve and deny need the app.
  • Claim answers: 200 the env lines; 401 claim_required (header missing); 404 claim_invalid; 409 approval_pending, label_taken; 403 claim_not_allowed (the user lost the right meanwhile); 410 request_denied, request_expired, claim_used; 429 rate_limited.
  • A second claim within 24 hours revokes the key (and its rotations) and notifies the user: someone else held the token. claimed without a file: revoke the key with api_keys.revoke and request again.
  • The claim token is in your context until it is used: the user's approval is the gate, so tell them to approve only a request they just made with you.

Rules:

  • Creating and rotating a key in one call needs a Clerk session (the Adlass app); an API key cannot mint or rotate keys, and an agent asks with api_keys.request.
  • Scopes can only be narrowed, never widened. Users, tenant and audit scopes need the admin role.
  • An organization key may be limited to some of the organization's spaces (space_ids on api_keys.create, listed as spaces; empty means the whole organization). It then acts as a member of those spaces only, with the role given as space_role: reader (default) or editor, which may also write records and documents there (each space in spaces shows its role). It cannot create spaces (api_key_space_restricted) and sees nothing that belongs to another space. space_role without space_ids is refused. It takes only scopes of space-bound domains (spaces, documents, records, data, pages, queues, routines, guides, workflows, scripts, rules, derivations, summaries, todos, shares); *:read and organization-wide domains are refused. The limit never changes; create a new key instead.
  • A rotated key keeps its old secret valid for 24 hours (and its spaces and role there); rotating the new key again revokes the old secret at once.
  • Never print or store a returned secret anywhere except where the user asked.

Rate limits and 429 (every write and read, data.write included):

  • REST: two sliding one-minute windows, the API key (key, its own rate_limit_per_minute or the plan's api_requests_per_minute) and the workspace (tenant, the plan's api_requests_per_minute: 60 free, 120, 300, 1000, 3000 by plan). Failed authentication has its own window (authentication, 30 per minute per IP). Only accepted requests count; a refused one is given back.
  • MCP: one window of mcp_operation_calls per user (300 per minute, reads and writes together), reported in RateLimit headers of the response.
  • Shared reads as a guest: guest_reads_per_hour. Templates: installs_per_hour, install_plan_per_minute, verification_rounds_per_day. Providers answer with their own limit as integration_rate_limited.
  • A 429 always carries Retry-After (seconds), RateLimit-Policy and RateLimit of the limit that fired (r=0, t equal to Retry-After) and a rate_limit object (name, limit, window_seconds, remaining, reset_seconds, retry_after; MCP: details.rate_limit). Wait retry_after seconds and repeat the same request with the same idempotency_key.
  • Successful responses list every limit that applied (r = remaining, t = seconds to refill). Keep a bulk load under the smallest q per w; use *_many and data.write batches instead of one call per item.
  • A cap that waiting does not lift is never a 429: billing_limit_reached and billing_credits_exhausted (402), template_quota_reached, script_run_limit_reached, script_version_limit_reached, script_monthly_budget_exhausted (409), script_capability_budget_exceeded (422).