/v1/apps/{app_id}/api-keysAuthMint a new hdk_live_* API key with an explicit permission scope. The raw key is returned ONCE.
Path parameters
app_id*stringId of the app.
Headers
Idempotency-KeystringStripe-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*stringHuman-readable label for this key (shown in the API keys list).
Example: "CI deploy bot"
permissions*arrayPermission 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*stringAPI key row UUID.
name*stringDisplay name.
Example: "CI deploy bot"
key*stringRaw API key. Returned exactly once — store it now.
Example: "hdk_live_aZxYbpKL..."
key_prefix*stringFirst 16 chars of the key — safe to display in lists.
Example: "hdk_live_aZxYbpKL"
permissions*arrayPermission scope.
Example: ["user.read","user.list"]
expires_at*string · date-timeWhen this key stops authenticating. `null` means it never expires.
created_at*string · date-timeWhen 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
}import { Auth } from "@productcraft/auth";
// Admin routes read PRODUCTCRAFT_API_KEY; consumer routes need no key
const auth = new Auth();
const createApiKey = await auth.admin.app("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f").apiKeys.create({ name: "CI deploy bot", permissions: ["user.read", "user.list"] });auth.admin.app(…).apiKeys.create(params, options?): Auth.CreateApiKey
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"
}