Create API key

POSThttps://app.speybooks.com/api/v1/api-keys/

Generate a new API key. The full plaintext key is returned exactly once in the response — it cannot be retrieved again. Store it securely immediately.

The key is hashed with Argon2id before storage. Default scopes grant full access (["*"]). Invalid scopes are rejected with a validation error listing the bad values.

Body parameters

environmentstringoptional
Key environment. Live keys use sk_live_ prefix, test keys use sk_test_.
livetest
namestringoptional
Human-readable name for the key (e.g. Production Backend).
max length: 100
scopesarray<string>optional
Permission scopes. Use ["*"] for full access, or specific scopes like ["invoices:read", "contacts"].
min items: 1 · max items: 20

Response

201API key created. The full key is returned ONCE in this response and cannot be retrieved again.
Show response fields
createdAtstringdate-time
environmentstring
idinteger
keystring
keyPreviewstring
namestring
scopesarray<string>
scopesSummarystring
warningstring

Error codes

400Validation error: invalid scope(s) or missing required fields.