Skip to main content

API keys

Create and manage API keys for authenticating with the Agentbot API. All endpoints require session authentication.

List keys

GET /api/keys

Response

{
  "keys": [
    {
      "id": "key_123",
      "name": "Production Key",
      "keyPreview": "sk_abc1234...",
      "createdAt": "2026-03-01T00:00:00Z",
      "lastUsed": "2026-03-19T00:00:00Z"
    }
  ]
}

Create key

POST /api/keys

Request body

FieldTypeRequiredDescription
namestringYesKey name (max 64 characters)

Response (201 Created)

{
  "id": "key_456",
  "name": "Production Key",
  "key": "sk_a1b2c3d4e5f6...",
  "createdAt": "2026-03-19T00:00:00Z"
}
The raw API key is only returned once at creation time. Store it securely — it cannot be retrieved again. The key is stored as a bcrypt hash in the database.

Errors

CodeDescription
400Name required or name too long (max 64 characters)
401Unauthorized
500Failed to create key

Get key

GET /api/keys/:id
Requires ownership of the key.

Response

{
  "id": "key_123",
  "name": "Production Key",
  "keyPreview": "sk_abc1234...",
  "createdAt": "2026-03-01T00:00:00Z",
  "lastUsed": "2026-03-19T00:00:00Z"
}

Errors

CodeDescription
401Unauthorized
404Key not found

Delete key

DELETE /api/keys/:id
Requires ownership of the key.

Response

{
  "success": true
}

Errors

CodeDescription
401Unauthorized
404Key not found