Skip to content

Issue and revoke API keys

An API key lets your server call EdgeKit on behalf of one site. Every key is pinned to exactly one site when it is issued, and the pin cannot change. A key with no site is never issued, and a key used for another site is refused.

Keys are for servers only. Browser code calls EdgeKit from an allowed origin with the site header and, once the user signs in, their EdgeKit session. It never holds a key.

The console calls these tenant API keys. They are not console API keys, which a build uses to change your organization’s configuration: a console API key is refused here, and a tenant API key is refused there.

You need the site write permission (the Owner and Admin roles) to issue or revoke keys. Without it, the Tenant API keys section lists the keys and offers no actions.

  1. Open Delivery › Delivery › Tenant API keys and pick the site the key is for. The same section is on the site’s own page in Delivery › Delivery › Sites.
  2. In Tenant API keys, enter a Name that says what will hold the key, for example Paywall middleware — production. The name is the only way to tell two keys apart later. Up to 100 characters.
  3. Optionally enter Expires in (days): a whole number from 1 to 3650. Leave it empty for a key that does not expire.
  4. Select Can send streaming scores (streaming:write) only if the key will post your own per-user scores to POST /v1/streaming/{pipeline}. Leave it off for every other use. A key without it gets 403 on that route. Select Can erase users (users:erase) only if the key will erase users by EdgeKit user id with POST /v1/id/erase, or by identity provider subject with POST /v1/id/external/erase; see Erased users. Such a key can erase any user of your organization. A key without it gets 403 on those routes. Select Can push users from the identity provider (users:sync) only if your server will tell EdgeKit about changes in your login: POST /v1/id/external/sync, change-identifier, change-subject and revoke-sessions; see Tell EdgeKit about changes in your login. Such a key can take over any user of your organization by asserting their address verified. A key without it gets 403 on those routes. Select Can write content items and authors (content:write) only if the key will push your CMS’s content through the content API. Content belongs to your whole organization, so such a key writes items for every site, not only its own. A key without it gets 403 on those routes.
  5. Select Issue key.
  6. Copy the key, then select I have it.

The key starts with ek_ and is shown once. EdgeKit stores only a hash of it, so it cannot be shown again or recovered. If you lose it, issue another and revoke the lost one.

A new key works from its first request; issuing one needs no deploy.

Send the key in either header:

Terminal window
curl -i https://<tenant>.edgekit.ai/v1/iglu/api/schemas \
-H 'Authorization: Bearer ek_your_key'
const response = await fetch(
'https://<tenant>.edgekit.ai/v1/iglu/api/schemas',
{
headers: { 'x-api-key': process.env.EDGEKIT_API_KEY! },
},
);
console.log(response.status); // 200 when the key is valid

On a route that also selects a site with x-edgekit-site-id, the selected site must be the key’s site. The API reference marks which routes take a key: see the client API reference. A server SDK takes the key and the site id as options; see the @edgekitcloud/client-server reference.

Status Code Message Cause
401 unauthorized Missing API key. No key on the request.
401 unauthorized Invalid or missing API key. The key is unknown, revoked or expired.
403 forbidden This key is not pinned to the selected site. The key belongs to another of your sites.
403 forbidden This key does not hold streaming:write. A streaming write with a key that lacks streaming:write.
403 forbidden This key does not hold users:erase. An erasure with a key that lacks users:erase.
403 forbidden This key does not hold users:sync. A user push with a key that lacks users:sync.
403 forbidden This key does not hold content:write. A content API write with a key that lacks content:write.
404 not_found Unknown site. The selected site is unknown, disabled or not yet deployed.

Each row shows the key’s Name, its first characters (ek_ and six more), its Permissions (default when it holds none), its Status, how many Requests it has made, when it was Last used and when it Expires.

  • active: the key works.
  • revoked: someone took it out of service. It cannot be turned back on.
  • expired: it passed its expiry date. It cannot be extended; issue a new key.
  1. Issue a new key for the same site, with the same permissions as the old one: a replacement for a streaming key needs streaming:write too.
  2. Put the new key into your server’s configuration and deploy your server.
  3. Revoke the old key once its Requests count stops rising. Last used shows a date only.
  1. Select Revoke on the key’s row.
  2. Confirm with Revoke key.

The key stops working at its next request, and whatever holds it gets 401. No deploy is needed. Revoking keeps the row, with its request count and last use, so the key’s history stays visible.

edgekit.ai