Mint an API key
const url = 'https://api.overwatch.weareheavy.dev/v1/keys';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"name":"sanity-plugin","expiresInDays":365,"access":"read"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.overwatch.weareheavy.dev/v1/keys \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "name": "sanity-plugin", "expiresInDays": 365, "access": "read" }'Mint a key bound to the caller’s organization. The organization id is
baked into the key, so the holder can’t widen its scope. Optionally
restrict the key to a subset of the organization’s sites via siteIds
(an agency minting a key per client); an empty or absent list means full
organization access.
Set access: read for a key that ships in a browser — a CMS plugin such
as a Sanity Studio tool, where every editor can see it. A read-only key
gets 403 on any request that isn’t GET.
Session-only, owner/admin. The plaintext key is returned once.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
A display name for the key.
Days until the key expires. Omit for a non-expiring key.
Restrict the key to these sites. Every id must belong to the organization. Empty or absent = full organization access.
full keys act with management capability (register sites, change
settings, trigger crawls). read keys may only make GET requests —
use them anywhere the key is visible to users, such as a CMS plugin
running in the browser.
Example
{ "name": "sanity-plugin", "expiresInDays": 365, "access": "read"}Responses
Section titled “ Responses ”The new key. Store key now — it is never shown again.
A freshly minted key. key is the plaintext, shown only in this response.
object
The plaintext API key (wah_…). Store it now — it is never shown again.
The key’s site scope, or null for full organization access.
full keys act with management capability (register sites, change
settings, trigger crawls). read keys may only make GET requests —
use them anywhere the key is visible to users, such as a CMS plugin
running in the browser.
Example
{ "id": "4f8f6a2e-9d31-4b7a-8c55-1e2d3f4a5b6c", "name": "sanity-plugin", "key": "wah_CLxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "siteIds": null, "access": "read"}siteIds names a site the organization doesn’t own, or access isn’t full or read.
object
A human-readable error message.
Example
{ "error": "unknown site ids: 0a1b2c3d-…"}Missing or invalid credentials.
object
A human-readable error message.
Example
{ "error": "invalid api key"}A dashboard session is required (API-key callers are rejected), or the session’s role does not allow this action.
object
A human-readable error message.
Example
{ "error": "a dashboard session is required"}