Create an API key
Creates a new API key for the organization and returns the created key, including the plaintext secret, with a 201 response.
POST
Creates a new API key for the organization and returns the created key, including the plaintext secret, with a 201 response. A restricted member can issue keys only in their namespace, capped by its available resources.
apiKeyheader
x-api-key<token>application/json- body
name*stringLength
1 <= length <= 32description?string|nullexpiresAt?string|nullaccess?||Defaults to full access for an unrestricted member, or namespace grants for a restricted member. A restricted API key creating a key defaults to its own grants and cannot issue full access.
Success
application/json- response
id*stringname*stringkey*stringstart*string|nullend*string|nulldescription?string|nullcreatedAt*stringexpiresAt*string|nulllastUsedAt*string|nullisActive*booleanaccess*|owner*|nullimport { createClient } from "samva";
const samva = createClient({ apiKey: process.env.SAMVA_API_KEY! });
const result = await samva.apiKeys.create({
"name": "example"
});Example Response
{
"id": "string",
"name": "string",
"key": "string",
"start": "string",
"end": "string",
"description": "string",
"createdAt": "string",
"expiresAt": "string",
"lastUsedAt": "string",
"isActive": true,
"access": {
"mode": "full"
},
"owner": {
"id": "string",
"name": "string",
"email": "string"
}
}