Skip to main content

Documentation Index

Fetch the complete documentation index at: https://spendguard.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Endpoint

POST /v1/keys
Authentication: Requires X-Admin-Key header (not a regular API key). The admin key must match the ADMIN_API_KEY environment variable on the server.

Request Headers

HeaderRequiredDescription
X-Admin-KeyYesThe master admin key
Content-TypeYesMust be application/json

Request Body

FieldTypeRequiredDefaultDescription
namestringYesHuman-readable name for this key (1-255 characters)
rate_limit_rpmintegerNo100Requests per minute limit (1-10,000)

Example Request

curl -X POST https://spendguardapi.com/v1/keys \
  -H "Content-Type: application/json" \
  -H "X-Admin-Key: your-admin-key" \
  -d '{
    "name": "Production Agent Key"
  }'

Response — 201 Created

{
  "key_id": "key_a1b2c3d4e5f6",
  "name": "Production Agent Key",
  "api_key": "sg_live_4a8f2c1b9e7d3056ef28a1c4b7e93f1d4a8f2c1b9e7d3056ef28a1c4b7e93f1d",
  "rate_limit_rpm": 100,
  "created_at": "2026-04-03T12:00:00Z"
}
The api_key field contains the raw API key. This is shown exactly once. SpendGuard stores only a SHA-256 hash of the key — the original cannot be retrieved. Copy it immediately and store it securely.

Error Responses

StatusCodeWhen
401unauthorizedMissing, invalid, or wrong admin key
422validation_errorMissing name or invalid rate_limit_rpm
500internal_errorServer error