Skip to content
中文

Update a publishable key

Code Mode: praxis.customer.publishableKeys.update

HTTP: PATCH /customer/v1/publishable_keys/{key_id}

Change the name of a publishable key or its own limits on anonymous admittance, for example to cap a page that is drawing more anonymous visitors than you want to pay for. Send at least one of name, anon_rate_per_min, daily_session_cap or daily_spend_cap; a field left out keeps its value, and null removes that limit. anon_rate_per_min caps the exchanges of this key per UTC minute across all visitors (returning visitors included), daily_session_cap caps the new anonymous visitors it admits per UTC day, and daily_spend_cap caps what its visitors’ usage may cost per UTC day (a returning visitor is refused too, because it would start new chargeable work); a returning visitor that sends its continuation_token is never counted toward or refused by the daily cap. A new limit applies from the next exchange. The resources a key grants and its plaintext value never change; mint a new key for different resources. Get the key id from the publishable key list. An unknown, deleted or foreign id answers 400 INVALID_PARAMS, as does a limit outside its range.

Signature

praxis.customer.publishableKeys.update(args:{path:{key_id:string};body:{/** New label for the key, 1 to 64 characters. */ name?:string;/** Most exchanges of this key per UTC minute, from 1 to 100000; null removes the per-key limit. */ anon_rate_per_min?:number|null;/** Most new anonymous visitors this key admits per UTC day, from 0 to 10000000; null removes the limit. */ daily_session_cap?:number|null;/** The most the usage events of this key may cost in one UTC day, for example five dollars as amount 5.00 with currency USD; null removes the cap. */ daily_spend_cap?:{/** Amount in major units of the currency as a decimal string with at most 2 decimals, for example 5.00 for five dollars; read back with exactly 2 decimals. e.g. "5.00" */ amount:string;/** Currency the amount is in, USD or CNY. e.g. "USD" */ currency:"USD"|"CNY"}|null}}):Promise<{/** Object type, always customer_publishable_key. */ type?:"customer_publishable_key";/** Key id (pk_…) used by the key list and the delete call. */ id?:string;/** Label you gave the key, for example Storefront. */ name?:string;/** The resource scopes the key grants an anonymous visitor. */ resources?:Array<{/** Scope in the form <type>:<id>:<action> — agent:<id>:chat, content:<id>:play or application:<id>:visit — where <id> may be * for every object of that type. e.g. "content:cnt_0123456789abcdef:play" */ scope?:string;/** Product-defined data for this grant, for example an agent version or a budget; this service stores it and never interprets it. */ params?:Record<string,unknown>}>;/** RFC 3339 time the key was created; the key list is ordered by it, newest first. */ created_at?:string;/** Most exchanges this key allows per UTC minute, counting every exchange (a returning visitor's too), or null for no per-key limit; the per-IP limit of the exchan */ anon_rate_per_min?:number|null;/** Most new anonymous visitors this key admits per UTC day, or null for no limit; a returning visitor that continues with its continuation_token is not counted, an */ daily_session_cap?:number|null;/** The most the usage events of this key may cost in one UTC day, or null for no spend cap; once reached, every visitor is refused until 00:00 UTC and a running pr */ daily_spend_cap?:{/** Amount in major units of the currency as a decimal string with at most 2 decimals, for example 5.00 for five dollars; read back with exactly 2 decimals. e.g. "5.00" */ amount:string;/** Currency the amount is in, USD or CNY. e.g. "USD" */ currency:"USD"|"CNY"}|null;/** The plaintext key value, present only in the create response; every later read returns the key without it, because only its hash is stored. */ key?:string}>;

Parameters

NameInTypeRequiredDescription
key_idpathstringyesPublishable key id (pk_…) from publishable_keys.list, not the plaintext key value.

Request body

RequiredContent typesDescription
yesapplication/jsonThe fields to change; at least one.

Responses

StatusContent typesDescription
200application/jsonThe key with its new name and limits, without its plaintext value.
400application/jsonINVALID_PARAMS: the request is not shaped the way this face accepts — an unknown or misspelled field, a repeated query parameter, a resource scope not in the form <type>:<id>:<action>, an expand value that is not products, sign_ins or usage, or a confirm that does not repeat the path customer id. The error names the field at fault and what it accepts; correct that field and send the request again.
401application/jsonThe credential is missing, malformed or expired. Merchant routes answer UNAUTHENTICATED when the API key or session names no organization; the pre-auth doors answer GRANT_CODE_INVALID when a grant code is unknown, already used, expired or foreign, and ACCESS_TOKEN_EXPIRED when the end-user token cannot be verified (a sign-in that is over answers SIGN_IN_EXPIRED or SIGN_IN_REVOKED). Send a valid API key, request a fresh grant code, or sign the end user in again.
502application/jsonUPSTREAM_UNAVAILABLE: the token issuer or another dependency refused the call, so nothing was issued or changed. Retry later, and if it persists report the time and the request path.
503application/jsonUPSTREAM_UNAVAILABLE: this face is not usable in this environment — the CUSTOMER service binding is unwired, or the anonymous rate limiter is unavailable or misconfigured so the door fails closed. Use an environment where the face is wired, or retry when the dependency is back.