Rawi

API reference · Billing & payment gateway

Quote (period + code)

post/billing/quote
AuthenticationCustomer token (Bearer)
AccessFree user · Pro user

Customer token (Bearer) — free and paid users

Rate limit30/1min

Price breakdown for a period and optional discount code, in the caller's currency (currency field, amounts in its minor unit). An invalid code is not an error: code_valid:false + code_message. A fixed-amount code (amount_off) in another currency → code_valid:false, «این کد برای پرداخت با این واحد پول نیست.» ("This code is not valid for payments in this currency."); percent codes work in every currency.

The code's duration is counted per account (successful and refunded payments of the caller with this code):

durationPer accountcode_message when valid (fa)
first_paymentonce«با این کد، پرداخت اول {percent} درصد تخفیف دارد. از تمدید بعدی، مبلغ بدون کد حساب می‌شود.»
first_nthe first duration_n payments«این کد روی {n} پرداخت اول هر حساب {percent} درصد تخفیف دارد؛ {left} پرداخت با این کد برای شما مانده است.»
foreverevery payment with the code«با این کد، این پرداخت و هر تمدیدی که با همین کد بپردازید {percent} درصد تخفیف دارد.»

A code this account has used up → code_valid:false, code_message «این حساب سهم خود از این کد را استفاده کرده است.» ("This account has already used its share of this code."). max_uses counts successful and refunded payments with the code by customer accounts (test accounts, team accounts and the admin panel test payments are not counted); an account that already used the code (first_n, forever) is not blocked by max_uses. Reached cap → «ظرفیت استفاده از این کد پر شده است.»

Without a code, a user who signed up with an invite link and has no successful payment gets the referral first-payment discount (referral_discount_percent) only while referral_gift_enabled is on; code_message then reads «چون با لینک دعوت آمده‌اید، پرداخت اول {percent} درصد تخفیف دارد.»

Request body

FieldTypeDescription
period*stringactive period key: monthly | quarterly | yearly
codestring | nullmax 40
Examplejson
{
  "period": "quarterly",
  "code": "FOUNDERS30"
}

Responses

200 — Quote

FieldTypeDescription
periodstring
currencystringCurrency code, e.g. USD, EUR or IRT.
base_amountinteger
period_discountinteger
code_discountinteger
subtotalinteger
vatinteger
totalinteger
codestringMachine-readable code.
code_validboolean
code_messagestring
period_startstring
period_endstring
json
{
  "period": "quarterly",
  "currency": "IRT",
  "base_amount": 5400000,
  "period_discount": 540000,
  "code_discount": 1260000,
  "subtotal": 3600000,
  "vat": 360000,
  "total": 3960000,
  "code": "FOUNDERS30",
  "code_valid": true,
  "code_message": "با این کد، پرداخت اول ۳۰ درصد تخفیف دارد. از تمدید بعدی، مبلغ بدون کد حساب می‌شود.",
  "period_start": "2026-11-25T09:53:44Z",
  "period_end": "2027-02-25T09:53:44Z"
}

401 — Missing/invalid token, or a token of the wrong owner (admin token on a user route or vice versa): {"message":"…","code":"unauthenticated"} (message in the request language)

FieldType
message*string
codestring
json
{
  "message": "Please sign in to continue; your session has ended or is not valid.",
  "code": "unauthenticated"
}

422 — Validation failed (period not active)

FieldType
message*string
errors*object
json
{
  "message": "",
  "errors": {
    "email": [
      "ایمیل معتبر نیست."
    ]
  }
}

429 — Throttle 30 req/min

FieldTypeDescription
message*string
resend_inintegerSeconds until a new login code may be requested (login-code cooldown only).
json
{
  "message": "Too Many Attempts.",
  "resend_in": 0
}

curl example

bash
curl -X POST 'http://127.0.0.1:8010/api/billing/quote' \
  -H 'Accept: application/json' \
  -H "Authorization: Bearer $RAWI_USER_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{
  "period": "quarterly",
  "code": "FOUNDERS30"
}'

Try it in the console