Skip to main content

Endpoint

POST /api/v1/keys
Host: api.driftguard.dev

Request

curl -s -X POST https://api.driftguard.dev/api/v1/keys \
  -H "X-API-Key: $DRIFTGUARD_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "environment": "live" }'

Request Body

FieldTypeRequiredDescription
environmentstringlive for production use, test for development and CI

Response

{
  "id": "your_key_id_here",
  "key": "dg_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "key_preview": "dg_live_xxxxxxxx",
  "environment": "live",
  "is_active": true,
  "created_at": "2026-03-01T12:00:00Z"
}

Response Fields

FieldTypeDescription
idstringUnique identifier for this key — save it for revoke, activate, and delete operations
keystringThe full API key — shown once only, copy it immediately
key_previewstringFirst 16 characters of the key — this is all that will be visible after creation
environmentstringlive or test
is_activebooleanAlways true for a newly created key
created_atstringISO 8601 timestamp of when the key was created
The key field is shown only once at creation time. It is stored as a SHA-256 hash on our servers and cannot be recovered. Copy it to a secrets manager or environment variable immediately before closing this response.

Rate Limits

In addition to the standard 100 req/min rate limit, key creation is limited to 10 new keys per hour per user. Exceeding this returns 429.

Error Responses

StatusMeaning
400Invalid or missing environment value
401Missing or invalid X-API-Key
429Rate limit exceeded — either 100 req/min or 10 key creations/hour

List Keys

View all keys on your account (previews only).

Revoke Key

Deactivate a key when it’s no longer needed.