Refill this key's wallet
Available only to a key issued with purchasing enabled, and only up to what the key may still spend (cap − spent − current balance): a purchase can never lift the key's own spend cap. Raising the cap and enabling purchasing are human actions.
status: charged means the payment provider accepted the collection from a saved payment method — not that the tokens have landed; they are credited when the payment is confirmed, so poll /tokens/balance. status: requires_human means no saved payment method was available: nothing was charged and checkout_url is for a person to open.
A human session is refused here with AGENT_KEY_REQUIRED — the apps have a real checkout with card entry and 3-D Secure.
Named like every other paid call: this is the one endpoint where software starts a charge, so a call that times out after the provider took it comes back as the same purchase rather than a second one.
Request
- Base URL: https://api.getfacade.ai/api/v1
- URL: https://api.getfacade.ai/api/v1/tokens/purchase
- Auth: one of:
- HTTP bearer
- OAuth 2 (authorization code, authorization URL https://api.getfacade.ai/oauth/authorize, token URL https://api.getfacade.ai/oauth/token, scopes: agent)
Headers
Names this order so a retry of it is answered rather than performed again. Required on every paid call made with an agent key: without it the call answers 422 IDEMPOTENCY_KEY_REQUIRED before anything is queued. (Optional for an app session, which is the only other caller of these paths.)
Any value of 8 to 191 characters, unique per account; a UUID per order is the usual choice. A repeat carrying the same value and the same body gets the original status and body back, with Idempotent-Replay: true on the response. The same value with a DIFFERENT body answers 422 IDEMPOTENCY_KEY_REUSED. A refusal (any 4xx) releases the value, so the same one can be sent again once the reason is fixed. Remembered for 24 hours.
A new order needs a new value. Two identical calls under two values are two designs, which is what exploring variants looks like on the wire.
Request body
Response
Purchase started
Changes
No recorded changes to this operation across all 1 revision of this API.