{"type":"root","children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"What this solves"}]},{"type":"text","value":": Explains how the provisioning key issues and manages downstream child keys, plus the child key limit, expiry, and idempotent-creation gotchas."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"When 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."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If you or a single service calls models directly, use an Inference key. See "},{"type":"element","tagName":"a","properties":{"href":"before-key"},"children":[{"type":"text","value":"Before you start"}]},{"type":"text","value":". A provisioning key plus child keys is for a SaaS product or a middle platform that issues keys, sets limits, and hands them out."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The 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 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"/v1/keys"}]},{"type":"text","value":" to create a Child key, then hands it to that user or to the project's server to use."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"img","properties":{"src":"diagram:en-provisioning-chain","alt":"Provisioning key issuing child keys · end-to-end chain","data-block":"true"},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{"data-alert":"note"},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The response embeds the key in two layers, "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"{key, data:{…}}"}]},{"type":"text","value":": the top level is the credential itself, and "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"data"}]},{"type":"text","value":" holds its attributes.\nClients that already integrate against this shape only need to change "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"base_url"}]},{"type":"text","value":" and manage the credential."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"Getting a provisioning key"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Issue one yourself on the console's "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"API Keys"}]},{"type":"text","value":" page: when creating, set the type to "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Provisioning (master key)"}]},{"type":"text","value":". "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"The plaintext appears only once, at creation"}]},{"type":"text","value":"; after that only a fingerprint is kept in the database. It can also be issued by the platform on your behalf."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{"data-alert":"warning"},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The provisioning key "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"can only manage keys"}]},{"type":"text","value":": 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."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"Creating child keys"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"pre","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"curl 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"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The returned "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"key"}]},{"type":"text","value":" is the full credential, "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"shown only once"}]},{"type":"text","value":"; "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"data.hash"}]},{"type":"text","value":" is the stable identifier for locating this key later."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"table","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"thead","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Field"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Meaning"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tbody","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"name"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Purpose note, filled in by the caller; the platform doesn't model end users"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"limit"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Spend cap (USD), not a balance; omitted = no limit. With "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"limit_reset"}]},{"type":"text","value":" set, it is the cap per period"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"limit_reset"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Automatic reset period: "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"daily"}]},{"type":"text","value":" / "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"weekly"}]},{"type":"text","value":" / "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"monthly"}]},{"type":"text","value":"; omitted = never reset automatically"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"external_id"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Your business ID, used for "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"idempotent creation"}]},{"type":"text","value":" (see below)"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"include_byok_in_limit"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Whether BYOK spend counts toward this key's limit. Counted by default"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"external_id"}]},{"type":"text","value":" 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."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"Response fields"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Create, query, and limit-change responses return "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"data"}]},{"type":"text","value":" in the same shape:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"table","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"thead","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Field"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Type"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Description"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tbody","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"hash"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"string"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Stable identifier"}]},{"type":"text","value":"; every operation on this key uses it"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"name"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"string"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Purpose note"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"label"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"string"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Prefix + ellipsis, for display"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"limit"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"number or null"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Cap; "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"null = no limit"}]},{"type":"text","value":", not 0"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"limit_remaining"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"number or null"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"What's left to spend = "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"limit - limit_usage"}]},{"type":"text","value":"; also null when "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"limit"}]},{"type":"text","value":" is null"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"limit_reset"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"string or null"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Automatic reset period; null = never"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"limit_usage"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"number"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Spend since the last reset, which the limit is checked against; equals "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"usage"}]},{"type":"text","value":" if never reset"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"limit_reset_at"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"string or null"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"When the limit was last reset (UTC); null if never"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"usage"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"number"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Cumulative spend so far; resets don't change it"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"usage_daily"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"number or null"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Spend today, by the billing timezone; resets don't change it. See \"Usage by day\" below"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"usage_weekly"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"number or null"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Spend since Monday"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"usage_monthly"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"number or null"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Spend since the 1st of the month"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"disabled"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"boolean"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Whether it's disabled"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"include_byok_in_limit"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"boolean"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Whether BYOK spend counts toward the limit"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"external_id"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"string"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"External ID; "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"this field is absent when unset"}]}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"byok_usage"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"number"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Currently always 0, reserved field"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"created_at"}]},{"type":"text","value":" / "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"updated_at"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"string"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"ISO 8601"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"expires_at"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"string or null"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Expiry time"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"Listing and pagination"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"GET /v1/keys?limit=&after="}]},{"type":"text","value":", cursor pagination, "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"includes disabled keys"}]},{"type":"text","value":" (you need to iterate all of them when rotating management credentials for a full migration)."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{"data-alert":"note"},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The console's "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"API Keys"}]},{"type":"text","value":" page also shows these child keys: pick the \"Child keys\" tab, which supports search by name, purpose, and "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"external ID "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"external_id"}]}]},{"type":"text","value":". To locate a single end user's child key, this is more direct than iterating the list endpoint."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"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."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{"data-alert":"warning"},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Child keys don't show up in the \"Inference\" tab"}]},{"type":"text","value":", 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."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"pre","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-json"]},"children":[{"type":"text","value":"{\"data\": [ /* same structure as above */ ], \"next_cursor\": 8123}\n"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"table","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"thead","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tbody","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Location of "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"next_cursor"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Top level"}]},{"type":"text","value":", alongside "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"data"}]}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Type"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"number (platform auto-increment ID) or "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"null"}]},{"type":"text","value":"; "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"null"}]},{"type":"text","value":" = no next page"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Usage"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Pass it back to "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"after"}]},{"type":"text","value":" as-is"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"limit"}]},{"type":"text","value":" default / max"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"100 / "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"200"}]},{"type":"text","value":"; exceeding it is clamped to 200, not an error"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{"data-alert":"warning"},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"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."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"Response when plaintext is unavailable"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"When you repeat a create beyond the 5-minute window, "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"key"}]},{"type":"text","value":" is "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"null"}]},{"type":"text","value":" and two extra fields appear at the same level:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"pre","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-json"]},"children":[{"type":"text","value":"{\"key\": null,\n \"key_unavailable_reason\": \"plaintext_window_expired\",\n \"key_unavailable_message\": \"The plaintext is only returned within 5 minutes ...\",\n \"data\": { }}\n"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"key_unavailable_reason"}]},{"type":"text","value":" is a "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"programmable enum value"}]},{"type":"text","value":", currently only "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"plaintext_window_expired"}]},{"type":"text","value":"; you'll be notified in advance before new enum values are added. "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Branch on this field"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"key_unavailable_message"}]},{"type":"text","value":" is a human-facing message, "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"its wording changes, don't use it for programmatic decisions"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"Expiry ("},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"expires_at"}]},{"type":"text","value":")"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can pass it at creation and change it later ("},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"PATCH"}]},{"type":"text","value":" with "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"expires_at"}]},{"type":"text","value":"; an explicit "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"null"}]},{"type":"text","value":" cancels the expiry)."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{"data-alert":"warning"},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"An expired key calling a model returns 401"}]},{"type":"text","value":", identical to a revoked one. Distinguishing the two would amount to confirming to someone holding an invalid credential that \"this key once existed\"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Expiry does not set "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"disabled"}]},{"type":"text","value":" to "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"true"}]}]},{"type":"text","value":"; that field only means \"disabled\". To check expiry, read "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"expires_at"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"Provisioning key rotation"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Provisioning keys are independent of each other; an account can "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"hold several at once"}]},{"type":"text","value":" and disable them separately, so rotation is zero-downtime:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ol","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"The platform issues a new provisioning key (plaintext appears only once);"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Switch the configuration to the new provisioning key, and new traffic goes through it;"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Confirm the new provisioning key works with any "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"GET /v1/keys"}]},{"type":"text","value":". "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"/whoami"}]},{"type":"text","value":" won't work"}]},{"type":"text","value":": that endpoint belongs to the reconciliation key, and the provisioning key gets a 403 whether it's valid or not;"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Tell the platform to disable the old provisioning key."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{"data-alert":"warning"},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Don't disable the old one before switching the configuration."}]},{"type":"text","value":" The provisioning key is the only way to create child keys; during the disable window "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"all new user registrations will fail"}]},{"type":"text","value":", with no way to compensate."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{"data-alert":"note"},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Rotating the provisioning key "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"doesn't affect already-issued child keys"}]},{"type":"text","value":"; child keys are independent credentials and don't become invalid when the provisioning key does."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"img","properties":{"src":"diagram:en-provisioning-rotation","alt":"Provisioning key rotation · zero-downtime sequence","data-block":"true"},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"Idempotent creation"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"After a create request times out you can't tell whether it was created: retrying creates one too many, not retrying leaves one missing. Including "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"external_id"}]},{"type":"text","value":" avoids this: repeating a create with the same ID "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"returns the existing key"}]},{"type":"text","value":", with an HTTP status code of "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"200"}]},{"type":"text","value":" instead of "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"201"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"img","properties":{"src":"diagram:en-provisioning-idempotent","alt":"Creating child keys · idempotency","data-block":"true"},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{"data-alert":"warning"},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"The full key can only be retrieved again within 5 minutes of creation."}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Beyond that window, a repeated create still returns the key's "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"data"}]},{"type":"text","value":", but "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"key"}]},{"type":"text","value":" is "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"null"}]},{"type":"text","value":", with a "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"key_unavailable_reason"}]},{"type":"text","value":" attached."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Without this limit, anyone holding the provisioning key could enumerate "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"external_id"}]},{"type":"text","value":" 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 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"external_id"}]},{"type":"text","value":" is just the user ID, the enumeration cost is close to zero."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Real create retries happen within seconds, so 5 minutes is generous. "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"When you need the plaintext again, the right move is to issue a new key"}]},{"type":"text","value":": disable the old one and create with a new "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"external_id"}]},{"type":"text","value":". This leaves an audit record; a silent re-retrieval doesn't."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{"data-alert":"warning"},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"external_id"}]},{"type":"text","value":" uniqueness "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"includes disabled keys"}]},{"type":"text","value":": one ID permanently maps to one key. To unban a user, use "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"PATCH {\"disabled\": false}"}]},{"type":"text","value":"; "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"do not"}]},{"type":"text","value":" open another key with the same "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"external_id"}]},{"type":"text","value":"; otherwise that user's usage history splits into two segments."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"Locating by external ID"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"No need to maintain an "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"external_id"}]},{"type":"text","value":" → "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"hash"}]},{"type":"text","value":" mapping table; you can operate directly with your own ID:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"pre","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"curl 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"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The semantics are "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"exactly the same"}]},{"type":"text","value":" as the "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"hash"}]},{"type":"text","value":"-based endpoints. "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"/external/{id}"}]},{"type":"text","value":" is a separate path rather than letting "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"{hash}"}]},{"type":"text","value":" 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."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"Changing the limit / disabling"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"pre","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"curl -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"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Takes effect on the next call"}]},{"type":"text","value":", 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."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To disable, pass "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"{\"disabled\": true}"}]},{"type":"text","value":", which also takes effect immediately."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"Limit semantics"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The limit is checked against "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"limit_usage"}]},{"type":"text","value":", the spend since the last reset. For a key that has never been reset, "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"limit_usage"}]},{"type":"text","value":" is the cumulative "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"usage"}]},{"type":"text","value":" and "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"limit"}]},{"type":"text","value":" is a lifetime cap. "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"usage"}]},{"type":"text","value":" only goes up; resets don't touch it."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Two ways to sync credits:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"On every credit change, reset the key and set "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"limit"}]},{"type":"text","value":" to the amount matching the user's current credits (see the next section)."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Without resets, count cumulatively: "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"limit = usage + the amount matching the user's current credits"}]},{"type":"text","value":". If the key is spending between your read of "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"usage"}]},{"type":"text","value":" and the update, this drifts."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The three limits don't overlap:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"table","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"thead","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Limit"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Effect"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Set by"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tbody","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Account balance"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Whether this account is in arrears"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Platform"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Monthly budget"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"This month's spend cap, "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"resets every month"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"You"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Key limit"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"This key's spend cap, "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"doesn't come back until reset"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"You (i.e. "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"limit"}]},{"type":"text","value":" here)"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The third isn't merged with the monthly budget, because credits don't automatically restore every month."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"Resetting the limit"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Reset now"}]},{"type":"text","value":": "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"limit_usage"}]},{"type":"text","value":" goes back to 0 and "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"limit_remaining"}]},{"type":"text","value":" back to "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"limit"}]},{"type":"text","value":", effective on the next call. No request body."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"pre","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"curl -X POST https://tare.jamerly.ai/v1/keys/$HASH/reset \\\n  -H \"Authorization: Bearer $TARE_PROVISIONING_KEY\"\n"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To reset by your own ID, use "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"POST /v1/keys/external/{id}/reset"}]},{"type":"text","value":". The returned "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"data"}]},{"type":"text","value":" has the same shape as the lookup endpoint."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Reset on a schedule"}]},{"type":"text","value":": pass "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"limit_reset"}]},{"type":"text","value":" when creating or in a "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"PATCH"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"pre","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"curl -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"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"table","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"thead","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Value"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Resets at (UTC)"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tbody","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"daily"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"00:00 every day"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"weekly"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"00:00 every Monday"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"monthly"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"00:00 on the 1st of each month"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"null"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Never"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The reset happens within a minute of the boundary. Values and boundaries match OpenRouter's "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"limit_reset"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{"data-alert":"note"},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Turning on a reset period starts the period at that moment; what the key already spent is "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"not"}]},{"type":"text","value":" wiped. To clear it now, call reset as well."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{"data-alert":"note"},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"A reset only affects the limit. "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"usage"}]},{"type":"text","value":", invoices, and usage records stay the same, and the account balance doesn't grow."}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"Usage by day"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"usage_daily"}]},{"type":"text","value":", "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"usage_weekly"}]},{"type":"text","value":" and "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"usage_monthly"}]},{"type":"text","value":" on the key object have the same names and meaning as in OpenRouter's "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"GET /api/v1/key"}]},{"type":"text","value":". 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 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"timezone"}]},{"type":"text","value":"; "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"limit_reset"}]},{"type":"text","value":" uses UTC boundaries instead. "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"null"}]},{"type":"text","value":" means usage can't be read right now, not 0."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"For a key with "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"include_byok_in_limit: false"}]},{"type":"text","value":", "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"usage"}]},{"type":"text","value":" leaves BYOK spend out, while these three fields and the daily rows below include it."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"For history, read one row per key per day:"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"pre","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"curl \"https://tare.jamerly.ai/v1/keys/usage/daily?from=2026-11-01&to=2026-11-23\" \\\n  -H \"Authorization: Bearer $TARE_PROVISIONING_KEY\"\n"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"table","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"thead","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Path"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Scope"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tbody","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"GET /v1/keys/usage/daily"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"All child keys under the account"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"GET /v1/keys/{hash}/usage/daily"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"One key"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"GET /v1/keys/external/{id}/usage/daily"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"One key, located by your own ID"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"table","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"thead","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Parameter"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Meaning"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tbody","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"from"}]},{"type":"text","value":" / "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"to"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"YYYY-MM-DD"}]},{"type":"text","value":", both inclusive; defaults to the 1st of this month through today. At most 100 days per request"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"group_by"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"model"}]},{"type":"text","value":" splits each row by model and adds a "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"model"}]},{"type":"text","value":" field"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"pre","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-json"]},"children":[{"type":"text","value":"{\"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"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"table","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"thead","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Field"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Description"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tbody","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"external_id"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"The key's external ID; null if never set"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"usage"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Spend that day (USD), same basis as "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"usage_daily"}]}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"requests"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Number of calls"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"prompt_tokens"}]},{"type":"text","value":" / "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"completion_tokens"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Input / output tokens"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"cached_tokens"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"The part of "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"prompt_tokens"}]},{"type":"text","value":" read from cache"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"reasoning_tokens"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"The part of "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"completion_tokens"}]},{"type":"text","value":" spent on reasoning. Counted from 2026-11-23; earlier days show 0. Anthropic upstreams don't report reasoning separately, so their calls show 0"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"includes_open_day"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"The window contains today. Today's row is computed live and still changes"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"A 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 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"includes_open_day: false"}]},{"type":"text","value":" won't change and can be stored as final."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Per key, the figures match "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"/v1/integration/usage/daily"}]},{"type":"text","value":" in the "},{"type":"element","tagName":"a","properties":{"href":"integration-api"},"children":[{"type":"text","value":"Reconciliation API"}]},{"type":"text","value":"; both read the same daily totals."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Errors: "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"400"}]},{"type":"text","value":" for a malformed date, "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"to"}]},{"type":"text","value":" before "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"from"}]},{"type":"text","value":", a window over 100 days, or a "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"group_by"}]},{"type":"text","value":" other than "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"model"}]},{"type":"text","value":"; "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"404"}]},{"type":"text","value":" for a key that isn't yours; "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"500"}]},{"type":"text","value":" when usage is temporarily unavailable, in which case retry later."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"Unauthorized access"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can only operate on keys you own. A "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"hash"}]},{"type":"text","value":" that isn't yours returns "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"404 rather than 403"}]},{"type":"text","value":"; a 403 would incidentally confirm that the hash really exists."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"Rate limit"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The provisioning key tier is "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"1200 requests/minute"}]},{"type":"text","value":", 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."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"For the four tiers, the raise process, concurrency, and timeouts, see "},{"type":"element","tagName":"a","properties":{"href":"limits"},"children":[{"type":"text","value":"Rate limits and quotas"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"Next steps"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Want to know how you call models once you have a child key: read "},{"type":"element","tagName":"a","properties":{"href":"auth"},"children":[{"type":"text","value":"API Key"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"Want to give a key a source IP allowlist or see the difference between the three key types: read "},{"type":"element","tagName":"a","properties":{"href":"auth"},"children":[{"type":"text","value":"API Key"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"How to debug API errors: read "},{"type":"element","tagName":"a","properties":{"href":"errors"},"children":[{"type":"text","value":"Error codes"}]},{"type":"text","value":"."}]},{"type":"text","value":"\n"}]}]}