Subscriptions & billing
A tenant’s plan determines its features and monthly document quota. Subscriptions are tenant-level and environment-independent. Only production emissions consume quota — sandbox is always free.
Two plan ladders, chosen by identification type
Section titled “Two plan ladders, chosen by identification type”The catalog is split in two. The pf_* plans are for a persona física and are
sold only to holders of a cédula física (01) or DIMEX (03); the pj_* plans
are for a persona jurídica and are open to every identification type. A plan
code is stable and never carries the commercial name, so a rebrand never changes
what is stored on a subscription.
GET /v1/billing/plans # public catalog; ?track=pf|pj to filterGET /v1/billing/plans/available # only what THIS tenant may buyGET /v1/billing/plans is public — it is the pricing page’s source. Each entry
carries both the net price and the gross actually charged to the card, so
no client has to know the tax rate. GET /v1/billing/plans/available narrows the
catalog to the ladders the tenant may buy from, derived on the server from its
Hacienda identification type: tracks is ['pf', 'pj'] for a cédula física or a
DIMEX (both ladders, each plan tagged with its track; track is the recommended
one, pf) and ['pj'] for every other identification type. The ?track= a client
passes to the public endpoint is a display choice, not an entitlement.
Asking for a plan the tenant’s identification type does not allow fails with
PLAN_NOT_AVAILABLE_FOR_IDENTIFICATION_TYPE. The check runs before anything is
written, so a rejected request leaves no scheduled change behind and creates
nothing in Onvo. GET /v1/auth/me returns identificationType and the derived
planTrack, so a client can explain the restriction rather than only report it.
Entitlements — the axis that matters at runtime
Section titled “Entitlements — the axis that matters at runtime”GET /v1/billing/entitlementsReturns the resolved plan: tier, feature set, quota, and current usage
(including prepaidBalance). Entitlements are a separate axis from RBAC
scopes — a gated write must pass both (does the plan include the feature and
does the credential have the scope).
paymentRecovery (retrying | suspended | null) says whether there is a
failed renewal to recover from. Key the “reactivate” prompt on it and not on
status: status describes the plan being served, and a tenant with prepaid
credits reads active while its subscription is unpaid.
Read limits.documentsRegime before rendering a quota, because
limits.documentsPerPeriod is null in every regime but quota (three of them
in the entitlements, and a fourth that only the catalog reports):
documentsRegime |
What it means |
|---|---|
quota |
documentsPerPeriod holds the monthly allowance. |
unlimited |
No cap and no per-document charge, subject to the fair-use terms. |
metered |
No cap; every document is billable (the pay-per-use regime, «Por consumo»). |
external |
The cap is the prepaid credit balance, not a period quota. |
quoted |
The plan is sold by quote (Águila, Jaguar): the allowance is the accepted quote’s. Only the catalog reports it (GET /v1/billing/plans and GET /v1/billing/plans/available) — a tenant on such a plan reads quota or unlimited from its quote, and quote carries the terms. |
Quota, then prepaid overage
Section titled “Quota, then prepaid overage”Document emission consumes the monthly subscription quota first, then prepaid credit lots as overage once the quota is exhausted. A subscriber who also bought prepaid bundles keeps their subscription features and uses the bundles only as extra capacity — buying prepaid never downgrades them.
A tenant with no good-standing subscription but a positive prepaid balance is
treated as the entry tier (Prepago) for as long as the balance lasts.
Plans & changes
Section titled “Plans & changes”GET /v1/billing/plan-change/preview # read-only: what this change would doPOST /v1/billing/plan-change # upgrade / downgrade / interval switchPOST /v1/billing/plan-change/sync # complete an upgrade after its intent was paidPOST /v1/billing/cancel # cancel at period endPOST /v1/billing/resumePOST /v1/billing/cancel-scheduled-changePOST /v1/billing/recovery # recover from a failed renewal- Upgrade can take effect now or at the period end (
timing: 'now' | 'period_end'). A change counts as an upgrade only when the target plan is at least as good on all four axes — price, document allowance, seats and features. That test replaces a single tier number, which two ladders made meaningless. - Upgrading now over a live plan credits the plan being left. The whole
days that remain to the running plan’s next anniversary — counted in the
interval of the price being bought — are priced at the new plan’s daily price
(
listChargeCentimos), and the unused whole days of the plan being left, at its own list price, are credited against them in the same operation (creditCentimos,creditDays,creditPlanCode). It is not a balance: whatever the credit does not cover is paid, whatever exceeds it buysextraDaysof the new plan, and nothing is ever left over.- When a card has something to pay, the answer is
mode: 'checkout'withpaymentType: 'one_time'and apaymentIntentId: a payment intent for the difference (the days minus the credit). The amount is fixed on the intent (firstChargeCentimos, withfirstChargeNetCentimosfor the tax breakdown) and is the same figure the preview quotes. Render the Onvo SDK withpaymentType: 'one_time'; when the SDK confirms it, callPOST /v1/billing/plan-change/syncwith thepaymentIntentId. That completion creates the subscription that renews the plan with a trial of exactly the days paid — so its first invoice is the full price, fromproratedTo— makes the plan effective and retires the one it replaces. It is idempotent and the same completion the payment webhook and the reconcile run, so a lost call never leaves money in and no plan out. Its answer isactiveonce the plan is on, the intent’s own status while the payment is still settling, orprocessingwhile a concurrent completion of the same intent is running;PLAN_UPGRADE_NEEDS_REVIEW(400) means the money is in but a person has to finish the change — do not pay again. Our comprobante for the charge shows the days at the list price with the credit as a discount line. - When the credit covers the days (an annual plan moving to a monthly price)
or the difference is under the minimum charge, the answer is
mode: 'applied': the plan is already on, with a trial oftrialDays(the days to the anniversary plus the days the surplus credit bought), paid throughpaidThrough, renewing atrenewalCentimosfrom then on. No SDK, nothing to pay, no comprobante (nothing was collected). - Send
expectedChargeCentimos— thequote.chargeCentimosyou showed — and a quote that moved in between (a day boundary) answers 409PLAN_UPGRADE_QUOTE_CHANGEDinstead of charging a figure nobody saw.
- When a card has something to pay, the answer is
- A fresh subscribe (no live plan) answers
paymentType: 'subscription'with asubscriptionId: a plain subscription at the full price whose cycle starts today; callPOST /v1/billing/subscription/syncon success. - Preview first.
GET /v1/billing/plan-change/previewwrites nothing (it reads the running subscription from Onvo once) and answers what a client needs before asking the user anything: whether the change is an upgrade, when the paid period ends (effectiveAt), the instant an immediate upgrade is paid through (proratedTo— as far as the days served reach, which with a surplus credit can be months past the anniversary), which add-ons the target plan would cover, and thequoteof upgrading now:chargeCentimos(what the card pays),chargeNetCentimos,listChargeCentimos,creditCentimos,creditDays,creditPeriodDays,creditPlanCode,creditInterval,days,periodDays,extraDays,trialDays,anniversary,paidThrough,renewalCentimosandwaived. Do not classify the change on the client.planCodemust be a self-service plan (PLAN_NOT_SELECTABLEotherwise) andinterval, when sent,monthoryear(BILLING_INTERVAL_INVALID). The dates and the quote arenullwhen the period end could not be established — offer no timing choice then. When the quote iswaived(the difference is under the minimum charge), asking fornowapplies the plan on the spot (mode: 'applied') and nothing is charged. - A checkout does not stay payable forever. An upgrade’s intent carries
expiresAt(one hour): its days were counted from today, so do not leave the Onvo SDK payable past it — start the change again. A subscription checkout paid on a subscription older than the one on record answersSUBSCRIPTION_SUPERSEDED. - Anything else is scheduled for the period end, including a lateral move between ladders that trades documents for seats. Nobody loses access by being scheduled: the current plan runs to the end of the period already paid for, and charging today would mean cancelling and recreating the subscription, throwing those paid days away.
- Interval switch on the same plan (monthly ↔ annual) is always scheduled.
- Cancel is cancel-at-period-end — features survive until
currentPeriodEnd. The exception is a subscription already suspended for non-payment: there is no paid period left to run out, so cancelling ends it immediately and the card stops being retried. - An active contract plan can’t self-serve change (
PLAN_CHANGE_CONTACT_SALES). - A contract plan is asked for with
POST /v1/billing/plan-requests(expected volume, people, contact, needs);GET /v1/billing/plan-requestslists the company’s requests andPOST /v1/billing/plan-requests/:id/withdrawtakes an open one back. One open request at a time (409PLAN_REQUEST_ALREADY_OPEN), a few per day (429). - The EmiteCR team answers with a quote.
GET /v1/billing/quoteslists the company’s quotes,GET /v1/billing/quotes/:id/documentreturns a quote’s document exactly as it was sent, andPOST /v1/billing/quotes/:id/acceptaccepts it. Accepting binds the company, so it takes bothbilling:manageandlegal:accept, and the body carries the same declaration as accepting the Terms:authority: true(falseanswers 400LEGAL_AUTHORITY_REQUIRED) and thecapacityit is made in,holder,legal_representativeorauthorized(any other value answers 400LEGAL_CAPACITY_REQUIRED). With no live plan, or one in dunning, the answer is a checkout at the quote’s price (mode: 'checkout',paymentType: 'subscription'; callPOST /v1/billing/subscription/synconce it is paid), and the quote becomes accepted when the payment is verified; over a live list plan the change is scheduled for the period end (mode: 'scheduled'). A quote that can no longer be accepted answers 409QUOTE_EXPIREDorQUOTE_NOT_OPEN. - A quote may carry a minimum term: while it binds,
POST /v1/billing/cancelanswers 409PLAN_COMMITMENT_ACTIVEwith the date, andquote.commitmentActivein the entitlements says so beforehand. An annual quoted plan is told 30 days before it renews.
Recovering from a failed renewal
Section titled “Recovering from a failed renewal”When paymentRecovery is set, POST /v1/billing/recovery opens the way back. It
answers one of two things:
mode |
What happened | What to do |
|---|---|---|
checkout |
A new subscription to the plan the tenant had was created, unpaid. | Render the Onvo SDK with the returned ids, then call POST /v1/billing/subscription/sync with its subscriptionId. |
recovered |
The charge had already been collected — by the gateway’s own retry, or by a checkout paid earlier — and the plan was restored. | Nothing to pay. Re-read the entitlements. |
Recovery never charges the subscription that failed a second time. The new one
is charged the full price of the period (firstChargeCentimos), its period
starts the day it is paid, and confirming it retires the failed subscription,
which is what stops its retries. No paid day is lost to the new period: a renewal
is attempted when the paid period ends, so service already paid for had run out.
A recovery checkout carries expiresAt (one hour after it was opened). The
failed subscription keeps being retried until the new one is paid, so do not
leave the Onvo SDK payable past that instant — ask for a new one. Choosing a plan
with POST /v1/billing/plan-change while paymentRecovery is set is a recovery
too, and its response carries the same expiresAt.
| Error | When |
|---|---|
NOTHING_TO_RECOVER |
The subscription is not past_due or unpaid. |
RECOVERY_PLAN_UNAVAILABLE |
The plan cannot be sold again: it is neither a self-service plan (a retired code counts as the plan that replaced it) nor a quoted plan with its quote still in force — a quoted plan, Águila or Jaguar, is sold again on that quote. Offer the available plans instead. |
Add-ons
Section titled “Add-ons”GET /v1/billing/addon-quote?addon=audit|whatsapp # what switching it on would chargePOST /v1/billing/audit-addon # { enabled, expectedChargeCentimos? }POST /v1/billing/whatsapp-agent-addon # { enabled, expectedChargeCentimos? }An add-on rides on a subscription: it needs a plan in good standing and a saved
card. The entitlements say what there is to offer — addonsCoveredByPlan lists
the add-ons the plan already includes (nothing to sell), and addons carries the
lifecycle of the ones the tenant holds.
Switching one on charges the saved card in that same request — there is no checkout in between — so ask for the quote first and show it:
| Field | Meaning |
|---|---|
chargeCentimos |
What the card is charged now, IVA included: the whole days left to the plan’s next monthly anniversary. 0 when waived. |
chargeNetCentimos |
The base of that charge. The IVA is the remainder. |
days / periodDays |
Days being bought, out of the days of the plan’s current monthly window. |
paidThrough |
When those days run out — the add-on’s first renewal. |
renewalCentimos |
What every renewal charges: a full month, IVA included. |
waived |
The days cost less than the minimum charge, so they are not charged. |
Send chargeCentimos back as expectedChargeCentimos when enabling. If the
purchase would charge any other amount — the quote moves when a day boundary is
crossed — it is refused with ADDON_QUOTE_CHANGED and nothing is collected; ask
for the quote again. From paidThrough on, the add-on renews every month at
renewalCentimos.
Switching one off stops the renewal, not the service: the add-on stays available until the end of the period already paid for, and switching it back on inside that period charges nothing. It can be switched off whatever state the plan is in, including suspended.
| Error | When |
|---|---|
NO_ACTIVE_SUBSCRIPTION |
There is no plan in good standing to attach it to. |
ADDON_REQUIRES_SUBSCRIPTION |
The tenant is on prepaid credits, with no subscription. |
ADDON_ALREADY_INCLUDED |
The plan already includes the feature. |
NO_PAYMENT_METHOD_ON_FILE |
There is no usable saved card. |
ADDON_QUOTE_CHANGED |
expectedChargeCentimos is no longer what would be charged. |
ADDON_PAYMENT_FAILED |
The card declined. Nothing was charged and the add-on is off. |
ADDON_PURCHASE_IN_PROGRESS |
An earlier purchase of this add-on is still settling. Retry in a few minutes — it is never charged twice. |
ADDON_UNKNOWN |
The addon query parameter is not audit or whatsapp. |
Prepaid credits
Section titled “Prepaid credits”POST /v1/billing/prepaid # start a one-time purchasePOST /v1/billing/prepaid/sync # confirm after the embedded paymentGET /v1/billing/prepaid-lotsGET /v1/billing/paymentsPrepaid lots are minted idempotently on confirmed payment and expire on a
schedule (with reminder emails). They’re consumed as overage per the quota model
above. A lot with granted set to true was a courtesy from the EmiteCR team:
it carried no charge, and otherwise works the same.
POST /v1/billing/prepaid hands back the open intent of the same bundle for an
hour (a refresh, a double click) instead of minting another. A SINPE Móvil
is asynchronous: once the buyer presses «Continuar» in the SDK the intent reads
processing until the transfer lands, Onvo refuses a card on it, and a new
checkout mints a fresh intent. When the buyer already started one for this
bundle within the last 24 hours, the answer also carries pendingPayment
(paymentIntentId, startedAt): tell them to wait if they sent the transfer —
the payment-intent.succeeded webhook credits the lot when it lands — instead
of letting them pay the same bundle again. The same field rides on the
one_time answer of POST /v1/billing/plan-change.
Payments
Section titled “Payments”Payments run through Onvo Pay (Costa Rican gateway). Card data is collected by Onvo’s embedded SDK iframe and tokenized — EmiteCR only ever handles opaque ids, never card numbers. You don’t build a card form.
Demo tenants are blocked from checkout (BILLING_NOT_AVAILABLE_IN_DEMO).