Make an API key
const url = 'https://api.metaphoric.io/v1/keys';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"name":"example","scopes":["memories:read"],"user_id":null,"expires_at":null}'};
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.metaphoric.io/v1/keys \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "name": "example", "scopes": [ "memories:read" ], "user_id": null, "expires_at": null }'Needs keys:manage. The new key does no more than the key that asks: no scope that key lacks, no other user, and no later expiry. A tenant holds a limited number of working keys, and fewer for any one user.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
Your label for the key: 1 to 64 letters, numbers, punctuation marks or symbols of any script, with single spaces between, in Unicode NFC. A character that draws nothing, such as a zero-width space or a Hangul filler, is refused.
The one end user the key may act for: your own ID, 1 to 256 visible ASCII characters but " and \, not starting with metaphor:. Null for a key of your own server.
Example
2027-01-31T09:30:00ZResponses
Section titled “Responses”The key was made.
object
The one user the key may act for. Null for a key of the tenant’s own server, and for a key whose user was erased.
Whether the key was made for one user. A key whose user was erased is revoked and keeps true here, with user_id null and its name replaced, so nothing of the user’s ID is left in it.
Null for a key that never expires.
Null for a key that is not revoked.
When the key last passed its check, to within an hour, even if the route’s scopes then refused the request. Null for a key never used.
The ID of the key that made this one. Null for a key Metaphor made for the tenant. Revoking a key does not revoke the keys it made.
The key itself. It is shown once.
Example
{ "id": "9f2c4e6a8b0d1f35", "scopes": [ "memories:read" ], "created_at": "2027-01-31T09:30:00Z", "expires_at": "2027-01-31T09:30:00Z", "revoked_at": "2027-01-31T09:30:00Z", "last_used_at": "2027-01-31T09:30:00Z", "made_by": "9f2c4e6a8b0d1f35"}The request is not valid.
object
object
One of ErrorCode, or a code added since. Treat a code you do not know by its status.
Example generated
{ "error": { "code": "example", "message": "example" }}No valid API key was sent.
object
object
One of ErrorCode, or a code added since. Treat a code you do not know by its status.
Example generated
{ "error": { "code": "example", "message": "example" }}The API key does not allow this.
object
object
One of ErrorCode, or a code added since. Treat a code you do not know by its status.
Example generated
{ "error": { "code": "example", "message": "example" }}The tenant or the user holds as many working keys as it may. Revoke one first.
object
object
One of ErrorCode, or a code added since. Treat a code you do not know by its status.
Example generated
{ "error": { "code": "example", "message": "example" }}The request body is too large.
object
object
One of ErrorCode, or a code added since. Treat a code you do not know by its status.
Example generated
{ "error": { "code": "example", "message": "example" }}The body was not sent as application/json.
object
object
One of ErrorCode, or a code added since. Treat a code you do not know by its status.
Example generated
{ "error": { "code": "example", "message": "example" }}The API key sent more than 600 requests in a minute, the user’s keys together more than 2000, the tenant’s keys together more than 6000, or the tenant’s keys made as many keys as they may in 24 hours. Wait the seconds Retry-After gives.
object
object
One of ErrorCode, or a code added since. Treat a code you do not know by its status.
Example generated
{ "error": { "code": "example", "message": "example" }}Something went wrong. Try again.
object
object
One of ErrorCode, or a code added since. Treat a code you do not know by its status.
Example generated
{ "error": { "code": "example", "message": "example" }}The request could not be checked. Try again.
object
object
One of ErrorCode, or a code added since. Treat a code you do not know by its status.
Example generated
{ "error": { "code": "example", "message": "example" }}