Create an API key
POST/v1/api-keysPortal sign-in
Returns the full key once, in key. Store it: it can’t be shown again. Your plan sets how many active keys your account can have (entitlements.limits.api_keys on GET /v1/account; one before a plan is granted): at the limit, 409 conflict. To rotate, create a new key, switch to it, then revoke the old one.
Authorization
Portal sign-in Authorization: Bearer $MA_ACCESS_TOKEN
Sign in to the portal and send its access token. Portal sign-in isn't available yet, so you can read this endpoint but not call it.
Request body
Required, application/json.
namestringrequiredA name to tell the key apart. Spaces around it are trimmed; then it must be 1 to 100 characters, with no control characters.
- Range
- 1 to 100 characters
- Example
Production
{ "name": "Production"}Responses
The new key, with the full key in key.
application/json · ApiKeyCreated
idstring (uuid)requiredThe key’s ID, to get or revoke it.
- Example
6f1c2a9e-4b7d-4e3a-9c51-2d8f0b7e3a14
namestringrequiredThe name you gave it.
- Example
Production
prefixstringrequiredThe key’s public part, to tell keys apart: the 8 characters after
ma_live_(orma_test_for a test key).- Example
p4ppuj7y
created_atstring (date-time)requiredWhen the key was created.
- Example
2026-11-26T15:10:00Z
last_used_atstring (date-time)requirednullableUpdated at most once a minute.
- Example
2026-11-28T09:41:00Z
revoked_atstring (date-time)requirednullableWhen the key was revoked. Null while it works.
- Example
null
keystringrequiredThe full key, shown once:
ma_live_(ma_test_for a test key), the 8-characterprefix,_, then a 52-character secret. Send it asAuthorization: Bearer <key>. The example is shortened.- Example
ma_test_p4ppuj7y_ji3ebqcb6iwsvw…
{ "id": "6f1c2a9e-4b7d-4e3a-9c51-2d8f0b7e3a14", "name": "Production", "prefix": "p4ppuj7y", "created_at": "2026-11-26T15:10:00Z", "last_used_at": null, "revoked_at": null, "key": "ma_test_p4ppuj7y_ji3ebqcb6iwsvw…"}400 Bad Request, code: invalid_parameter. A parameter or the request body is invalid.
application/problem+json · Problem
typestringrequiredAlways about:blank for now. Use
code.titlestringrequiredThe HTTP status’s standard name.
statusintegerrequiredThe HTTP status code, the same as the response’s.
detailstringWhat went wrong with this request, in plain language: which parameter, which slug. Absent when there’s nothing to add (an internal error).
codestringrequiredThe error, for your code to act on. Branch on this, not on
titleordetail.- Allowed
not_found,invalid_parameter,unauthorized,forbidden,conflict,rate_limited,not_implemented,internal
401 Unauthorized. No valid portal access token. API Gateway checks it before the API runs, so this body is API Gateway’s, not a Problem.
409 Conflict, code: conflict. It conflicts with what’s there (see the description).
application/problem+json · Problem
typestringrequiredAlways about:blank for now. Use
code.titlestringrequiredThe HTTP status’s standard name.
statusintegerrequiredThe HTTP status code, the same as the response’s.
detailstringWhat went wrong with this request, in plain language: which parameter, which slug. Absent when there’s nothing to add (an internal error).
codestringrequiredThe error, for your code to act on. Branch on this, not on
titleordetail.- Allowed
not_found,invalid_parameter,unauthorized,forbidden,conflict,rate_limited,not_implemented,internal
Over a rate limit: your account’s per-minute limit from its plan (entitlements.requests_per_minute on GET /v1/account), shared by its keys, or the API-wide throttle every caller shares. Wait Retry-After seconds, then retry with backoff.
application/problem+json · Problem
typestringrequiredAlways about:blank for now. Use
code.- Example
about:blank
titlestringrequiredThe HTTP status’s standard name.
- Example
Not Found
statusintegerrequiredThe HTTP status code, the same as the response’s.
- Example
404
detailstringWhat went wrong with this request, in plain language: which parameter, which slug. Absent when there’s nothing to add (an internal error).
- Example
No version claude-sonnet-9.
codestringrequiredThe error, for your code to act on. Branch on this, not on
titleordetail.- Allowed
not_found,invalid_parameter,unauthorized,forbidden,conflict,rate_limited,not_implemented,internal- Example
not_found
{ "type": "about:blank", "title": "Too Many Requests", "status": 429, "detail": "Your plan allows 60 requests a minute, across your account's keys. Retry after 12 s.", "code": "rate_limited"}{ "type": "about:blank", "title": "Too Many Requests", "status": 429, "detail": "The API is busy. Retry after 1 s, with backoff.", "code": "rate_limited"}