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}'};
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 }'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.
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.
Example
{ "name": "sanity-plugin", "expiresInDays": 365}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.
Example
{ "id": "4f8f6a2e-9d31-4b7a-8c55-1e2d3f4a5b6c", "name": "sanity-plugin", "key": "wah_CLxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "siteIds": null}siteIds names a site the organization doesn’t own.
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"}