Credentials

Create an API key

Create an API key, super admin or narrowed to a preset or a custom permission set, optionally with an expiry and conditions. The secret is returned once. A key never holds more than the person creating it; the credential policy decides who may create which keys. grant is required: a request without it is refused (400 validation_error, details.reason grant_required), never treated as super admin. A custom key must say which mail it reaches: the addresses and domains it lists (grant.addresses, grant.domains), or every mailbox in the organization with grant.mail_scope "org", which cannot be combined with them; one that says neither is refused (400 validation_error, details.reason mail_scope_required). Super admin, Send only and Read only reach every mailbox by definition. members:read is only for an org-wide custom key: naming it with grant.addresses or grant.domains is refused (400). Owners and admins are emailed about every super admin key. Send an Idempotency-Key to retry safely: a second create by the same person under the same key makes no second key and is refused (409 idempotency_key_reused) with the first key's id in error.details.key_id, so a caller whose first answer was lost can revoke that key. The onboarding field is for the dashboard only. The Primitive CLI's token is refused, even with a step-up: keys are created in the dashboard or by an app the person connected. While the organization's keys API is not enabled, this answers 404 feature_disabled, except that a dashboard session may still create a super admin key (the dashboard's own create).

Person only: a dashboard session, or the person's own OAuth token with a step-up token for purpose keys.create in the Primitive-Step-Up header. Without one an OAuth token is answered 403 step_up_required, whose details carry the dashboard URL that issues it (or 403 grant_forbidden when the person's role could not do it anyway). The person's role must hold keys:manage. API keys and agent connection keys are refused. An agent acting for the person is refused unless it carries a step-up token the person issued in the dashboard.

post/keys

Request

  • Base URL
    https://api.primitive.dev/v1
  • URL
    https://api.primitive.dev/v1/keys
  • Auth
    HTTP bearer

Headers

Primitive-Step-Upstring

A single-use step-up token the person issued in the dashboard for this operation's purpose (valid five minutes). Needed only when calling with an OAuth token; a dashboard session does not send it. Accepted only with a token of the client it was confirmed for; refused with a token issued for MCP and with any API key.

Idempotency-Keystring

Up to 200 printable characters. A second create by the same person under the same key makes no second key: it answers 409 idempotency_key_reused naming the first key in error.details.key_id.

Primitive-Not-Afterstring date-time

An ISO 8601 time, with an Idempotency-Key. A request that reaches the server after it creates nothing itself (409 request_expired), so a caller that lost an answer can wait past it and then revoke whatever the attempt made, knowing no late copy can still create a key. A key an earlier copy made is still reported as 409 idempotency_key_reused.

Request body

namestring
expires_atstring date-time
expires_in_daysinteger
onboardingboolean

Response

Created

successtrue required

Changes

No operation changes recorded.