Auth API reference

Auth API · Api-Keys

post/v1/apps/{app_id}/api-keysAuth

Mint a new hdk_live_* API key with an explicit permission scope. The raw key is returned ONCE.

Path parameters

app_id*string

Id of the app.

Headers

Idempotency-Keystring

Stripe-style idempotency key. The plaintext API key is returned exactly once; an IaC retry without this header creates a second key the customer never sees the plaintext for. 24h TTL.

Request body

name*string

Human-readable label for this key (shown in the API keys list).

Example: "CI deploy bot"

permissions*array

Permission scope for the key. Each entry must match `resource.action` (lowercase + underscores).

Example: ["user.read","user.list"]

expires_in_daysenum (3)

Lifetime of the key in days. Omit or send `null` for a key that never expires — the historical behaviour and still the default.

Example: 90

Response · 201 New API key with raw secret.

id*string

API key row UUID.

name*string

Display name.

Example: "CI deploy bot"

key*string

Raw API key. Returned exactly once — store it now.

Example: "hdk_live_aZxYbpKL..."

key_prefix*string

First 16 chars of the key — safe to display in lists.

Example: "hdk_live_aZxYbpKL"

permissions*array

Permission scope.

Example: ["user.read","user.list"]

expires_at*string · date-time

When this key stops authenticating. `null` means it never expires.

created_at*string · date-time

When the API key was created (ISO 8601).

Example

Request

POST https://api.auth.productcraft.co/v1/apps/{app_id}/api-keys
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json

{
  "name": "CI deploy bot",
  "permissions": [
    "user.read",
    "user.list"
  ],
  "expires_in_days": 90
}

Response

{
  "id": "string",
  "name": "CI deploy bot",
  "key": "hdk_live_aZxYbpKL...",
  "key_prefix": "hdk_live_aZxYbpKL",
  "permissions": [
    "user.read",
    "user.list"
  ],
  "expires_at": "2026-01-01T00:00:00.000Z",
  "created_at": "2026-01-01T00:00:00.000Z"
}