ApiKeys

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
/v1/api-keys

Creates a new API key for the organization and returns the created key, including the plaintext secret, with a 201 response.

Authorization

apiKey
headerx-api-key<token>

Request Body

application/json
  1. body
name*string
Length1 <= length <= 32
description?string|null
expiresAt?string|null
access?||

Defaults to full access. A restricted API key creating a key defaults to its own grants and cannot issue full access.

Response Body

Success

application/json
  1. response
id*string
name*string
key*string
start*string|null
end*string|null
description?string|null
createdAt*string
expiresAt*string|null
lastUsedAt*string|null
isActive*boolean
access*|
owner*|null
Example Request
import { 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"  }}

Related documentation