Before you start
- API:
https://api.segmnt.cloud - Every billing call on this page uses your session cookie (the dashboard session). An API key cannot call them.
- Prices are in SAR per month, before VAT.
- The plans are Starter, Pro and Agency, but they are not on sale yet (billing is paused). The free plan is the default. A customer joins the paid-plan whitelist to ask for a paid plan.
1. The plans
GET /v1/billing/plans returns the plans and their prices.
Notes:
price.amountis in halalas (1 SAR = 100 halalas).5900halalas is 59 SAR. This is the same unit the API uses everywhere.price.currencyisSARandprice.intervalismonth.priceis before VAT. See VAT below.limitsare the plan limits (stored hours, new uploads, watched minutes, domains, projects, quality and the logo). See Usage and plan limits for what they mean.- The prices and limits come from the plan catalog. They are the same numbers you see on the site.
- This call needs the session cookie. Without it you get
401 unauthorized.
2. Start a checkout
Paid plans are not open yet. Checkout cannot start a payment and cannot change a plan: this call answers503 billing_paused. Join the
paid-plan whitelist instead.
503):
- Nothing is charged and the plan does not change. The call returns before it reaches any provider.
- Ask the customer to join the paid-plan whitelist instead of paying.
- When billing is on, checkout answers
201with the provider’s hosted page (checkoutUrl) and the customer pays with mada, Apple Pay, STC Pay or a card.planIdis then checked (a free or unknown plan gets400 invalid_request), anddiscountCodeis an optional code (see Discount codes). 503 billing_unavailable(no provider configured) and502 billing_provider_error(the provider did not answer) apply again only after paid plans go on sale.
3. Join the paid-plan whitelist
Paid plans are not on sale yet. To ask for one, record your interest with this API. It stores your intent only — no payment, no plan change.POST /v1/billing/whitelist (session cookie):
201):
planIdmust be one of the paid plans:starter,prooragency. A free or unknown plan gets400 invalid_request.emailis optional. When you omit it, we use the account owner’s e-mail.- The call is idempotent per account and plan: calling it again does not
create a second entry, and the
createdAtstays the first time. A newemailupdates the contact address. - This never charges the customer and never changes the plan.
GET /v1/billing/whitelist (session cookie) returns the account’s entries:
Discount codes
Discount codes apply at checkout, so they are not usable while billing is paused. This section is a reference for when paid plans go on sale.POST /v1/billing/checkout takes an optional discountCode. A code is applied
when it has been issued to you; creating a code is an internal segmnt action,
so this page does not show how to create one.
- A founding code gives 30% off and a referral code gives 10% off. The total discount is capped at 40%, so no code can take off more than that.
- Codes are case-insensitive and trimmed, so
founding-30andFOUNDING-30are the same code. - The code is checked before the payment provider is called. An unknown,
expired or used-up code answers
400 invalid_requestwith a clear message, so the customer is never charged the full price by accident. - The discount is applied to the plan price before VAT: VAT (15%) is charged on the discounted net, not on the full price.
- The 15% VAT invoice shows the plan line and, when a code was applied, a second negative discount line. The lines still add up to the invoice total.
- The code is counted only when a payment is confirmed. A provider retry does not count the same code twice.
- A confirmed payment stores the code on the subscription (
discount_code). - The discount is kept on every renewal for the promised number of months.
A founding code or a referral for the referrer lasts 12 months; a referral
for the new customer lasts 3 months. The first discounted payment locks the
promise on the subscription, and each later hosted payment re-applies it. Send
no
discountCodeon a renewal: the promise stored on the subscription is applied automatically. Once the window is used up, the renewal is at the full price again. - The code’s
usedcounter counts a customer once, on the first discounted payment, not once per renewal. Somax_uses = 10means 10 customers, even though each of them may pay 12 discounted months. - A locked promise is honored even when the code later expires or reaches its
cap: the customer was promised the discount. A new customer using that same
expired or used-up code is still refused with
400 invalid_request. - The 40% cap applies on every payment, including a renewal.
4. The payment that changes the plan
Billing is paused, so no provider calls this route today. A valid event that arrived anyway is acknowledged with204 and changes no plan. This section is a
reference for when paid plans go on sale.
When the customer pays, Moyasar calls
POST /v1/billing/providers/moyasar/webhook. This route is for the provider,
not for customers. It has no segmnt session; it is checked with the provider’s
own secret token.
What happens on every verified event:
- The provider’s secret token is checked with a constant-time compare.
- The webhook body is never trusted. We read the merchant invoice back from the provider API.
- The amount and currency are checked against the plan’s fixed price (plus 15% VAT when VAT mode is on).
- The payment, the 15% VAT invoice, the subscription and the account plan are written in one batch, so the event is applied once and cannot be applied half way.
204 and does not change the plan again or
extend the period.
A refund reverses an applied payment. When the provider reports a refunded
payment, the payment is recorded as refunded, the subscription is set to
canceled, and the account returns to the free plan. The invoice row is
kept: a refund is not a delete, and the fiscal sequence must stay gapless
(a ZATCA credit note is a later open point). A refund is idempotent too, so
a retried refund changes nothing.
Answers:
A verified event that does not match is refused with
400 and changes no plan.
This covers a wrong amount, a currency that is not SAR, a missing plan or
account in the invoice, an unknown plan, and an account we do not have.
5. Check the plan after payment
After a confirmed payment,GET /v1/billing/plan returns the paid plan, an
active subscription period, the new limits and your usage. The call is
documented on the Usage and plan limits page.
limitsis the paid plan’s limits (stored hours, watched minutes, domains, quality and the logo). Inlimits,nullmeans no limit.usageis your account now: stored seconds, watched minutes in the current period, and verified domains.- The new-upload and project limits are enforced, but they are not in this answer yet. See Usage and plan limits for the full limits table.
VAT
VAT is not on yet. Today VAT is off:- When VAT is off, the customer pays the plan price and the invoice shows
0VAT. - When VAT mode is on, the amount is the plan price plus 15%, and the invoice records the VAT.
unitAmount (net),
vatAmount and amount (gross, net + VAT). So the lines add up to
invoices.total when VAT mode is on.
Not live yet
- Paid plans. They are not on sale yet: billing is paused. A customer joins the paid-plan whitelist and we contact them.
- The annual plan. Only the monthly plan is planned.
- The watched-minute overage on the provider invoice. Pro and Agency are never stopped at the watched-minutes limit. The overage is recorded now (see Usage and plan limits); folding it into the payment provider’s invoice is a later step.
- The invoice PDF. The 15% VAT invoice is written, but its PDF file is not built yet.
Errors
Errors useapplication/problem+json. Use the code field in your code, not
the text. The type field links to https://docs.segmnt.cloud/errors/{code}.
Tested against the current release
Checked on 14 Oct 2026:POST /v1/billing/checkoutwith a session ->503 billing_paused(no provider is active; nothing is charged and the plan does not change).POST /v1/billing/whitelistwith a session ->201, and a second call ->201with the same entry (idempotent per plan).GET /v1/billing/whitelistwith a session ->200with the account’s rows.GET /v1/billing/planswith no session ->401 unauthorized.POST /v1/billing/checkoutwith no session ->401 unauthorized.POST /v1/billing/checkoutwith an unknown plan (billing on) ->400 invalid_request(unit test).
503 billing_paused with no provider call and no plan change, and the
whitelist is idempotent per account+plan and account-scoped. The same tests keep
the retained payment path
covered for the day paid plans go on sale: a verified invoice applies the plan
and the 15% VAT invoice, sequential invoice numbers, idempotent replay, and every
400 refusal path. The live Moyasar sandbox run needs sandbox keys, so the
end-to-end provider call is not run while billing is paused.