Skip to main content
Anona holds the Stripe relationship, so you never touch Stripe keys directly. Paid-plan changes go through Stripe Checkout or the Customer Portal; free-plan changes happen in place. These are control-plane calls, so they authenticate with a dashboard session, not an API key, and neither memory SDK wraps them. $SESSION is the session token sign-in returns.

View billing status

GET /v1/billing returns the current plan, credit usage, and every plan you could switch to. available_plans lists only the plans on sale today. An organization on a plan we no longer offer keeps it: plan_id, its allowance and its billing are unchanged, and it simply does not see that plan listed back to itself. credits_reset_at is when the credit allowance refreshes: on a paid plan, the end of the Stripe billing period, so it falls on the day of the month you subscribed; on Developer, the signup anniversary. It is not the 1st of the calendar month. A date landing in a month too short for it (the 31st, in February) moves to the last day of that month. current_month_ops, the per-operation counts and line_items are counted over the same billing period as credits_used, from period_start to credits_reset_at (the field keeps its old name for compatibility). period_start is null only for a legacy account with no stored boundary, where the counts fall back to the calendar month.
Each line item’s subtotal is the credits actually charged for that kind of operation this period, and unit_price is that subtotal divided by count: an average, since what one operation costs depends on the model and the tokens it used. A refunded charge reduces the subtotal and is not counted as an operation. current_month_ops counts every kind, chat turns included.
line_items is credit-cost accounting, not a Stripe invoice. The amount you are actually billed comes from Stripe.

Change plan

Free tiers

Valid only for plans priced at zero. Any paid plan returns 400 payment_required and directs you to /v1/billing/checkout instead.
Redirect the user to checkout_url. Stripe’s webhook flips the organization onto the new plan and syncs its quota once payment completes, so polling /v1/billing right after the redirect may still show the old plan for a few seconds.

Manage an existing subscription

POST /v1/billing/portal requires an existing Stripe customer, meaning you have completed checkout at least once.
Redirect the user there to update a payment method, view invoices, switch between paid plans, or cancel. Plan switches are prorated by Stripe, which is why they belong in the portal rather than in a second checkout. An upgrade applies immediately, and the organization’s unused credits are added on top of the new plan’s allowance for the current period. A downgrade is scheduled for the end of the period already paid for, exactly like a cancellation: the organization keeps the larger plan and its limits until then, and GET /v1/billing keeps reporting the larger plan until the change lands.

Top-up packs

An organization on a paid plan can buy extra credits at any time, at $1.50 per 1,000.
Redirect the user to checkout_url; it is a one-time card payment, not a subscription. Credits are added once Stripe confirms payment, so GET /v1/billing may take a few seconds to show them. It reports them as credits_banked, and credits_remaining is your plan allowance still unspent plus credits_banked. topup_packs lists the packs on offer. Purchased credits are spent only after the plan allowance is used up, they are not reset at the end of the billing period, and they never expire. A free Developer organization gets 403 topup_requires_paid_plan and has to upgrade first. If a pack is refunded, its credits are removed from credits_banked in proportion to the amount refunded; a chargeback that is lost removes the whole pack. Credits from the pack that were already spent are not reversed, and the balance never goes below zero. If a refund later fails or is canceled, the credits it removed are put back. Inside a shared organization billed to another organization, /topup answers 403 billing_personal_org_only: buy from the owner’s personal organization, whose pool the shared organization draws on. See Credit top-ups for the full rules.

Purchase history

Newest first, at most 50. Inside a shared organization billed to another organization, items is always empty: the purchases are the payer’s.

Cancel

Cancellation takes effect at the end of the current billing period, the same date as credits_reset_at. The organization keeps its paid plan and credits until then, and purchased credits stay after it. POST /v1/billing/resume undoes it any time before that date:

Error responses

See the full error reference.