API Keys

Manage API keys for your organization. Keys are used for Bearer token authentication.

Create API Key

POST /v1/api_keys

Request Body:

FieldTypeRequiredDescription
namestringyesDisplay name for the key
scopesstring[]noPermissions (default: all scopes)

Response: 200 OK — Returns the key object including the secret (shown only once).

List API Keys

GET /v1/api_keys

Returns all API keys for the organization. Secrets are masked.

Rotate API Key

POST /v1/api_keys/{key_id}/rotate

Generates a new secret for the key. The old secret remains valid for 24 hours (overlap window).

Revoke API Key

POST /v1/api_keys/{key_id}/revoke

Immediately revokes the key. This action cannot be undone.

Response: 204 No Content

Available Scopes

When creating an API key, you can restrict its permissions using scopes. If no scopes are specified, the key receives all scopes by default.

ScopeDescription
jobs:writeCreate and cancel jobs
jobs:readList and get job details, files, submissions
webhooks:writeCreate, update, delete webhook endpoints
webhooks:readList webhook endpoints and events
keys:manageCreate, rotate, revoke API keys
audit:readRead audit log events
usage:readRead billing and usage data
billing:writePurchase credits, manage billing

Example: Create a read-only key

curl -X POST https://api.firsthandapi.com/v1/api_keys \
  -H "Authorization: Bearer fh_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Read-only dashboard key",
    "scopes": ["jobs:read", "usage:read"]
  }'