{"article":{"title":"Provisioning keys","breadcrumb":["Getting started","Provisioning keys"],"body":"**What this solves**: Explains how the provisioning key issues and manages downstream child keys, plus the child key limit, expiry, and idempotent-creation gotchas.\n\nWhen your end users have accounts and quota with you, a single shared key doesn't cut it. You need to issue a separate key to each user, limit each one separately, and disable them at any time. The provisioning key (also known as the master key) does exactly this: it only manages keys, and doesn't call models.\n\nIf you or a single service calls models directly, use an Inference key. See [Before you start](before-key). A provisioning key plus child keys is for a SaaS product or a middle platform that issues keys, sets limits, and hands them out.\n\nThe most common use case is this: your platform backend stores one provisioning key. When a new user registers, buys quota, or creates a project, the backend calls `/v1/keys` to create a Child key, then hands it to that user or to the project's server to use.\n\n![Provisioning key issuing child keys · end-to-end chain](diagram:en-provisioning-chain)\n\n> [!NOTE]\n> The response embeds the key in two layers, `{key, data:{…}}`: the top level is the credential itself, and `data` holds its attributes.\n> Clients that already integrate against this shape only need to change `base_url` and manage the credential.\n\n### Getting a provisioning key\n\nIssue one yourself on the console's **API Keys** page: when creating, set the type to **Provisioning (master key)**. **The plaintext appears only once, at creation**; after that only a fingerprint is kept in the database. It can also be issued by the platform on your behalf.\n\n> [!WARNING]\n> The provisioning key **can only manage keys**: it cannot send model requests, cannot read billing, and cannot change channels or routing. A credential that can both create child keys with unlimited limits and spend money has no loss ceiling if it leaks.\n\n### Creating child keys\n\n```bash\ncurl https://tare.jamerly.ai/v1/keys \\\n  -H \"Authorization: Bearer $TARE_PROVISIONING_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"name\": \"user-8f3a2b91\",\n    \"limit\": 12.50,\n    \"external_id\": \"usr_8f3a2b91\",\n    \"include_byok_in_limit\": false\n  }'\n```\n\nThe returned `key` is the full credential, **shown only once**; `data.hash` is the stable identifier for locating this key later.\n\n| Field | Meaning |\n|---|---|\n| `name` | Purpose note, filled in by the caller; the platform doesn't model end users |\n| `limit` | Spend cap (USD), not a balance; omitted = no limit. With `limit_reset` set, it is the cap per period |\n| `limit_reset` | Automatic reset period: `daily` / `weekly` / `monthly`; omitted = never reset automatically |\n| `external_id` | Your business ID, used for **idempotent creation** (see below) |\n| `include_byok_in_limit` | Whether BYOK spend counts toward this key's limit. Counted by default |\n\n`external_id` should always be included: after a create request times out, you can safely retry with the same ID, and Tare returns the existing key instead of opening another one.\n\n### Response fields\n\nCreate, query, and limit-change responses return `data` in the same shape:\n\n| Field | Type | Description |\n|---|---|---|\n| `hash` | string | **Stable identifier**; every operation on this key uses it |\n| `name` | string | Purpose note |\n| `label` | string | Prefix + ellipsis, for display |\n| `limit` | number or null | Cap; **null = no limit**, not 0 |\n| `limit_remaining` | number or null | What's left to spend = `limit - limit_usage`; also null when `limit` is null |\n| `limit_reset` | string or null | Automatic reset period; null = never |\n| `limit_usage` | number | Spend since the last reset, which the limit is checked against; equals `usage` if never reset |\n| `limit_reset_at` | string or null | When the limit was last reset (UTC); null if never |\n| `usage` | number | Cumulative spend so far; resets don't change it |\n| `usage_daily` | number or null | Spend today, by the billing timezone; resets don't change it. See \"Usage by day\" below |\n| `usage_weekly` | number or null | Spend since Monday |\n| `usage_monthly` | number or null | Spend since the 1st of the month |\n| `disabled` | boolean | Whether it's disabled |\n| `include_byok_in_limit` | boolean | Whether BYOK spend counts toward the limit |\n| `external_id` | string | External ID; **this field is absent when unset** |\n| `byok_usage` | number | Currently always 0, reserved field |\n| `created_at` / `updated_at` | string | ISO 8601 |\n| `expires_at` | string or null | Expiry time |\n\n### Listing and pagination\n\n`GET /v1/keys?limit=&after=`, cursor pagination, **includes disabled keys** (you need to iterate all of them when rotating management credentials for a full migration).\n\n> [!NOTE]\n> The console's **API Keys** page also shows these child keys: pick the \"Child keys\" tab, which supports search by name, purpose, and **external ID `external_id`**. To locate a single end user's child key, this is more direct than iterating the list endpoint.\n>\n> If your account has more than one provisioning key, the Child keys tab can filter by \"which provisioning key issued it\" — for example when you set up a separate provisioning key per environment or product line, use it to tell the batches of child keys apart.\n\n> [!WARNING]\n> **Child keys don't show up in the \"Inference\" tab**, even though the underlying key type is \"inference\" just like an ordinary key. That tab only lists keys you created directly. To find child keys, go to \"Child keys\"; otherwise it will look like the key doesn't exist at all.\n\n```json\n{\"data\": [ /* same structure as above */ ], \"next_cursor\": 8123}\n```\n\n| | |\n|---|---|\n| Location of `next_cursor` | **Top level**, alongside `data` |\n| Type | number (platform auto-increment ID) or `null`; `null` = no next page |\n| Usage | Pass it back to `after` as-is |\n| `limit` default / max | 100 / **200**; exceeding it is clamped to 200, not an error |\n\n> [!WARNING]\n> The cursor is an id, not an offset. If new keys are created while you're paginating, an offset will skip or duplicate a key.\n\n### Response when plaintext is unavailable\n\nWhen you repeat a create beyond the 5-minute window, `key` is `null` and two extra fields appear at the same level:\n\n```json\n{\"key\": null,\n \"key_unavailable_reason\": \"plaintext_window_expired\",\n \"key_unavailable_message\": \"The plaintext is only returned within 5 minutes ...\",\n \"data\": { }}\n```\n\n- `key_unavailable_reason` is a **programmable enum value**, currently only `plaintext_window_expired`; you'll be notified in advance before new enum values are added. **Branch on this field**.\n- `key_unavailable_message` is a human-facing message, **its wording changes, don't use it for programmatic decisions**.\n\n### Expiry (`expires_at`)\n\nYou can pass it at creation and change it later (`PATCH` with `expires_at`; an explicit `null` cancels the expiry).\n\n> [!WARNING]\n> **An expired key calling a model returns 401**, identical to a revoked one. Distinguishing the two would amount to confirming to someone holding an invalid credential that \"this key once existed\".\n>\n> **Expiry does not set `disabled` to `true`**; that field only means \"disabled\". To check expiry, read `expires_at`.\n\n### Provisioning key rotation\n\nProvisioning keys are independent of each other; an account can **hold several at once** and disable them separately, so rotation is zero-downtime:\n\n1. The platform issues a new provisioning key (plaintext appears only once);\n2. Switch the configuration to the new provisioning key, and new traffic goes through it;\n3. Confirm the new provisioning key works with any `GET /v1/keys`. **`/whoami` won't work**: that endpoint belongs to the reconciliation key, and the provisioning key gets a 403 whether it's valid or not;\n4. Tell the platform to disable the old provisioning key.\n\n> [!WARNING]\n> **Don't disable the old one before switching the configuration.** The provisioning key is the only way to create child keys; during the disable window **all new user registrations will fail**, with no way to compensate.\n\n> [!NOTE]\n> Rotating the provisioning key **doesn't affect already-issued child keys**; child keys are independent credentials and don't become invalid when the provisioning key does.\n\n![Provisioning key rotation · zero-downtime sequence](diagram:en-provisioning-rotation)\n\n### Idempotent creation\n\nAfter a create request times out you can't tell whether it was created: retrying creates one too many, not retrying leaves one missing. Including `external_id` avoids this: repeating a create with the same ID **returns the existing key**, with an HTTP status code of `200` instead of `201`.\n\n![Creating child keys · idempotency](diagram:en-provisioning-idempotent)\n\n> [!WARNING]\n> **The full key can only be retrieved again within 5 minutes of creation.**\n>\n> Beyond that window, a repeated create still returns the key's `data`, but `key` is `null`, with a `key_unavailable_reason` attached.\n>\n> Without this limit, anyone holding the provisioning key could enumerate `external_id` to repeatedly retrieve the plaintext of any child key, and since child keys can spend money, \"the provisioning key can't spend money itself\" would no longer be a loss ceiling. If `external_id` is just the user ID, the enumeration cost is close to zero.\n>\n> Real create retries happen within seconds, so 5 minutes is generous. **When you need the plaintext again, the right move is to issue a new key**: disable the old one and create with a new `external_id`. This leaves an audit record; a silent re-retrieval doesn't.\n\n> [!WARNING]\n> `external_id` uniqueness **includes disabled keys**: one ID permanently maps to one key. To unban a user, use `PATCH {\"disabled\": false}`; **do not** open another key with the same `external_id`; otherwise that user's usage history splits into two segments.\n\n### Locating by external ID\n\nNo need to maintain an `external_id` → `hash` mapping table; you can operate directly with your own ID:\n\n```bash\ncurl https://tare.jamerly.ai/v1/keys/external/usr_8f3a2b91 \\\n  -H \"Authorization: Bearer $TARE_PROVISIONING_KEY\"\n\ncurl -X PATCH https://tare.jamerly.ai/v1/keys/external/usr_8f3a2b91 \\\n  -H \"Authorization: Bearer $TARE_PROVISIONING_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"limit\": 3.75}'\n```\n\nThe semantics are **exactly the same** as the `hash`-based endpoints. `/external/{id}` is a separate path rather than letting `{hash}` accept both kinds of identifiers: both are free text, and if placed in the same position, an ID that happens to look like a hash would silently operate on a different key.\n\n### Changing the limit / disabling\n\n```bash\ncurl -X PATCH https://tare.jamerly.ai/v1/keys/$HASH \\\n  -H \"Authorization: Bearer $TARE_PROVISIONING_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"limit\": 3.75}'\n```\n\n**Takes effect on the next call**, with no cache delay. This is a deliberate guarantee: when you lower the limit after deducting a user's credits, any minute-level delay window means overspending.\n\nTo disable, pass `{\"disabled\": true}`, which also takes effect immediately.\n\n### Limit semantics\n\nThe limit is checked against `limit_usage`, the spend since the last reset. For a key that has never been reset, `limit_usage` is the cumulative `usage` and `limit` is a lifetime cap. `usage` only goes up; resets don't touch it.\n\nTwo ways to sync credits:\n\n- On every credit change, reset the key and set `limit` to the amount matching the user's current credits (see the next section).\n- Without resets, count cumulatively: `limit = usage + the amount matching the user's current credits`. If the key is spending between your read of `usage` and the update, this drifts.\n\nThe three limits don't overlap:\n\n| Limit | Effect | Set by |\n|---|---|---|\n| Account balance | Whether this account is in arrears | Platform |\n| Monthly budget | This month's spend cap, **resets every month** | You |\n| **Key limit** | This key's spend cap, **doesn't come back until reset** | You (i.e. `limit` here) |\n\nThe third isn't merged with the monthly budget, because credits don't automatically restore every month.\n\n### Resetting the limit\n\n**Reset now**: `limit_usage` goes back to 0 and `limit_remaining` back to `limit`, effective on the next call. No request body.\n\n```bash\ncurl -X POST https://tare.jamerly.ai/v1/keys/$HASH/reset \\\n  -H \"Authorization: Bearer $TARE_PROVISIONING_KEY\"\n```\n\nTo reset by your own ID, use `POST /v1/keys/external/{id}/reset`. The returned `data` has the same shape as the lookup endpoint.\n\n**Reset on a schedule**: pass `limit_reset` when creating or in a `PATCH`.\n\n```bash\ncurl -X PATCH https://tare.jamerly.ai/v1/keys/$HASH \\\n  -H \"Authorization: Bearer $TARE_PROVISIONING_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"limit\": 5, \"limit_reset\": \"daily\"}'\n```\n\n| Value | Resets at (UTC) |\n|---|---|\n| `daily` | 00:00 every day |\n| `weekly` | 00:00 every Monday |\n| `monthly` | 00:00 on the 1st of each month |\n| `null` | Never |\n\nThe reset happens within a minute of the boundary. Values and boundaries match OpenRouter's `limit_reset`.\n\n> [!NOTE]\n> Turning on a reset period starts the period at that moment; what the key already spent is **not** wiped. To clear it now, call reset as well.\n\n> [!NOTE]\n> A reset only affects the limit. `usage`, invoices, and usage records stay the same, and the account balance doesn't grow.\n\n### Usage by day\n\n`usage_daily`, `usage_weekly` and `usage_monthly` on the key object have the same names and meaning as in OpenRouter's `GET /api/v1/key`. They count spend inside a time window, so a reset doesn't change them. Days are cut in the billing timezone, which the endpoints below return as `timezone`; `limit_reset` uses UTC boundaries instead. `null` means usage can't be read right now, not 0.\n\nFor a key with `include_byok_in_limit: false`, `usage` leaves BYOK spend out, while these three fields and the daily rows below include it.\n\nFor history, read one row per key per day:\n\n```bash\ncurl \"https://tare.jamerly.ai/v1/keys/usage/daily?from=2026-11-01&to=2026-11-23\" \\\n  -H \"Authorization: Bearer $TARE_PROVISIONING_KEY\"\n```\n\n| Path | Scope |\n|---|---|\n| `GET /v1/keys/usage/daily` | All child keys under the account |\n| `GET /v1/keys/{hash}/usage/daily` | One key |\n| `GET /v1/keys/external/{id}/usage/daily` | One key, located by your own ID |\n\n| Parameter | Meaning |\n|---|---|\n| `from` / `to` | `YYYY-MM-DD`, both inclusive; defaults to the 1st of this month through today. At most 100 days per request |\n| `group_by` | `model` splits each row by model and adds a `model` field |\n\n```json\n{\"data\": [\n  {\"date\": \"2026-11-22\", \"hash\": \"9c1e…\", \"external_id\": \"usr_8f3a2b91\",\n   \"usage\": 1.284, \"requests\": 37,\n   \"prompt_tokens\": 51230, \"completion_tokens\": 8410,\n   \"reasoning_tokens\": 2100, \"cached_tokens\": 30500}\n ],\n \"from\": \"2026-11-01\", \"to\": \"2026-11-23\",\n \"timezone\": \"Asia/Shanghai\", \"includes_open_day\": true}\n```\n\n| Field | Description |\n|---|---|\n| `external_id` | The key's external ID; null if never set |\n| `usage` | Spend that day (USD), same basis as `usage_daily` |\n| `requests` | Number of calls |\n| `prompt_tokens` / `completion_tokens` | Input / output tokens |\n| `cached_tokens` | The part of `prompt_tokens` read from cache |\n| `reasoning_tokens` | The part of `completion_tokens` spent on reasoning. Counted from 2026-11-23; earlier days show 0. Anthropic upstreams don't report reasoning separately, so their calls show 0 |\n| `includes_open_day` | The window contains today. Today's row is computed live and still changes |\n\nA key with no usage on a given day has no row for it. Rows are ordered by date, then key, then model. For incremental sync, a response with `includes_open_day: false` won't change and can be stored as final.\n\nPer key, the figures match `/v1/integration/usage/daily` in the [Reconciliation API](integration-api); both read the same daily totals.\n\nErrors: `400` for a malformed date, `to` before `from`, a window over 100 days, or a `group_by` other than `model`; `404` for a key that isn't yours; `500` when usage is temporarily unavailable, in which case retry later.\n\n### Unauthorized access\n\nYou can only operate on keys you own. A `hash` that isn't yours returns **404 rather than 403**; a 403 would incidentally confirm that the hash really exists.\n\n### Rate limit\n\nThe provisioning key tier is **1200 requests/minute**, counted separately from model traffic: your limit-change frequency is roughly your billing-event frequency, and rate-limiting at the model tier would 429 on the first burst.\n\nFor the four tiers, the raise process, concurrency, and timeouts, see [Rate limits and quotas](limits).\n\n### Next steps\n\n- Want to know how you call models once you have a child key: read [API Key](auth).\n- Want to give a key a source IP allowlist or see the difference between the three key types: read [API Key](auth).\n- How to debug API errors: read [Error codes](errors).\n"},"diagrams":{"en-provisioning-chain":"<svg viewBox=\"0 0 848 200\" width=\"848\" role=\"img\" xmlns=\"http://www.w3.org/2000/svg\">\n  <title>Master key issues a child key</title>\n  <desc>A platform backend keeps one master key, calls POST /v1/keys when a user registers or buys quota, and hands the child key to that user. The master key manages keys and does not call models.</desc>\n  <style>\n    text { font-family: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', system-ui, sans-serif; }\n  </style>\n  <defs>\n    <marker id=\"arrow-blue\" markerWidth=\"8\" markerHeight=\"8\" refX=\"2\" refY=\"4\" orient=\"auto\" markerUnits=\"userSpaceOnUse\">\n      <path d=\"M0,0 L8,4 L0,8 L2,4 z\" fill=\"#3b82f6\"/>\n    </marker>\n    <marker id=\"arrow-orange\" markerWidth=\"8\" markerHeight=\"8\" refX=\"2\" refY=\"4\" orient=\"auto\" markerUnits=\"userSpaceOnUse\">\n      <path d=\"M0,0 L8,4 L0,8 L2,4 z\" fill=\"#f59e0b\"/>\n    </marker>\n    <marker id=\"arrow-green\" markerWidth=\"8\" markerHeight=\"8\" refX=\"2\" refY=\"4\" orient=\"auto\" markerUnits=\"userSpaceOnUse\">\n      <path d=\"M0,0 L8,4 L0,8 L2,4 z\" fill=\"#22c55e\"/>\n    </marker>\n  </defs>\n\n  <!-- 浅色画布：图被贴到深色页面上时，仍然读作一张白卡片 -->\n  <rect x=\"0\" y=\"0\" width=\"848\" height=\"200\" fill=\"#ffffff\"/>\n\n  <!-- 版式算术在任何坐标落笔之前就定死了。\n       四格同宽：宽 180、间距 28，于是 22..202 / 230..410 / 438..618 / 646..826。\n       框高按公式给：三行 12 x 3 + 2 x 18 = 72，顶边 60、底边 132，行心 y = 96。\n       内容左右边界 22..826，中心 424；viewBox 宽 = 804 + 两侧各 22 = 848；\n       标题与两条脚注都落在 424，和框体包围盒的中心是同一个数。\n       高度 = 脚注末行基线 173 + 下伸 2.5 + 22px 边距 = 197.5，取整 200。 -->\n\n  <!-- 标题落在内容中心 424。 -->\n  <text x=\"424\" y=\"34\" font-size=\"16\" fill=\"#1e293b\" text-anchor=\"middle\">Master key issues a child key</text>\n\n  <!-- 第 1 层：两条短横线（实际三格两缝，三格间两段连线），起点 = 源框右沿 + 5，终点 = 目标框左沿 - 11。\n       都在行心 96 上，与四个框同轴。线色跟着它离开的那个框的描边色。 -->\n  <path d=\"M207,96 L 219,96\" fill=\"none\" stroke=\"#3b82f6\" stroke-width=\"1.5\" marker-end=\"url(#arrow-blue)\"/>\n  <path d=\"M415,96 L 427,96\" fill=\"none\" stroke=\"#f59e0b\" stroke-width=\"1.5\" marker-end=\"url(#arrow-orange)\"/>\n  <path d=\"M623,96 L 635,96\" fill=\"none\" stroke=\"#22c55e\" stroke-width=\"1.5\" marker-end=\"url(#arrow-green)\"/>\n\n  <!-- 第 2 层：方框和文字，盖住线头。\n       三行框的基线 = 框心 + 12 x 0.35 再按 -13 / +5 / +20 摊开，落在 83 / 101 / 116。\n       蓝是「输入」——你的平台后台；橙是「处理中」——调接口创建；绿是「输出」——子钥。 -->\n  <rect x=\"22\" y=\"60\" width=\"180\" height=\"72\" rx=\"6\" fill=\"#dbeafe\" stroke=\"#3b82f6\"/>\n  <text x=\"112\" y=\"83\" font-size=\"12\" fill=\"#1e40af\" text-anchor=\"middle\">Your platform backend</text>\n  <text x=\"112\" y=\"101\" font-size=\"10\" fill=\"#1e40af\" text-anchor=\"middle\">Holds one master key</text>\n  <text x=\"112\" y=\"116\" font-size=\"10\" fill=\"#1e40af\" text-anchor=\"middle\">Manages keys, not models</text>\n\n  <rect x=\"230\" y=\"60\" width=\"180\" height=\"72\" rx=\"6\" fill=\"#fef3c7\" stroke=\"#f59e0b\"/>\n  <text x=\"320\" y=\"83\" font-size=\"12\" fill=\"#b45309\" text-anchor=\"middle\">POST /v1/keys</text>\n  <text x=\"320\" y=\"101\" font-size=\"10\" fill=\"#b45309\" text-anchor=\"middle\">Master key creates a child</text>\n  <text x=\"320\" y=\"116\" font-size=\"10\" fill=\"#b45309\" text-anchor=\"middle\">Response returns the child</text>\n\n  <rect x=\"438\" y=\"60\" width=\"180\" height=\"72\" rx=\"6\" fill=\"#d1fae5\" stroke=\"#22c55e\"/>\n  <text x=\"528\" y=\"83\" font-size=\"12\" fill=\"#166534\" text-anchor=\"middle\">Child key</text>\n  <text x=\"528\" y=\"101\" font-size=\"10\" fill=\"#166534\" text-anchor=\"middle\">Its own credential</text>\n  <text x=\"528\" y=\"116\" font-size=\"10\" fill=\"#166534\" text-anchor=\"middle\">Own limit and disable</text>\n\n  <rect x=\"646\" y=\"60\" width=\"180\" height=\"72\" rx=\"6\" fill=\"#dbeafe\" stroke=\"#3b82f6\"/>\n  <text x=\"736\" y=\"83\" font-size=\"12\" fill=\"#1e40af\" text-anchor=\"middle\">End user or project</text>\n  <text x=\"736\" y=\"101\" font-size=\"10\" fill=\"#1e40af\" text-anchor=\"middle\">Calls models with it</text>\n  <text x=\"736\" y=\"116\" font-size=\"10\" fill=\"#1e40af\" text-anchor=\"middle\">Your account and quota</text>\n\n  <!-- 脚注两行，同为 10px、行距 15px，与标题同一条中轴 424。\n       第一条是原文 NOTE 的落点：回包形状 {key, data} 两层；\n       第二条是「已对接过的客户端只需改 base_url 和管理凭据」。 -->\n  <text x=\"424\" y=\"158\" font-size=\"10\" fill=\"#64748b\" text-anchor=\"middle\">The response nests the key as {key, data}: the credential, then its attributes.</text>\n  <text x=\"424\" y=\"173\" font-size=\"10\" fill=\"#64748b\" text-anchor=\"middle\">Clients built for this shape only change base_url and the management credential.</text>\n</svg>\n","en-provisioning-rotation":"<svg viewBox=\"0 0 664 428\" width=\"664\" role=\"img\" xmlns=\"http://www.w3.org/2000/svg\">\n  <title>Master key rotation, no downtime</title>\n  <desc>Master keys are independent, so rotation has no downtime: issue a new key, switch config, confirm with GET /v1/keys, then disable the old key. Do not disable the old key first.</desc>\n  <style>\n    text { font-family: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', system-ui, sans-serif; }\n  </style>\n  <defs>\n    <marker id=\"arrow-blue\" markerWidth=\"8\" markerHeight=\"8\" refX=\"2\" refY=\"4\" orient=\"auto\" markerUnits=\"userSpaceOnUse\">\n      <path d=\"M0,0 L8,4 L0,8 L2,4 z\" fill=\"#3b82f6\"/>\n    </marker>\n    <marker id=\"arrow-orange\" markerWidth=\"8\" markerHeight=\"8\" refX=\"2\" refY=\"4\" orient=\"auto\" markerUnits=\"userSpaceOnUse\">\n      <path d=\"M0,0 L8,4 L0,8 L2,4 z\" fill=\"#f59e0b\"/>\n    </marker>\n  </defs>\n\n  <!-- 浅色画布：图被贴到深色页面上时，仍然读作一张白卡片 -->\n  <rect x=\"0\" y=\"0\" width=\"664\" height=\"428\" fill=\"#ffffff\"/>\n\n  <!-- 版式算术在任何坐标落笔之前就定死了。\n       四步竖排同宽：宽 620、x = 22..642，中心 332。\n       框高两行 = 12 x 3 + 18 = 54，顶边 60 / 142 / 224 / 306；\n       上一行底边到下一行顶边一律 28px。\n       内容左右边界 22..642，中心 332；viewBox 宽 = 620 + 两侧各 22 = 664；\n       标题与两条脚注都落在 332，和框体包围盒的中心是同一个数。\n       高度 = 脚注末行基线 403 + 下伸 2.5 + 22px 边距 = 427.5，取整 428。 -->\n\n  <!-- 标题落在内容中心 332。 -->\n  <text x=\"332\" y=\"34\" font-size=\"16\" fill=\"#1e293b\" text-anchor=\"middle\">Master key rotation, no downtime</text>\n\n  <!-- 第 1 层：连线。起点 = 源框底边 + 5，终点 = 目标框顶边 - 11，留 12px 可见线。\n       全竖直、走中轴 332；线色跟着它离开的那个框的描边色。 -->\n  <path d=\"M332,119 L 332,131\" fill=\"none\" stroke=\"#3b82f6\" stroke-width=\"1.5\" marker-end=\"url(#arrow-blue)\"/>\n  <path d=\"M332,201 L 332,213\" fill=\"none\" stroke=\"#f59e0b\" stroke-width=\"1.5\" marker-end=\"url(#arrow-orange)\"/>\n  <path d=\"M332,283 L 332,295\" fill=\"none\" stroke=\"#f59e0b\" stroke-width=\"1.5\" marker-end=\"url(#arrow-orange)\"/>\n\n  <!-- 第 2 层：方框和文字，盖住线头。\n       两行框的基线 = 框心 + 12 x 0.35 再上下各让 9px：\n       60 起的框落在 82 / 100，142 起的框落在 164 / 182，\n       224 起的框落在 246 / 264，306 起的框落在 328 / 346。\n       蓝是「你发起」——签发；橙是「操作/确认」——切配置、验可用；绿是「完成」——停用旧的。 -->\n  <rect x=\"22\" y=\"60\" width=\"620\" height=\"54\" rx=\"6\" fill=\"#dbeafe\" stroke=\"#3b82f6\"/>\n  <text x=\"332\" y=\"82\" font-size=\"12\" fill=\"#1e40af\" text-anchor=\"middle\">1. Platform issues a new master key</text>\n  <text x=\"332\" y=\"100\" font-size=\"10\" fill=\"#1e40af\" text-anchor=\"middle\">Plaintext is shown once. Only a fingerprint is kept.</text>\n\n  <rect x=\"22\" y=\"142\" width=\"620\" height=\"54\" rx=\"6\" fill=\"#fef3c7\" stroke=\"#f59e0b\"/>\n  <text x=\"332\" y=\"164\" font-size=\"12\" fill=\"#b45309\" text-anchor=\"middle\">2. Point config at the new master key</text>\n  <text x=\"332\" y=\"182\" font-size=\"10\" fill=\"#b45309\" text-anchor=\"middle\">New traffic uses the new key, on your side</text>\n\n  <rect x=\"22\" y=\"224\" width=\"620\" height=\"54\" rx=\"6\" fill=\"#fef3c7\" stroke=\"#f59e0b\"/>\n  <text x=\"332\" y=\"246\" font-size=\"12\" fill=\"#b45309\" text-anchor=\"middle\">3. GET /v1/keys to confirm it works</text>\n  <text x=\"332\" y=\"264\" font-size=\"10\" fill=\"#b45309\" text-anchor=\"middle\">Not /whoami. A master key always gets 403.</text>\n\n  <rect x=\"22\" y=\"306\" width=\"620\" height=\"54\" rx=\"6\" fill=\"#d1fae5\" stroke=\"#22c55e\"/>\n  <text x=\"332\" y=\"328\" font-size=\"12\" fill=\"#166534\" text-anchor=\"middle\">4. Ask the platform to disable the old key</text>\n  <text x=\"332\" y=\"346\" font-size=\"10\" fill=\"#166534\" text-anchor=\"middle\">New signups fail while it is disabled, so do this last</text>\n\n  <!-- 脚注两行，同为 10px、行距 15px，与标题同一条中轴 332。\n       第一条是「零停机」的根据；\n       第二条是那两条 WARNING 的合并落点（落档第 127、129 行）。 -->\n  <text x=\"332\" y=\"388\" font-size=\"10\" fill=\"#64748b\" text-anchor=\"middle\">Master keys are independent. One account can hold several and disable them apart, so rotation does not stop traffic.</text>\n  <text x=\"332\" y=\"403\" font-size=\"10\" fill=\"#64748b\" text-anchor=\"middle\">Do not disable the old key before switching config. Signups fail while it is off. Child keys already issued stay.</text>\n</svg>\n","en-provisioning-idempotent":"<svg viewBox=\"0 0 700 548\" width=\"700\" role=\"img\" xmlns=\"http://www.w3.org/2000/svg\">\n  <title>Creating a child key, idempotent</title>\n  <desc>Create a child key with external_id. No timeout returns HTTP 201 and the full credential. After a timeout, retry the same external_id: an existing key comes back as HTTP 200, a missing one is created as 201, and neither path opens a second key. After 5 minutes, key is null and key_unavailable_reason is set. key=null is not disabled, and re-enable does not restore the plaintext.</desc>\n  <style>\n    text { font-family: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', system-ui, sans-serif; }\n  </style>\n  <defs>\n    <marker id=\"arrow-blue\" markerWidth=\"8\" markerHeight=\"8\" refX=\"2\" refY=\"4\" orient=\"auto\" markerUnits=\"userSpaceOnUse\">\n      <path d=\"M0,0 L8,4 L0,8 L2,4 z\" fill=\"#3b82f6\"/>\n    </marker>\n    <marker id=\"arrow-orange\" markerWidth=\"8\" markerHeight=\"8\" refX=\"2\" refY=\"4\" orient=\"auto\" markerUnits=\"userSpaceOnUse\">\n      <path d=\"M0,0 L8,4 L0,8 L2,4 z\" fill=\"#f59e0b\"/>\n    </marker>\n    <marker id=\"arrow-pink\" markerWidth=\"8\" markerHeight=\"8\" refX=\"2\" refY=\"4\" orient=\"auto\" markerUnits=\"userSpaceOnUse\">\n      <path d=\"M0,0 L8,4 L0,8 L2,4 z\" fill=\"#ec4899\"/>\n    </marker>\n  </defs>\n\n  <!-- 浅色画布 -->\n  <rect x=\"0\" y=\"0\" width=\"700\" height=\"548\" fill=\"#ffffff\"/>\n\n  <!-- 版式算术在任何坐标落笔之前就定死了。\n       全宽横条宽 656，x = 22..678，中心 350；\n       两行框高 54（12 x 3 + 18），三行框高 72（12 x 3 + 2 x 18）。\n       行顶边 60 / 142 / 224 / 324 / 406；上一行底边到下一行顶边一律 28px。\n       第 3 行是左右两栏：宽 314、间距 28，于是 22..336 / 364..678（中心 179 / 521）。\n       内容左右边界 22..678，中心 350；viewBox 宽 = 656 + 两侧各 22 = 700；\n       标题与两条脚注都落在 350，和框体包围盒的中心是同一个数。\n       高度 = 脚注末行基线 523 + 下伸 2.5 + 22px 边距 = 547.5，取整 548。 -->\n\n  <!-- 标题落在内容中心 350。 -->\n  <text x=\"350\" y=\"34\" font-size=\"16\" fill=\"#1e293b\" text-anchor=\"middle\">Creating a child key, idempotent</text>\n\n  <!-- 第 1 层：连线。起点 = 源框底边 + 5，终点 = 目标框顶边 - 11，留 12px 可见线。\n       四条全竖直；第 2 行的两个落点（179 / 521）都在源框 22..678 的 x 范围内，\n       所以不需要扇出弧线，直接竖线即可。 -->\n  <path d=\"M350,119 L 350,131\" fill=\"none\" stroke=\"#3b82f6\" stroke-width=\"1.5\" marker-end=\"url(#arrow-blue)\"/>\n  <path d=\"M179,201 L 179,213\" fill=\"none\" stroke=\"#f59e0b\" stroke-width=\"1.5\" marker-end=\"url(#arrow-orange)\"/>\n  <path d=\"M521,201 L 521,213\" fill=\"none\" stroke=\"#f59e0b\" stroke-width=\"1.5\" marker-end=\"url(#arrow-orange)\"/>\n  <path d=\"M521,301 L 521,313\" fill=\"none\" stroke=\"#ec4899\" stroke-width=\"1.5\" marker-end=\"url(#arrow-pink)\"/>\n\n  <!-- 第 2 层：方框和文字，盖住线头。\n       两行框的基线 = 框心 + 12 x 0.35 再上下各让 9px：60 起的落在 82 / 100，142 起的落在 164 / 182，\n       324 起的落在 346 / 364，406 起的落在 428 / 446；\n       三行框的基线 = 框心 + 12 x 0.35 再按 -13 / +5 / +20 摊开：224 起的落在 247 / 265 / 280。\n       蓝是「输入」——创建入口；橙是「处理中」——超时与重试；绿是「输出」——正常结果；\n       粉是「注意/警告」——窗口限制；灰虚线是旁注，不在流程里。 -->\n  <rect x=\"22\" y=\"60\" width=\"656\" height=\"54\" rx=\"6\" fill=\"#dbeafe\" stroke=\"#3b82f6\"/>\n  <text x=\"350\" y=\"82\" font-size=\"12\" fill=\"#1e40af\" text-anchor=\"middle\">Create a child key with external_id</text>\n  <text x=\"350\" y=\"100\" font-size=\"10\" fill=\"#1e40af\" text-anchor=\"middle\">Without it, a retry can add a key, or skipping the retry can lose one</text>\n\n  <rect x=\"22\" y=\"142\" width=\"656\" height=\"54\" rx=\"6\" fill=\"#fef3c7\" stroke=\"#f59e0b\"/>\n  <text x=\"350\" y=\"164\" font-size=\"12\" fill=\"#b45309\" text-anchor=\"middle\">Did the create request time out?</text>\n  <text x=\"350\" y=\"182\" font-size=\"10\" fill=\"#b45309\" text-anchor=\"middle\">You cannot tell if it was created. That is when you retry.</text>\n\n  <rect x=\"22\" y=\"224\" width=\"314\" height=\"72\" rx=\"6\" fill=\"#d1fae5\" stroke=\"#22c55e\"/>\n  <text x=\"179\" y=\"247\" font-size=\"12\" fill=\"#166534\" text-anchor=\"middle\">No timeout, normal return</text>\n  <text x=\"179\" y=\"265\" font-size=\"10\" fill=\"#166534\" text-anchor=\"middle\">HTTP 201. Full key, shown once.</text>\n  <text x=\"179\" y=\"280\" font-size=\"10\" fill=\"#166534\" text-anchor=\"middle\">data.hash is the stable id for this key</text>\n\n  <rect x=\"364\" y=\"224\" width=\"314\" height=\"72\" rx=\"6\" fill=\"#fef3c7\" stroke=\"#f59e0b\"/>\n  <text x=\"521\" y=\"247\" font-size=\"12\" fill=\"#b45309\" text-anchor=\"middle\">Timed out: retry that external_id</text>\n  <text x=\"521\" y=\"265\" font-size=\"10\" fill=\"#b45309\" text-anchor=\"middle\">Exists: that key returns (200, not 201)</text>\n  <text x=\"521\" y=\"280\" font-size=\"10\" fill=\"#b45309\" text-anchor=\"middle\">Missing: create it (201). No second key.</text>\n\n  <rect x=\"22\" y=\"324\" width=\"656\" height=\"54\" rx=\"6\" fill=\"#fce7f3\" stroke=\"#ec4899\"/>\n  <text x=\"350\" y=\"346\" font-size=\"12\" fill=\"#9d174d\" text-anchor=\"middle\">Repeat create after 5 minutes: key is null</text>\n  <text x=\"350\" y=\"364\" font-size=\"10\" fill=\"#9d174d\" text-anchor=\"middle\">The same object adds key_unavailable_reason. Branch on it.</text>\n\n  <!-- 旁注：虚线框、不在流程里，所以不与任何箭头相连。 -->\n  <rect x=\"22\" y=\"406\" width=\"656\" height=\"72\" rx=\"6\" fill=\"#f8fafc\" stroke=\"#94a3b8\" stroke-dasharray=\"6,4\"/>\n  <text x=\"350\" y=\"428\" font-size=\"12\" fill=\"#64748b\" text-anchor=\"middle\">Note: re-enable and key=null differ</text>\n  <text x=\"350\" y=\"446\" font-size=\"10\" fill=\"#64748b\" text-anchor=\"middle\">key=null is not disabled. Re-enable does not restore plaintext.</text>\n  <text x=\"350\" y=\"464\" font-size=\"10\" fill=\"#64748b\" text-anchor=\"middle\">Re-enable with PATCH {disabled:false}. A new key on the same external_id splits usage history.</text>\n\n  <!-- 脚注两行，同为 10px、行距 15px，与标题同一条中轴 350。\n       第一条是 external_id 的用途（落档第 44、127 行）；第二条是 5 分钟窗口那条 WARNING 的摘要。 -->\n  <text x=\"350\" y=\"508\" font-size=\"10\" fill=\"#64748b\" text-anchor=\"middle\">Always send external_id. After a timeout, the same id retries safely and does not open a second key.</text>\n  <text x=\"350\" y=\"523\" font-size=\"10\" fill=\"#64748b\" text-anchor=\"middle\">The full key can be fetched again for 5 minutes. After that, mint a new key. A silent refetch is not audited.</text>\n</svg>\n"}}