Docs
Billing ›

Create billing checkout

POST/v1/billing/checkout

The payment page for a plan or a top-up, for a person to pay on.

RequestTypeScript
  1. import { Agental } from "agental-sdk";
  2. const agental = new Agental();
  3. const checkout = await agental.checkout({ topUp: 500 });
Answer200 OK · Checkout
  1. {
  2. "url": string | null,
  3. "changed": boolean,
  4. }

Where to send the browser: to save a card for the free plan, charging nothing; to pay for a plan; or for a top-up of credits that do not expire.

Headers

Authorizationrequired
Bearer key
An API key that may make this call.

Returns

200 Where to send the browser: to save a card for the free plan, charging nothing; to pay for a plan; or for a top-up of credits that do not expire. An account that already has a plan and picks another is moved with nothing to pay on a page: url is null and changed is true, and the month's credits are each plan's for the part of the month it holds. A smaller plan is moved to at once, and a bigger one once the payment provider has charged the difference, within seconds. To go back to the free plan, cancel the plan in the billing portal.

Checkout2 fields
url
stringnull
changed
boolean

Errors and other answers

409 billing_not_configured, already_on_plan, card_saved: a card is saved already, or
409payment_late the plan's last payment has not gone through, so it is not changed until it has.
429 rate_limited. The account asked for too many amounts of top-up the store had no product for today.
503 billing_unavailable. The payment provider did not answer.

Every error answers { "error": { "code", "message" } }; a key without the action a call needs answers 403 key_action_forbidden, naming it.