Skip to content
Dashboard
Theme
Theme

Create an organization-scoped secret key (shown once)

POST /v1/organizations/{org}/api_keys: Create an organization-scoped secret key (shown once).

View Markdown

POST /v1/organizations/{org}/api_keys

The new key is limited to this organization. Its scopes must be a subset of the calling key’s scopes (a key without * cannot grant *).

Scope
api_keys:write
Auth
Secret key (sk_…)
Since
1.0
  • org string Required

  • OhAuthCat-Version string

    Minor version; defaults to the environment’s pin.

  • Idempotency-Key string

    Honoured for 24 h; a replay returns the original response.

    min length 1 · max length 255

  • name string Required

    min length 1 · max length 200

  • scopes array of string Required

    min items 1

  • ip_allow_list array of string

    CIDR blocks the key may be used from (Business plan and above).

  • expires_at string (date-time)

    RFC 3339, UTC.

Errors share one shape; see the error code catalogue.

curl -X POST \
"https://api.ohauthcat.com/v1/organizations/org_01J9Z3K5V7W8X9Y0Z1A2B3C4D5/api_keys" \
-H "Authorization: Bearer $OHAUTHCAT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Corp",
"scopes": [
"organizations:read"
]
}'
Response 201
{
"api_key": {
"id": "key_01J9Z3K5V7W8X9Y0Z1A2B3C4D5",
"object": "api_key",
"name": "Acme Corp",
"type": "secret",
"prefix": "sk_test",
"publishable_key": "pk_01J9ZQ4M7K2X8V3N5B6C1D0E9F",
"revoked_at": "2026-01-15T09:30:00Z",
"environment": "env_01J9Z3K5V7W8X9Y0Z1A2B3C4D5",
"scopes": [
"organizations:read"
],
"ip_allow_list": [
"example_ip_allow_list"
],
"expires_at": "2026-01-15T09:30:00Z",
"last_used_at": "2026-01-15T09:30:00Z",
"created_at": "2026-01-15T09:30:00Z",
"organization": "org_01J9Z3K5V7W8X9Y0Z1A2B3C4D5"
},
"secret": "sk_test_example",
"previous_key_expires_at": "2026-01-15T09:30:00Z"
}