Mint a workspace key
const url = 'https://api.keptslot.com/v1/account/workspaces/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/keys';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"type":"sk","name":"Production server"}'};
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.keptslot.com/v1/account/workspaces/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/keys \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "type": "sk", "name": "Production server" }'This endpoint makes a new API key for a workspace the account owns. A workspace on another account gives a 404, and nothing is created.
CAUTION: key carries the full value, and this is the only response
that shows it for a secret key. Store it now. A later read gives null.
Authorizations
Section titled “ Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “ Path Parameters ”The workspace id.
Request Body required
Section titled “ Request Body required ”object
sk for a secret key, used from a server. pk for a
publishable key, used from a browser.
A label for the key. 100 characters at most.
Example
{ "type": "sk", "name": "Production server"}Responses
Section titled “ Responses ”The key is created.
object
Null for a key made before names existed. “No name” and “made before names” are the same answer here.
The full key value. A create response carries it for both key types, because that is the only moment the value exists.
A read gives it for a publishable key only, and gives null for a secret key. It is also null for an old publishable key whose value was never stored.
The first characters, to tell keys apart in a list.
The browser origins a publishable key works from. An empty list rejects every browser Origin.
Example
{ "type": "sk"}The key is missing, malformed or revoked.
object
object
A stable machine-readable code. Match on this.
A sentence for a person. Do not match on this.
The field that caused the refusal, if one field did.
The plan limit that refused the request. It is present only on a 402, and only for a secret key or an account key. See the errors guide.
The current count for that dimension. It is present only on a 402, and only for an account key. It is absent when the refusal has no count to report. Absent and zero are different answers.
The cap for that dimension. It is present only on a 402, and only for an account key. A cap of zero is a real value.
Example generated
{ "error": { "type": "example", "message": "example", "param": "example", "dimension": "example", "used": 1, "limit": 1 }}There is no such resource in this workspace.
object
object
A stable machine-readable code. Match on this.
A sentence for a person. Do not match on this.
The field that caused the refusal, if one field did.
The plan limit that refused the request. It is present only on a 402, and only for a secret key or an account key. See the errors guide.
The current count for that dimension. It is present only on a 402, and only for an account key. It is absent when the refusal has no count to report. Absent and zero are different answers.
The cap for that dimension. It is present only on a 402, and only for an account key. A cap of zero is a real value.
Example generated
{ "error": { "type": "example", "message": "example", "param": "example", "dimension": "example", "used": 1, "limit": 1 }}The request body or the query is not valid.
object
object
A stable machine-readable code. Match on this.
A sentence for a person. Do not match on this.
The field that caused the refusal, if one field did.
The plan limit that refused the request. It is present only on a 402, and only for a secret key or an account key. See the errors guide.
The current count for that dimension. It is present only on a 402, and only for an account key. It is absent when the refusal has no count to report. Absent and zero are different answers.
The cap for that dimension. It is present only on a 402, and only for an account key. A cap of zero is a real value.
Example generated
{ "error": { "type": "example", "message": "example", "param": "example", "dimension": "example", "used": 1, "limit": 1 }}