Skip to main content
This page covers how a request is authenticated: the two headers that carry a key, the key format and tiers, how to handle keys, every 401 the API returns, and how quickly a revoked key stops working. You need it before your first request and again when a key is rotated.

Sending the key

Send the key in the X-API-Key header:
or as a bearer token:
Both headers work on every /v1 endpoint, on the live stream and on the MCP endpoint. The stream cannot be opened from a browser EventSource, which cannot set headers; connect from a server.

Key format and tiers

A key is rk_live_<id>_<secret>: Routeur stores only the SHA-256 of the secret. A lost key cannot be shown again; ask for a new one and have the old one revoked. Every key has a tier that sets its per-minute limit and daily quota. Custom limits can be set on a key when it is issued. The limits in force for your key come back on every response in X-RateLimit-Limit and X-Daily-Quota-Limit; see Rate limits.

Handling keys

  • Keep keys on your server, in an environment variable or a secret store. A key in a browser, a mobile app or a public repository can be read and used against your quota.
  • Use one key per system so that revoking one does not stop the others.
  • To rotate, ask for a new key, deploy it, then have the old one revoked.
  • Nothing in the API reads or writes your key beyond checking it: there is no endpoint to list, create or revoke keys.

Errors

A request without a valid key returns 401 with WWW-Authenticate: Bearer realm="routeur", Cache-Control: no-store and the standard error body. Observed:
A 401 is not counted against any limit. /healthz and unknown paths (404 not_found) do not need a key.

Revocation lag

Each API instance caches what it knows about a key for one minute, so a revoked key can keep working for up to 60 seconds on an instance that checked it just before the revocation. The same cache applies to unknown keys: a key used before it was created is refused with invalid_api_key for up to a minute on that instance. Retry after a minute.

MCP

The MCP endpoint https://api.routeur.app/mcp takes the same key in the same headers. Protocol messages such as initialize and tools/list are authenticated but not counted; the REST requests a tool makes are counted as usual. A request without a key gets the same 401 as REST:
See Agents and MCP.