Skip to Content

Rotate an API key

Issues a replacement with the same owner, name, and access, then deactivates the existing key. Returns the new key, including the plaintext secret.

POST
/v1/api-keys/{id}/rotate

Issues a replacement with the same owner, name, and access, then deactivates the existing key. Returns the new key, including the plaintext secret.

Authorization

apiKey
headerx-api-key<token>

Path Parameters

id*string
Match^key_[0-9a-hjkmnp-tv-z]{16,24}$

Response Body

ApiKeyWithSecret

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.rotate({
  "id": "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