Rawi

API overview

Base URL, customer authentication, headers, response and error format, rate limits, money and date conventions, and plan limits of the Rawi customer API.

Rawi has a JSON API that the Rawi web app itself uses. This page explains the conventions of the customer API: the endpoints you can call with your own Rawi account. To browse and run individual endpoints, open the interactive API console.

ResourceLocation
Interactive console/docs/api
OpenAPI 3.1 spec/openapi.json (also from the API itself: GET /api/openapi.json)
Postman collectionRawi.postman_collection.json

Base URL

All routes live under /api on Rawi's API server; the API console is set up with the right base URL. The customer API covers access and setup, scans and reports, and your account (expert requests, billing, settings, referrals). In the API a scan is called a run (for example run_id).

Authentication

Sign-in is passwordless: you request a 6-digit code by email or SMS, verify it, and receive a Customer token (Bearer) that you send as Authorization: Bearer <token> with every request.

sequenceDiagram
    participant C as Client
    participant A as Rawi API
    C->>A: POST /auth/request-code {email}
    A-->>C: 200 {sent, expires_in, resend_in}
    Note over A: sign-in code by email or SMS
    C->>A: POST /auth/verify {email, code}
    A-->>C: 200 {token, user}
    C->>A: GET /me (Authorization: Bearer token)
    A-->>C: 200 Me
    C->>A: POST /auth/logout
    A-->>C: 204
  • The customer token comes from POST /auth/verify, the same sign-in flow as the web app.
  • A code is valid for 10 minutes, allows 5 wrong attempts, and a new code can be requested after 45 seconds.
  • Mobile sign-in (phone) and voice-call codes (channel: "voice") are available when GET /auth/options returns phone_login: true.
  • Tokens do not expire on their own; POST /auth/logout revokes the current token. Deleting your account revokes all of its tokens.

Access levels

The console and the OpenAPI spec mark each endpoint's access level:

LevelMeaning
GuestNo token needed
Free user / Pro userCustomer token; some features are limited on the Free plan (403 plan_limit)

Headers

HeaderValue
Acceptapplication/json (always, so errors come back as JSON too)
Content-Typeapplication/json for requests with a body
Accept-Languagefa (default) or en: language of messages, validation errors and localized names
AuthorizationBearer <token>

Response format

  • JSON keys are snake_case.
  • Dates are ISO-8601 in UTC (2026-11-25T10:30:00Z). Jalali display and Persian digits are the client's job. The calendar set by the Rawi team for your market only decides where monthly periods start (e.g. resets_at), not how dates are displayed.
  • Money is an integer in the currency's main unit: Toman for IRT (e.g. 1800000). Quotes and payments carry the full breakdown: base_amount − period_discount − code_discount = subtotal and subtotal + vat = total.
  • Percentages (share of voice, visibility) are 0–100 with one decimal.
  • Responses without a body are 204 No Content (logout, events, deletes).

Pagination

Customer endpoints return plain arrays; they are not paginated.

Errors

StatusBodyWhen
401{"message":"…","code":"unauthenticated"} (message in the request language)No token, or an invalid or revoked token
403{"message":"…","code":"plan_limit"}Not available on the current plan (older scan, locked AI assistant, over a count limit …)
403{"message":"…","code":"forbidden"}For example, changing an expert request that is no longer "new"
404{"message":"…"}Unknown id, or one that belongs to another account
409{"requires_confirmation":true,"reason":"rebuild_questions",…}A change that rebuilds the questions; resend with "confirm": true
422{"message":"…","errors":{"field":["…"]}}Validation error (localized; nested fields use dots: products.0.generic_name)
429{"message":"Too Many Attempts."} or {"message":"…","resend_in":32}Rate limit or sign-in code resend cooldown
502 / 503{"message":"…"}An external service (AI, SMS) is unavailable

Rate limits

EndpointLimit
POST /auth/request-code30/min per IP, plus a 45 s cooldown and at most 5 codes/min per address
POST /auth/verify30/min per IP and 5 attempts per code
POST /reports/gaps/<questionId>/suggestion20/min
POST /consultations, POST /billing/checkout10/min
POST /billing/quote30/min

Throttled routes send X-RateLimit-Limit, X-RateLimit-Remaining and, on 429, Retry-After.

Plan limits

Limits are enforced on the server and returned by GET /me (key limits):

KeyFreePro
engines["chatgpt"]["chatgpt","gemini","claude"]
questions1025
products / customers / cells1 / 1 / 13 / 2 / 4
changes_per_month25
run_frequencies["monthly"]["weekly","monthly"]
discovered_limit10null (all)
citations_fullfalsetrue
all_runsfalsetrue
ai_suggestions_per_month330

Report filters

Every /reports/* route accepts run_id (the scan), engine (all|chatgpt|gemini|claude) and cell_id (the audience). Defaults: the latest finished scan, all AI assistants of the plan and all audiences (cell_id=0). The effective values come back in context.filters. On the Free plan a non-default run_id or an AI assistant outside the plan answers 403 plan_limit.

A complete example

bash
BASE="https://…/api"   # the base URL shown in the API console

# 1. Request a code
curl -s -X POST "$BASE/auth/request-code" \
  -H "Accept: application/json" -H "Content-Type: application/json" \
  -d '{"email":"you@company.com"}'

# 2. Verify the code from your email and get a customer token
TOKEN=$(curl -s -X POST "$BASE/auth/verify" \
  -H "Accept: application/json" -H "Content-Type: application/json" \
  -d '{"email":"you@company.com","code":"123456"}' | jq -r .token)

# 3. Market overview
curl -s "$BASE/reports/overview" \
  -H "Accept: application/json" -H "Accept-Language: en" \
  -H "Authorization: Bearer $TOKEN"

Next steps

API console · Open the console