---
title: "Child API Keys: Per-Customer USD Budgets & Rate Limits | Straitly Docs"
description: "Mint scoped child keys via POST /v1/admin/keys with lifetime total_cap_usd, daily caps, RPM limits, 7-day grace rotation and per-customer request logs."
url: https://straitly.ai/docs/child-keys
updated: 2026-11-26
publisher: Straitly (https://straitly.ai)
---

Docs

Account

# Child keys

Copy docs

**On this page**

Straitly child keys are scoped, revocable API keys minted via `POST /v1/admin/keys` for each of your own customers or apps. They call the gateway directly from a server or browser with per-key lifetime USD budgets, daily caps, RPM limits and request logs while billing into your shared prepaid balance.

Budgets

Lifetime `total_cap_usd` \+ UTC `daily_cap_usd`

Rate limits

Per-key RPM & concurrency

Rotation

Grace window up to 7 days

Billing

Shared parent balance

### Before minting a key

Keep the parent account key on your server. The management calls below require that account key, not the child credential. Start with a small test budget and store the returned key securely.

Minting is enabled per account. If your account key returns `403 admin_scope_required`, write to [hashim@straitly.ai](mailto:hashim@straitly.ai).

Mint

POST https://api.straitly.ai/v1/admin/keys

List

GET https://api.straitly.ai/v1/admin/keys

Read one

GET https://api.straitly.ai/v1/admin/keys/{key\_hash}

Change controls

PATCH https://api.straitly.ai/v1/admin/keys/{key\_hash}

Rotate

POST https://api.straitly.ai/v1/admin/keys/{key\_hash}/rotate

Revoke

DELETE https://api.straitly.ai/v1/admin/keys/{key\_hash}

Request history

GET https://api.straitly.ai/v1/admin/requests

One request

GET https://api.straitly.ai/v1/admin/requests/{request\_id}

Auth

Authorization: Bearer sk-… (your account key, on every call)

The same keys appear in the console under [Customer keys](https://straitly.ai/app/customer-keys), grouped by customer, with spend, rotate and revoke.

### Three ids

- `key_ref` (`lk_…`): the stable id of a customer's key. Survives rotation. Use it as your primary key.
- `key_hash`: the id of the current credential. Changes on rotation. Goes in management URLs.
- `customer_ref`: your own customer id, up to 128 characters. Stored as-is, never interpreted. Filter keys and history by it.

### Mint

Every field is optional. The raw key is returned once and never stored.

curl

Copy Copied Failed

curl https://api.straitly.ai/v1/admin/keys \
  -H "Authorization: Bearer $STRAITLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "label": "acme-prod",
    "customer_ref": "cust_01H9",
    "total_cap_usd": 500,
    "daily_cap_usd": 50,
    "rpm_limit": 600,
    "concurrency_limit": 64,
    "allowed_origins": ["https://app.acme.com"]
  }'

# 201
# {
#   "key": "sk-...",                    <- shown exactly once
#   "key_ref": "lk_3f9a1c22b0d94e17",   <- stable, survives rotation
#   "key_hash": "0a1c6d9b...",          <- current credential
#   "customer_ref": "cust_01H9",
#   "total_cap_usd": 500, "daily_cap_usd": 50,
#   "rpm_limit": 600, "concurrency_limit": 64,
#   "disabled": false
# }

- `total_cap_usd` is a lifetime budget. At the cap the key returns `429 budget_exhausted` until you raise it or mint a new key.
- `rpm_limit` and `concurrency_limit` are the key's own window, never above your plan. One customer going over does not throttle another.
- `allowed_origins` lets pages on those origins call the inference endpoints directly; the gateway answers the preflight. Keys without it are server-only. CORS is not a secret-keeping mechanism: a key shipped to a browser can be extracted, so use bounded child keys rather than a parent account key.
- A child key cannot mint keys.

### List and read

curl

Copy Copied Failed

# newest first, keyset pagination, limit <= 200
curl "https://api.straitly.ai/v1/admin/keys?customer_ref=cust_01H9&include_disabled=true&limit=100" \
  -H "Authorization: Bearer $STRAITLY_API_KEY"
# {"keys": [...], "next_cursor": "..." | null}

curl https://api.straitly.ai/v1/admin/keys/KEY_HASH \
  -H "Authorization: Bearer $STRAITLY_API_KEY"
# key object + "spent_usd", "remaining_usd"

Filters: `customer_ref`, `key_ref`, `include_disabled` (default false).

### Change controls

curl

Copy Copied Failed

curl -X PATCH https://api.straitly.ai/v1/admin/keys/KEY_HASH \
  -H "Authorization: Bearer $STRAITLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"daily_cap_usd": null, "rpm_limit": 120, "label": "acme-prod-eu"}'

Any of `label`, `customer_ref`, `total_cap_usd`, `daily_cap_usd`, `rpm_limit`, `concurrency_limit`, `allowed_origins`. `null` clears a cap or resets a limit to your plan. Live everywhere within 15 seconds. A revoked key cannot be patched (`409 key_revoked`).

### Rotate

curl

Copy Copied Failed

curl -X POST https://api.straitly.ai/v1/admin/keys/KEY_HASH/rotate \
  -H "Authorization: Bearer $STRAITLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"grace_seconds": 3600}'
# 201: new key object with "key" (shown once), same key_ref, "previous_key_hash"

The new credential copies every control and keeps the same `key_ref`, so caps, spend and history continue as one series. The old credential keeps working for `grace_seconds` (0 to 7 days), then returns `401`. Rotating a credential that was already rotated returns `409 already_rotated` with `current_key_hash`.

### Revoke

curl

Copy Copied Failed

curl -X DELETE https://api.straitly.ai/v1/admin/keys/KEY_HASH \
  -H "Authorization: Bearer $STRAITLY_API_KEY"
# {"key_hash": "...", "key_ref": "lk_...", "revoked": true}

Immediate and permanent. History stays queryable by `key_ref` and `customer_ref`.

### Request history

Every response carries `x-straitly-request-id`. Send `x-partner-request-ref: <your id>` on a request and it is stored beside it.

curl

Copy Copied Failed

curl "https://api.straitly.ai/v1/admin/requests?customer_ref=cust_01H9&since=1789800000&limit=200" \
  -H "Authorization: Bearer $STRAITLY_API_KEY"
# {"requests": [...], "next_cursor": "..." | null}

curl https://api.straitly.ai/v1/admin/requests/REQUEST_ID \
  -H "Authorization: Bearer $STRAITLY_API_KEY"
# or by your own reference:
curl "https://api.straitly.ai/v1/admin/requests/YOUR_REF?by=partner_ref" \
  -H "Authorization: Bearer $STRAITLY_API_KEY"

Filters: `key_ref`, `key_hash`, `customer_ref`, `partner_ref`, `status` (`pending` | `completed` | `failed`), `since` / `until` (unix seconds or ms). Newest first.

Each row: `request_id`, `partner_ref`, `key_ref`, `customer_ref`, `model`, `status`, `final`, `stream`, `started_at`, `ended_at`, `duration_ms`, `time_to_first_token_ms`, `finish_reason`, `error`, `usage` (input, cache read, cache write, output, total tokens), `charge_usd`.

A row is written as `pending` when the request is accepted and updated once to `final` about two seconds after it ends. A client disconnect mid-stream is `failed` with `error.code = client_disconnect`; the usage on that row is what was generated, and what you are charged. Rows already `final` never change. Retention is 400 days.

### Errors

| Status | Code                                                                                                                                                 | Meaning                                                                                                                                        |
| ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| 400    | invalid\_customer\_ref, invalid\_total\_cap, invalid\_rpm\_limit, invalid\_concurrency\_limit, invalid\_origins, invalid\_grace, nothing\_to\_change | Fix the body.                                                                                                                                  |
| 403    | admin\_scope\_required                                                                                                                               | This key cannot mint.                                                                                                                          |
| 404    | key\_not\_found, request\_not\_found                                                                                                                 | Not yours, or never existed.                                                                                                                   |
| 409    | key\_revoked, already\_rotated                                                                                                                       | Read the message; already\_rotated includes current\_key\_hash.                                                                                |
| 429    | child\_key\_limit, budget\_exhausted, rate\_limit\_exceeded, concurrency\_limit\_exceeded                                                            | Rate and concurrency limits may be retried after Retry-After. Key-count and lifetime-budget limits require a control change, not a retry loop. |

### Verify before handing out access

1. Mint a test key with an explicit lifetime budget and customer reference.
2. Use the child key for one inference request; use the parent key to inspect its history.
3. Confirm usage is attributed to the expected customer and budget.
4. Test rotation and revocation in a non-production integration before relying on them.

Related guides: [API keys & authentication](https://straitly.ai/docs/authentication), [Errors & limits](https://straitly.ai/docs/errors), [Teams & roles](https://straitly.ai/docs/teams), [Production checklist](https://straitly.ai/docs/production) and [partner setup support](https://straitly.ai/docs/support).

### Common questions

**What is a Straitly child key?**

A child key is a scoped, revocable API key you mint for one of your own customers or apps. It calls the Straitly gateway directly with its own lifetime budget, daily spend cap, rate limit and request history while billing into your prepaid account balance.

**How do I set a hard spend cap on a child key?**

Pass total\_cap\_usd for a lifetime budget or daily\_cap\_usd for a UTC daily cap when calling POST /v1/admin/keys, or update either field later with PATCH /v1/admin/keys/{key\_hash}. At total\_cap\_usd the key returns 429 budget\_exhausted until you raise the cap.

**Can a child key be rotated without downtime?**

Yes. Call POST /v1/admin/keys/{key\_hash}/rotate with grace\_seconds from 0 seconds up to 7 days. The new credential keeps the same key\_ref, controls and history while the old key keeps working during the grace window.

**When should I use child keys instead of team members?**

Use child keys when you are passing inference through to your own end customers or multi-tenant apps and need per-customer budgets and rate limits. Use team accounts and roles for internal engineers who need console logins and shared company billing.

**Why does POST /v1/admin/keys return 403 admin\_scope\_required?**

Child-key minting is enabled per account and requires your parent account key, never a child key. If your parent account key returns 403 admin\_scope\_required, email hashim@straitly.ai to enable partner minting.

[Account & sign-in](https://straitly.ai/docs/account) [Teams & roles](https://straitly.ai/docs/teams)

---
Markdown version of https://straitly.ai/docs/child-keys.
