Mint an API key
Mint a new API key for this organization.
Mint a new API key for this organization.
The secret is shown exactly once. Store it when you receive it; there is no endpoint that can show it again.
Requires the keys:write scope, which DENIES BY DEFAULT and is the one
scope a pre-scopes key does NOT hold implicitly — no key already in
circulation can mint another one until an account admin grants it.
The new key is always bound to the calling key's own organization, and may sit on the calling key's plan or a lower one but never a higher one.
Scopes. Omit scopes and the new key inherits everything the
calling key holds, minus key management. Send an explicit list to mint a
narrower key; send [] to mint one that can do nothing. You can never
grant a scope you do not hold — that is a 403, not a silently trimmed list.
Every key minted here carries an explicit scope list even when the calling
key does not, so the grandfather clause stops with this key rather than
propagating. GET /v2/scopes lists what is available.
The whole read-modify-write of the key store runs under a per-organization lock, so two creates issued at the same moment both survive rather than one silently overwriting the other.
Errors: 400, 401, 403 (missing scope, wrong organization, a scope the calling key does not hold, or a plan above the minting key's), 409 (another key change is in flight, or the organization is at its active-key ceiling), 422, 429, 503.
Rate limit: 1000 requests per minute per organization (bucket default). Exceeding it returns 429 with Retry-After; the X-RateLimit-* response headers report your remaining allowance on every call.
v2/api-keysAuthorization
AuthorizationRequiredBearer <token>
Your Graine API key. Create one in the dashboard under Developers, or via POST /v2/api-keys. Send it as Authorization: Bearer <key>.
In: header
Request Body
application/jsonRequirednameRequiredName
Human label for the key, stored as the developer name.
1Maximum length: 100emailEmail | null
Contact address for the key's owner.
"email"descriptionDescription | null
Free-text note.
500planPlan | null
Plan for the new key. Defaults to the minting key's plan and may never exceed it.
40grant_api_keys_writeGrant Api Keys Write
Grant the new key key-management rights so it can mint and revoke keys itself. Off by default: the scope is otherwise stripped from the inherited permissions.
falsescopesScopes | null
Scopes for the new key. Omit to inherit everything the minting key holds (minus key management). Send an explicit list to mint a narrower key; an empty list mints a key that can do nothing. You can never grant a scope you do not hold yourself. See GET /v2/scopes.
Query Parameters
organization_idOrganization Id
Optional; must match the key's organization.
Response Body
201
The new key. The secret is present in this response and nowhere else.
key_idRequiredKey Id
Stable id. Pass this to DELETE /v2/api-keys/{key_id}.
api_keyRequiredApi Key
The secret. Shown exactly once — store it now.
key_previewRequiredKey Preview
Masked form of the key, safe to store and display.
developer_idRequiredDeveloper Id
Developer record created for this key.
developer_nameRequiredDeveloper Name
The label you sent as name.
planRequiredPlan
Plan the new key holds. Never higher than the minting key's.
rate_limit_tierRequiredRate Limit Tier
Tier the new key's request ceilings are drawn from.
org_idRequiredOrg Id
The organization the new key belongs to.
created_atRequiredCreated At
When the key was minted.
messageRequiredMessage
A reminder that the secret is shown exactly once.
401
1100 — missing, unknown or inactive API key. 1101 — a browser session token was presented instead of an API key.
errorRequiredError
Stable integer code from the /v2 error table. Branch on this.
messageRequiredMessage
One human-readable sentence. Wording may change; the code will not.
403
1102 — the key is valid but lacks the scope this endpoint requires, or names another organization. GET /v2/scopes reports what a key holds.
errorRequiredError
Stable integer code from the /v2 error table. Branch on this.
messageRequiredMessage
One human-readable sentence. Wording may change; the code will not.
409
1201 — the resource's current state does not allow this action.
errorRequiredError
Stable integer code from the /v2 error table. Branch on this.
messageRequiredMessage
One human-readable sentence. Wording may change; the code will not.
422
1001 — the body or query failed validation; the message names the first offending field.
errorRequiredinteger
Stable integer code from the error table. Branch on this, not on the message.
messageRequiredstring
One human-readable sentence. Wording may change; the code will not.
429
1300 — the per-organization request rate or concurrent-call limit was reached. Carries Retry-After.
errorRequiredError
Stable integer code from the /v2 error table. Branch on this.
messageRequiredMessage
One human-readable sentence. Wording may change; the code will not.
503
1501 — a service this endpoint depends on is unreachable or returned a 5xx.
errorRequiredError
Stable integer code from the /v2 error table. Branch on this.
messageRequiredMessage
One human-readable sentence. Wording may change; the code will not.
The new key. The secret is present in this response and nowhere else.

