# Chatrixa developer documentation (full) Machine-readable index: https://chatrixa.com/llms.txt OpenAPI 3 specification: https://chatrixa.com/developer-api.yaml Authentication: `Authorization: Bearer ` on every request. --- # Quickstart Send your first WhatsApp one-time passcode in five minutes. ## 1. Create an API token In the Chatrixa dashboard, open **Developer Tools → Access Tokens** and generate a token. The token identifies your organization — keep it on your server and never ship it to browsers or mobile apps. Choose **Full access**, or **Specific permissions** and tick only what your integration calls — this guide needs **Send and verify OTP codes** (`otp:send`). Each endpoint's required scope is listed in the API reference and in [Authentication](/developers/guides/authentication). Tokens created before scopes existed keep full access. A call without the scope it needs gets `403 API_KEY_SCOPE_MISSING`. ## 2. Prepare an AUTHENTICATION template WhatsApp requires OTP messages to use an **AUTHENTICATION-category template**: 1. In Chatrixa, go to **Templates** and create a new template with category **Authentication** (Meta fixes the body text; you choose the language and the code-delivery button, usually *Copy code*). 2. Wait for Meta to approve it, then **sync templates** in Chatrixa. When you have exactly one approved authentication template you don't need to reference it by name — `/otp/send` picks it automatically. ## 3. Send a code ```bash curl -X POST https://chatrixa.com/api/otp/send \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{"phone": "+14155552671"}' ``` Response: ```json { "statusCode": 200, "code": "SENT", "message": "Verification code sent.", "data": { "phone": "+14155552671", "template": "otp_login_code", "language": "en_US", "expires_in": 300, "message_id": "wamid.HBgLMTQxNTU1..." } } ``` ## 4. Verify the customer's code ```bash curl -X POST https://chatrixa.com/api/otp/verify \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{"phone": "+14155552671", "code": "482913"}' ``` Response: ```json { "statusCode": 200, "code": "VERIFIED", "message": "Phone number verified.", "verified": true } ``` That's the whole flow — Chatrixa generates the code, delivers it, stores only a hash, and enforces expiry, cooldowns, and attempt limits for you. ## Next steps - [OTP API](/developers/guides/otp) — every parameter, error code, and limit - [Downloads](/developers/plugins) — ready-made store plugins and SDKs - [API Reference](/developers/api) — the full platform API --- # Authentication The platform API authenticates with **organization API tokens** sent as HTTP Bearer tokens: ``` Authorization: Bearer YOUR_API_TOKEN ``` ## Creating tokens In the Chatrixa dashboard open **Developer Tools → Access Tokens** (`/developer-tools/access-tokens`) and click *Generate*. A token: - is bound to your **organization** — every API call acts on that organization's contacts, templates, and WhatsApp account - does not expire, but can be revoked at any time from the same screen - carries the API access you chose when creating it (see *Scopes* below) — treat it like a password ## Scopes A token holds a list of **scopes** that limit what it can do. When you generate a token you choose *Full access* (the default) or *Specific permissions*. **Tokens created before scopes existed keep full access**; nothing changes for them. | Scope | Grants | |---|---| | `*` | Everything (full access) | | `messages:send` | `POST /send`, `/send/template`, `/send/media` | | `contacts:read` | `GET /contacts` | | `contacts:write` | `POST /contacts`, `PUT` and `DELETE /contacts/{uuid}` | | `contact_groups:read` / `contact_groups:write` | the same split for `/contact-groups` | | `canned_replies:read` / `canned_replies:write` | the same split for `/canned-replies` | | `templates:read` | `GET /templates`, `GET /templates/{uuid}` | | `templates:write` | `POST /templates`, `POST /templates/sync`, `PUT` and `DELETE /templates/{uuid}` | | `otp:send` | `POST /otp/send`, `POST /otp/verify` | | `otp:read` | `GET /otp/usage` | `:write` does not include `:read`; tick both if an integration needs both. Give each integration only what it needs: a store plugin that only sends OTP codes needs just `otp:send`. You can change a token's scopes at any time from **Access Tokens** without replacing the token. A request without the required scope is refused: ```json { "statusCode": 403, "code": "API_KEY_SCOPE_MISSING", "message": "...", "required_scope": "contacts:write" } ``` ## Where to keep it Tokens belong on servers only: - ✅ your backend, a store plugin's server-side settings, CI secrets - ❌ browser JavaScript, mobile apps, public repositories All official Chatrixa plugins follow this rule: the shopper's browser talks to the store's own backend, and only the store backend talks to Chatrixa. ## Checking a token ```bash curl https://chatrixa.com/api/verify -H "Authorization: Bearer YOUR_API_TOKEN" ``` Returns `200` when the token is valid and the subscription is active. The body includes a `scopes` array (`["*"]` for full access). This endpoint needs no scope. ## Failure modes | Status | Meaning | |---|---| | `401` | Token missing, revoked, or wrong | | `403` | Token valid, but the subscription is inactive, WhatsApp is not connected, or the token lacks the scope the endpoint needs (`API_KEY_SCOPE_MISSING`) | | `429` | Endpoint rate limit hit (OTP endpoints: 30 sends/min, 60 verifies/min per token) | --- # OTP API Two endpoints implement a complete phone-verification flow. Chatrixa generates the code, delivers it over WhatsApp, stores only a SHA-256 hash, and verifies the customer's submission — your integration never handles raw codes. ## Prerequisites - An approved **AUTHENTICATION-category** WhatsApp template, synced into Chatrixa (see [Quickstart](/developers/guides/quickstart)) - An [API token](/developers/guides/authentication) - An active subscription and a connected WhatsApp account ## Send a code `POST https://chatrixa.com/api/otp/send` ```json { "phone": "+14155552671", "template": "otp_login_code", "language": "en_US", "length": 6, "expires_in": 300, "first_name": "Jane", "email": "jane@example.com" } ``` | Field | Required | Description | |---|---|---| | `phone` | yes | International format; normalised to E.164 server-side | | `template` | no | AUTHENTICATION template name. Omit to auto-select your most recent approved one — every organization gets the default `ramz_otp` template created automatically on WhatsApp connect | | `language` | no | Exact or prefix match (`en` matches `en_US`) | | `length` | no | 4–8 digits, default 6 | | `expires_in` | no | 60–1800 seconds, default 300 | | `first_name` / `last_name` / `email` | no | Used if a new contact is created for this phone | Success (`200`): ```json { "statusCode": 200, "code": "SENT", "message": "Verification code sent.", "data": { "phone": "+14155552671", "template": "otp_login_code", "language": "en_US", "expires_in": 300, "message_id": "wamid.HBgLMTQxNTU1..." } } ``` ## Verify a code `POST https://chatrixa.com/api/otp/verify` ```json { "phone": "+14155552671", "code": "482913" } ``` Success (`200`): ```json { "statusCode": 200, "code": "VERIFIED", "message": "Phone number verified.", "verified": true } ``` Codes are **single-use**: after one successful verification the same code is rejected with `EXPIRED`. ## Result codes | HTTP | `code` | Meaning | |---|---|---| | 200 | `SENT` | Code generated and delivered | | 200 | `VERIFIED` | Code correct; phone confirmed | | 401 | `INVALID_CODE` | Wrong code — attempts remaining | | 402 | `INSUFFICIENT_CREDITS` | Allowance and prepaid credits exhausted — see [Ramz pricing](/developers/guides/ramz-pricing) | | 410 | `EXPIRED` | Code expired, already used, or never sent | | 422 | `NO_AUTH_TEMPLATE` | No approved AUTHENTICATION template found | | 429 | `RESEND_COOLDOWN` | Called again within 60 s for the same phone | | 429 | `SEND_LIMIT_REACHED` | More than 5 sends per hour for the same phone | | 429 | `MAX_ATTEMPTS` | 5 wrong verifications — request a new code | | 502 | `DELIVERY_FAILED` | WhatsApp could not deliver the message | ## Abuse protection (built in) Per organization + phone number: - 60-second resend cooldown, maximum 5 sends per hour - Maximum 5 verification attempts per code - Codes stored only as SHA-256 hashes with strict TTL Per API token: - `/otp/send` throttled to 30 requests/min - `/otp/verify` throttled to 60 requests/min ## Recommended integration pattern 1. Your **frontend** collects the phone number and calls **your backend**. 2. Your backend calls `/otp/send` (the API token never leaves your server). 3. The customer types the code from WhatsApp into your frontend. 4. Your backend calls `/otp/verify` and unlocks the action when `verified: true`. This is exactly what the downloadable [store plugins](/developers/plugins) do for WooCommerce, OpenCart, and PrestaShop. --- # Template Messages Send an approved WhatsApp template (for example an invoice with a PDF) with `POST /api/send/template`. ## Send a template ```bash curl -X POST https://chatrixa.com/api/send/template \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "phone": "+14155552671", "template": { "name": "invoice_ready", "language": { "code": "en" }, "components": [ { "type": "header", "parameters": [ { "type": "document", "document": { "link": "https://files.example.com/INV-1001.pdf", "filename": "INV-1001.pdf" } } ] } ] }, "reference": "INV-1001", "recipient_reference": "+14155552671", "idempotency_key": "invoice-1001" }' ``` The `template` object is sent to the WhatsApp Cloud API as you give it. `phone`, `template.name` and `template.language` are required. The last three fields are optional — see below. Response: ```json { "statusCode": 200, "data": { "success": true, "data": { "messages": [{ "id": "wamid.HBgM..." }] } }, "request_id": "3f0c2a6e-1d1b-4d55-9a37-6f3f5f8a2b10" } ``` `data.success` is `false` when WhatsApp refused the message. The HTTP status is still `200` in that case. ## Buttons with a dynamic link When the template has a URL button whose link ends with `{{1}}` (see [Managing Templates](/developers/guides/managing-templates)), each send gives that ending in a `button` component. WhatsApp adds it to the end of the button's fixed URL. Template button: `https://pay.example.com/link/{{1}}`. Send: ```json "template": { "name": "payment_link", "language": { "code": "en" }, "components": [ { "type": "body", "parameters": [ { "type": "text", "text": "TCK-1001" }, { "type": "text", "text": "12.500" } ] }, { "type": "button", "sub_type": "url", "index": "1", "parameters": [ { "type": "text", "text": "AbC123" } ] } ] } ``` The customer's button opens `https://pay.example.com/link/AbC123`. - `index` is the button's position among **all** the template's buttons, counting from `0`, in the order `GET /api/templates/{uuid}` returns them. Quick-reply buttons are always stored first, whatever order you created the buttons in: a template created with `[URL, QUICK_REPLY]` has the quick reply at `0` and the URL button at `"1"`. - Send only the ending, not the whole link. Percent-encode special characters (space → `%20`, `|` → `%7C`). - Leaving out the `button` component for a dynamic URL button makes WhatsApp refuse the message (`data.success: false`). - Static URL buttons (no `{{1}}`) need no component. - With `idempotency_key`, a different ending counts as a different request for Marketing and Utility templates, the same as a different body parameter. ## Request id Every call that reaches this endpoint, also a refused one, gets a `request_id`. It is in the response body **and** in the `X-Request-Id` header. Keep it in your logs and quote it when you contact support: it points to the audit record of that call. Do not put personal data (names, phone numbers, e-mail addresses) in `reference`: it is stored as you send it. Use an invoice or order number. The audit record keeps only keyed fingerprints and small values: the template name and language, a fingerprint of the phone, the file host, a fingerprint of the file link, the file extension, and your `reference`. It never keeps your API token, the message text, the phone number, the filename or the file link (signed links stay private). Records are deleted after **180 days**. Calls refused before they reach the endpoint (wrong token `401`, suspended account `403 ORGANIZATION_SUSPENDED`, rate limits) get no `request_id`. ## Owner guard: `recipient_reference` The guard is **opt-in**. Send the phone number or the Chatrixa contact `uuid` that you believe owns the document. When it does not match the recipient of `phone`, **nothing is sent**: ```json { "statusCode": 422, "code": "TEMPLATE_RECIPIENT_MISMATCH", "message": "The recipient does not match recipient_reference. Nothing was sent.", "request_id": "3f0c2a6e-1d1b-4d55-9a37-6f3f5f8a2b10" } ``` - A phone number has **one** reading. With `+` or `00` it is international (`+96550000001`, `00965 5000 0001`). Without them it is a national number of the recipient's country (`5000 0001` for a Kuwaiti recipient). `96550000001` without `+` is therefore *not* read as a Kuwaiti number. Arabic or Persian digits, spaces, dashes and right-to-left marks are fine. - Any other value must be the `uuid` of an **existing** Chatrixa contact that has this phone number. A uuid for a phone that has no contact yet does not match. - The guard only helps when you take `recipient_reference` from the invoice (or order) record itself, separately from the value you put in `phone`. If both come from the same variable, a mix-up changes both and the guard cannot see it. If `recipient_reference` is present it must be a non-empty string (or number) of at most 255 characters, or the call is refused with `400`. It is never ignored. ## Safe retries: `idempotency_key` Give each send a unique key, for example `invoice-1001`: 1 to 255 characters, letters, digits, `.`, `_`, `:` or `-`. Anything else is a `400`. Keys belong to your **organization**: all your API keys share them. | Call | Result | |---|---| | Same key, same request | `200` with the first result, `"idempotent_replay": true` and `original_request_id`. Nothing is sent again. | | Same key, other request (other `phone`, template, language, document, or — for non-authentication templates — other parameters such as the invoice number or amount) | `409 TEMPLATE_IDEMPOTENCY_KEY_REUSED`. Nothing is sent. | | Same key while the first call is still running | `409 TEMPLATE_IDEMPOTENCY_IN_PROGRESS` with `original_request_id`. Retry a little later. | | Same key after the first call ended without a known result: a timeout or lost connection while calling WhatsApp, a WhatsApp server error (5xx), an unexpected answer, or a call still not finished after 10 minutes | `409 TEMPLATE_IDEMPOTENCY_OUTCOME_UNKNOWN` with `original_request_id`. Do **not** retry with the same key: check whether the customer got the first message (support can look up `original_request_id`), then send again with a new key if needed. | Only when WhatsApp refuses the first send outright (`data.success: false` with a 4xx error that is not temporary, for example `131026` or a template error), or Chatrixa refuses it before calling WhatsApp, is the key freed: you can fix the problem and retry with the **same** key. After a timeout, a 5xx, an HTTP 408, or an error WhatsApp marks as temporary (`is_transient`, or codes `1`, `2`, `131000`, `131016`, `133004`) the message may already have been delivered, so the key stays taken (`TEMPLATE_IDEMPOTENCY_OUTCOME_UNKNOWN`). For **authentication** (OTP) templates the parameters are not part of the request comparison, because a short code must never be stored even as a fingerprint: the same key with another code returns the first result. Use a new key for every new code. To be safe, Chatrixa compares parameters only for a template it knows is **Marketing or Utility in exactly the language you send** (synced in Chatrixa). Any other template is treated like an authentication one. Media links (document, image, video, carousel cards) are always compared. If the send record cannot be updated at the wrong moment (for example a database outage right after a call), a key can stay blocked as in progress or unknown. Use a new key then. The replayed `data` is partial: it carries `success`, the WhatsApp message id and only the chat's `id`, `wam_id`, `status` and `created_at` — never the message content. A key whose first call is older than the 180-day retention window is forgotten: using it again sends again. If the call carries `recipient_reference` or `idempotency_key` and Chatrixa cannot record it, nothing is sent and the answer is `503 TEMPLATE_SEND_AUDIT_UNAVAILABLE` (retry later). Calls without these fields are sent as before. To create, edit, delete or sync templates from your own system, and to be notified when WhatsApp approves, rejects or re-categorises one, see [Managing templates](/developers/guides/managing-templates) and [Webhooks](/developers/guides/webhooks). ## Errors | Status | `code` | Meaning | |---|---|---| | 400 | — | Invalid input; see `errors`. | | 401 | — | Missing or wrong API token. | | 403 | — / `ORGANIZATION_SUSPENDED` | No active subscription, WhatsApp not connected, or account suspended. | | 403 | `API_KEY_SCOPE_MISSING` | The token lacks `messages:send` (see `required_scope`). | | 409 | `TEMPLATE_IDEMPOTENCY_KEY_REUSED`, `TEMPLATE_IDEMPOTENCY_IN_PROGRESS`, `TEMPLATE_IDEMPOTENCY_OUTCOME_UNKNOWN` | See *Safe retries*. | | 422 | `TEMPLATE_RECIPIENT_MISMATCH` | See *Owner guard*. | | 503 | `TEMPLATE_SEND_AUDIT_UNAVAILABLE` | A guarded call could not be recorded; nothing was sent. | --- # Managing Templates via API Create, edit, delete and sync your WhatsApp message templates with the same API token you use for sending, and get a webhook when WhatsApp approves, rejects, pauses or re-categorises one. All endpoints are under `https://chatrixa.com/api` and use `Authorization: Bearer YOUR_API_TOKEN`. Templates are identified by their Chatrixa `uuid`. | Method and path | What it does | |---|---| | `GET /api/templates` | List templates. Optional filters: `status`, `category`, `language`, `name`. | | `GET /api/templates/{uuid}` | One template with its components, rejection reason and quality. | | `POST /api/templates` | Create a template and submit it to WhatsApp. | | `PUT /api/templates/{uuid}` | Edit the components of a template. | | `DELETE /api/templates/{uuid}` | Delete one language, or all languages with `?all_languages=true`. | | `POST /api/templates/sync` | Pull your templates from WhatsApp. | Success responses are `{ "statusCode": 200, "data": { ... } }` (`201` on create). Errors are `{ "statusCode": 409, "code": "TEMPLATE_NAME_TAKEN", "message": "...", "errors": { ... } }`; `errors` is present for field validation failures. A template that belongs to another organization is always `404 TEMPLATE_NOT_FOUND`. Write endpoints (`POST`, `PUT`, `DELETE`, `sync`) are limited to **30 requests per minute per API token**; beyond that you get `429` with a `Retry-After` header. ## Create a template ```bash curl -X POST https://chatrixa.com/api/templates \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "order_update", "language": "en_US", "category": "UTILITY", "body": { "text": "Your order {{1}} has shipped", "example": ["1001"] }, "footer": { "text": "Thanks for shopping with us" }, "buttons": [ { "type": "URL", "text": "Track", "url": "https://example.com/track" } ] }' ``` The response is `201` with the stored template, usually `"status": "PENDING"`. WhatsApp reviews it; you learn the result from a webhook (below) or by polling `GET /api/templates/{uuid}`. Rules checked before anything is sent to WhatsApp (`422 TEMPLATE_VALIDATION_FAILED`, with `errors` per field): - `category` is `MARKETING`, `UTILITY` or `AUTHENTICATION`. - `name` is 1 to 512 characters of lowercase letters, digits and underscores. - `body.text` is required unless the category is `AUTHENTICATION`. - `message_send_ttl_seconds` for `MARKETING` is between 43200 (12 hours) and 2592000 (30 days). - Media headers (IMAGE, VIDEO, DOCUMENT) and carousels are **not supported yet**. Use a TEXT header or none. - URL buttons: at most 2 per template, button text up to 25 characters, URL up to 2000 characters starting with `https://` or `http://`. See *Buttons with a dynamic link* below. - `COPY_CODE` sample code (`example`) is at most 15 characters. ### Buttons with a dynamic link A URL button can end with a variable, so each message opens a different link — for example a payment link created by your own system: ```json "buttons": [ { "type": "URL", "text": "Pay now", "url": "https://pay.example.com/link/{{1}}", "example": "AbC123" } ] ``` WhatsApp's rules, checked before anything is sent: - Only **one** variable, written `{{1}}`, at the **very end** of the URL. - The website domain is fixed. You cannot pass a whole URL per message, only its ending: `https://{{1}}` is refused. Put the part of your links that never changes in `url`. - `example` is **required** with `{{1}}`: a realistic ending that WhatsApp's reviewers can open, as a string. No spaces. Quick-reply buttons are always stored before the other buttons, so check the button order with `GET /api/templates/{uuid}` before you send. You fill in the ending each time you send the template. See *Buttons with a dynamic link* in [Template Messages](/developers/guides/template-messages). If the same name and language already exists in your account you get `409 TEMPLATE_NAME_TAKEN` and nothing is sent to WhatsApp. WhatsApp's own duplicate error returns the same code. When WhatsApp rejects the content, `422` carries WhatsApp's message in `message`. ## Edit a template `PUT /api/templates/{uuid}` **replaces the components**: send the full body, header, footer and buttons you want. The template goes back to `PENDING` for review. Anything you leave out is removed or reset to its default — for AUTHENTICATION templates that means `add_security_recommendation` (default `true`) and `code_expiration_minutes` (default `5`), so send them again if you changed them. - Only `APPROVED`, `REJECTED` and `PAUSED` templates can be edited. Otherwise `409 TEMPLATE_NOT_EDITABLE`. - `name` and `language` cannot change, and neither can the category of an approved template (`422`). - WhatsApp limits how often a template can be edited. When it refuses, you get `429 TEMPLATE_EDIT_RATE_LIMITED` with a `Retry-After` header. Retry later. - The default OTP template (`ramz_otp`) is managed by Chatrixa and cannot be edited. ## Delete a template `DELETE /api/templates/{uuid}` deletes that language only. `DELETE /api/templates/{uuid}?all_languages=true` deletes every language of the same name (WhatsApp deletes by name). The response lists what was removed: ```json { "statusCode": 200, "data": { "deleted_uuids": ["9b1e7f44-3c1a-4d0e-8f1b-2a7c5d6e8f90"] } } ``` The default OTP template (`ramz_otp`) cannot be deleted (`409 TEMPLATE_NOT_EDITABLE`). ## Sync `POST /api/templates/sync` pulls your WhatsApp account's templates. It creates the ones Chatrixa does not have, refreshes status and category, and never deletes. Response: `{ "statusCode": 200, "data": { "created": 2, "updated": 1, "unchanged": 14 } }`. One sync per organization per 60 seconds: a second call returns `429 TEMPLATE_SYNC_THROTTLED` with `Retry-After`. A sync that fails does not start the wait. ## Errors | `code` | Status | Meaning | |---|---|---| | `TEMPLATE_NOT_FOUND` | 404 | No such template in your organization. | | `TEMPLATE_VALIDATION_FAILED` | 422 | Invalid fields (`errors`), or WhatsApp rejected the content. | | `TEMPLATE_NAME_TAKEN` | 409 | Name and language already exist. | | `TEMPLATE_NOT_EDITABLE` | 409 | Status does not allow edits, or a protected platform template. | | `TEMPLATE_EDIT_RATE_LIMITED` | 429 | WhatsApp refused a too-recent edit. Retry later. | | `TEMPLATE_SYNC_THROTTLED` | 429 | A sync ran less than 60 seconds ago. | | `TEMPLATE_WHATSAPP_NOT_CONNECTED` | 422 | Connect your WhatsApp account first. | | `TEMPLATE_UPSTREAM_PROVIDER_ERROR` | 502 | WhatsApp could not be reached or failed. Safe to retry. | ## Template webhooks Subscribe an endpoint in **Settings → Webhooks** (`https://chatrixa.com/settings/webhooks`) to these events (or to `template.*`): | Event | Fires when | |---|---| | `template.status_updated` | The stored status changes (PENDING to APPROVED, REJECTED, PAUSED, DISABLED, ...). | | `template.category_updated` | The stored category changes (for example WhatsApp re-categorises UTILITY to MARKETING, which changes price and opt-in rules). | No event fires when nothing changed, so WhatsApp retries and duplicate deliveries are silent. Each delivery is signed with HMAC-SHA256 in the `X-Chatrixa-Signature` header (`sha256=` of the raw body, using your webhook secret). ```json { "event": "template.status_updated", "event_id": "6f0e9a3e-5a39-4d26-9d2a-0a8f7c1b2d11", "delivered_at": "2026-11-09T10:15:01Z", "organization_id": 42, "data": { "template": { "uuid": "9b1e7f44-3c1a-4d0e-8f1b-2a7c5d6e8f90", "meta_id": "1234567890", "name": "order_confirmation", "language": "en_US", "status": "REJECTED", "category": "UTILITY" }, "change": { "field": "status", "previous": "PENDING", "new": "REJECTED", "reason": "INVALID_FORMAT" }, "source": "meta_webhook", "occurred_at": "2026-11-09T10:15:00Z" } } ``` - `change.field` is `status` or `category`. `change.reason` is WhatsApp's reason when it gave one, else `null`. - `source` is `meta_webhook` (WhatsApp told us) or `sync` (a sync found the difference). - `template` is the state **after** the change. New fields may be added; ignore keys you do not know. - `event_id` is new for every delivery; deduplicate on it. Ordering is best effort, so compare `occurred_at` and treat the latest `template` as the truth. The full request and response schemas are in the [OpenAPI spec](https://chatrixa.com/developer-api.yaml). --- # Targeting contacts: groups vs tags vs segments Chatrixa has three ways to pick a set of contacts. They look alike in the dashboard, but they work differently. This guide explains each one, how a campaign uses them, and what the public API can do today. ## The three concepts | | Groups | Tags | Segments | |---|---|---|---| | What it is | A manual list of contacts | A tag you apply to contacts | A saved filter that updates itself | | How a contact joins | You add the contact to the group | You attach the tag | The contact matches the filter rules | | Can a contact be in many? | Yes | Yes | Yes (a contact can match many segments) | | Who maintains it | You, or the platform for system groups | You | The rules, automatically | | Where you manage it | Contacts, or the groups API | Chat and Contacts (web app) | Contacts, saved filters (web app) | ### Groups A group is a list you control. Add a contact, remove a contact, and the list changes. A contact can be in several groups. Two groups are **system groups**. The platform maintains them, and users cannot rename, delete, or remove contacts from them: - **Unsubscribed** — contacts who opted out of messages. You cannot remove contacts from it by hand. - **Failed campaign** — the group that receives contacts whose campaign message failed, when your organization has set one up. ### Tags A tag is a short name, for example `VIP` or `Kuwait`. You attach tags from the chat or from the contact profile. Tags are shown as **Tags** everywhere in the product. A contact can have many tags. When you select several tags in a campaign, you choose how they combine: - **any** — contacts that have at least one of the selected tags - **all** — contacts that have every selected tag ### Segments A segment is a saved set of filter rules. It updates itself: when a contact starts or stops matching the rules, the segment changes with it. There are two kinds. - **Saved segments** — you create them from the filters on the Contacts page (groups, tags, country, language, created date, last activity, and so on). - **Smart segments** — built in. They are always available: - New this week - New this month - Inactive for 30 days - Inactive for 90 days - Blocked contacts - Tagged contacts (has at least one tag) - Country known - Language known "New this week" starts on your organization's first day of the week, in your organization's timezone. The default is Sunday; an organization can use Monday instead. The setting is `metadata.week_start` on the organization (`sunday` or `monday`; anything else means Sunday). The Tagged, Country known and Language known smart segments use segment definition version 2. The keys they use (`has_tags`, `country_known`, `language_known`) exist only in version 2, and for now they are read-only: you cannot save your own segment with them yet. ## How campaigns use them A campaign has **one audience**. You pick one of these: | Audience | Who receives the campaign | |---|---| | All | Every contact that can be messaged | | Groups | Contacts in one or more selected groups | | Tags (any or all) | Contacts that match the selected tags | | Segment | Contacts that match one segment | | Specific | A list of up to **500 contacts** | Things to know: - **Reachable count.** The count shown in the campaign form is the number of contacts the campaign can reach now. It leaves out contacts who opted out (unsubscribed). The number is cached for a short time, so it can lag a little behind a change. - **Segment rules are frozen when you schedule the campaign.** A draft keeps only a reference to the segment. When you schedule the campaign, the segment's current rules are copied into the campaign. After that, changes to the segment do not change this campaign. For a campaign scheduled for the future, the recipient list is created when the send time is reached, from the frozen rules. Contacts who start matching before the send time are included. Contacts who stop matching are not. Opted-out contacts are always excluded. - **Specific lists are capped at 500 contacts.** A "Create campaign" link from the Contacts page carries up to 100 contacts. You can add more in the campaign form, up to 500. For a bigger audience, use a group, a tag, or a segment. ## What the public API can manage today The public API (`/api`, Bearer token (a secret key you send in the Authorization header), see the [Authentication guide](/developers/guides/authentication)) covers groups and contacts. It does **not** have campaign endpoints, tag endpoints, or segment endpoints. Groups, from [`developer-api.yaml`](/developer-api.yaml): - `GET /api/contact-groups` — list groups (paginated: results come in pages) - `POST /api/contact-groups` — create a group (`name`) - `PUT /api/contact-groups/{uuid}` — rename a group - `DELETE /api/contact-groups/{uuid}` — delete a group Contacts: - `GET /api/contacts`, `POST /api/contacts` - `PUT /api/contacts/{uuid}`, `DELETE /api/contacts/{uuid}` So you can prepare group lists through the API. Tags, segments, and campaign audiences are set up in the web app. ## Practical pattern 1. Use the API to create the groups you need, for example `Spring offer`. 2. Add the contacts to the group in the web app. 3. Open the campaign in the web app, choose **Groups**, and pick the group. 4. Check the reachable count before you schedule. ## Related guides - [Quickstart](/developers/guides/quickstart) - [Template Messages](/developers/guides/template-messages) - [API Reference](/developers/api) --- # Webhooks Chatrixa pushes events to your HTTPS endpoint as they happen: messages, delivery status, contacts, groups, auto-replies, calls and template changes. Configure endpoints in **Settings → Webhooks** (`https://chatrixa.com/settings/webhooks`, organization owners only). Every delivery is signed, sent from a background queue (a slow endpoint never slows Chatrixa down), retried on failure and protected by a circuit breaker. ## Envelope Every delivery is a `POST` with `Content-Type: application/json` and this body: ```json { "event": "contact.created", "event_id": "6f0e9a3e-5a39-4d26-9d2a-0a8f7c1b2d11", "delivered_at": "2026-11-09T10:15:01+00:00", "organization_id": 42, "data": { } } ``` | Field | Meaning | |---|---| | `event` | Dotted event name, see the catalogue below. | | `event_id` | UUID shared by every endpoint that receives this event. Deduplicate on it. | | `delivered_at` | When Chatrixa produced the delivery (ISO 8601). | | `organization_id` | Your organization. | | `data` | The event payload. New keys may be added; ignore keys you do not know. | Headers: `X-Chatrixa-Signature`, `X-Chatrixa-Event`, `X-Chatrixa-Event-Id`, `X-Chatrixa-Delivered-At` and `User-Agent: Chatrixa-Webhooks/1.0`, plus any static headers you configured on the endpoint. ## Verify the signature `X-Chatrixa-Signature` is `sha256=` followed by the hex HMAC-SHA256 of the **raw request body** using the signing secret shown once when you create the endpoint. Verify before parsing the JSON and compare in constant time. ```php $raw = file_get_contents('php://input'); $expected = 'sha256=' . hash_hmac('sha256', $raw, $secret); if (!hash_equals($expected, $_SERVER['HTTP_X_CHATRIXA_SIGNATURE'] ?? '')) { http_response_code(401); exit; } ``` ```js const crypto = require('crypto'); // Use a raw-body parser (express.raw) so the bytes are exactly what was signed. const expected = 'sha256=' + crypto.createHmac('sha256', secret).update(rawBody).digest('hex'); const ok = crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(req.get('X-Chatrixa-Signature') || '')); ``` ## Delivery, retries and the circuit breaker - Answer with any `2xx` within your endpoint's timeout (default 5 s, configurable 0.5 to 30 s). Anything else (non-2xx, timeout, connection error) is a failed attempt. - A failed delivery is attempted up to **5 times**, after 30 s, 2 min, 10 min, 1 h and 6 h. - After **10 consecutive failed deliveries** the endpoint's circuit opens: new events are recorded as skipped, not sent, until you reset the circuit on the endpoint's page. - Each attempt is listed on the endpoint's page with status, HTTP code and latency. - Delivery is at least once; use `event_id` to ignore duplicates. Ordering is best effort. - Events of a suspended organization are not delivered. Subscribe to exact names, to a prefix such as `message.*` or `template.*`, or to `*`. ## Event catalogue | Event | Fires when | |---|---| | `message.received` | An inbound WhatsApp message arrived. | | `message.sent` | An outbound message was sent. | | `message.status.update` | A message status changed (sent, delivered, read, failed). | | `contact.created` / `contact.updated` / `contact.deleted` | A contact was created, changed or removed. | | `group.created` / `group.updated` / `group.deleted` | A contact group was created, changed or deleted. | | `autoreply.created` / `autoreply.updated` / `autoreply.deleted` | An auto-reply rule was created, changed or deleted. | | `call.event` | A WhatsApp call update from Meta arrived (connect, status, terminate). | | `template.status_updated` | A template status changed (approved, rejected, paused, ...). | | `template.category_updated` | A template category changed (for example re-classified by Meta). | | `order.paid` / `order.fulfilled` / `order.cancelled` / `order.refunded` | ShopFlow order lifecycle (ShopFlow users only). | | `webhook.test` | Sent by the "Send test event" button. | ### Payloads - `message.received`, `message.status.update` and `call.event`: `data.data` is the change object exactly as WhatsApp sent it (`field` and `value`, with `messages`, `statuses` or `calls`). - `message.sent`: `data.data` is the WhatsApp Cloud API send response plus Chatrixa's `chat` record. - `contact.*`, `group.*`, `autoreply.*`: `data` is the record as stored (`uuid`, names, timestamps, ...). `*.deleted` carries the `uuid` and deletion time. - `template.status_updated` and `template.category_updated`: ```json { "template": { "uuid": "9b1e7f44-3c1a-4d0e-8f1b-2a7c5d6e8f90", "meta_id": "1234567890", "name": "order_confirmation", "language": "en_US", "status": "REJECTED", "category": "UTILITY" }, "change": { "field": "status", "previous": "PENDING", "new": "REJECTED", "reason": "INVALID_FORMAT" }, "source": "meta_webhook", "occurred_at": "2026-11-09T10:15:00Z" } ``` `change.field` is `status` or `category`; `source` is `meta_webhook` or `sync`. Payload fields are only ever added, never renamed or removed. ## Migrating from the legacy Webhooks module The older "Webhooks" developer tool (`/developer-tools/webhooks`) posted `{ "event", "data" }` unsigned. It still works and now sends from the background queue too, with the same body. Delivery stays at most once, as before: it is retried (up to 3 attempts, 10 s, 1 min, 5 min apart) only when your endpoint could not be reached or answered `429` or `503`; any other answer is final. Each delivery carries an `X-Chatrixa-Delivery-Id` header that stays the same on every attempt, so you can drop duplicates. It is unsigned and has no delivery log. To migrate: 1. Create an endpoint in Settings → Webhooks subscribed to the same events. 2. Read the payload from `data` in the new envelope; the event names and `data` content are the same as before. 3. Verify `X-Chatrixa-Signature`, then delete the legacy URL. While both are configured you receive each event twice. --- # WhatsApp / Meta Setup for Ramz Everything you need to configure on Meta's side before sending your first one-time passcode. Done once, takes 30–60 minutes plus Meta review time. Ramz (رمز), Chatrixa’s verification product, sends codes from **your own WhatsApp Business Account (WABA)**. That matters for cost: Meta bills authentication conversations directly to your WABA at Meta's regional rates — Chatrixa credits are the platform fee only, and never mark up delivery. ## Step 1 — Meta Business Manager 1. Go to [business.facebook.com](https://business.facebook.com) and create (or use) a **Meta Business Portfolio** for your company. 2. Add your company's legal details under **Business settings → Business info** — the legal name must match your registration documents; you will need this for business verification in Step 6. ## Step 2 — Create a Meta app with WhatsApp 1. Open [developers.facebook.com](https://developers.facebook.com) → **My Apps → Create App**. 2. Choose **Business** as the app type and link it to your Business Portfolio. 3. In the app dashboard, click **Add product → WhatsApp → Set up**. This creates a **WhatsApp Business Account (WABA)** with a free test number. ## Step 3 — Add and verify your phone number 1. In **WhatsApp → API Setup**, click **Add phone number**. 2. Use a number that is **not** registered on the consumer WhatsApp app (or delete that registration first). A dedicated virtual/landline number works — it only needs to receive one verification call or SMS. 3. Verify it via the SMS/voice code Meta sends. 4. Set a **display name** that matches your brand or legal name. Meta reviews display names — generic names ("Verification", "OTP") are rejected; use your actual brand. ## Step 4 — Connect the number to Chatrixa Two options: - **Embedded signup (recommended):** in Chatrixa go to **Settings → WhatsApp** and follow the connect flow — it walks through Meta's OAuth and links the WABA automatically. - **Manual:** copy the **Phone number ID**, **WABA ID**, and a **permanent System User access token** (Business settings → Users → System users → generate token with `whatsapp_business_messaging` and `whatsapp_business_management` permissions) into Chatrixa's WhatsApp settings. ## Step 5 — Authentication template (usually automatic) OTP messages **must** use an AUTHENTICATION-category template — Meta blocks free-form messages for codes. **Chatrixa creates one for you**: the moment your number is connected, the default `ramz_otp` template is submitted to Meta automatically in English and Arabic (copy-code button, 5-minute expiry footer). Authentication templates usually approve within minutes, after which `/api/otp/send` works with no configuration. Create your own template only if you need other languages or settings — then pin it per request with the `template` parameter. 1. In Chatrixa go to **Templates → New template**. 2. Category: **Authentication**. Language: your customers' language (create one per language you need — e.g. `en_US` and `ar`). 3. Meta fixes the body text of authentication templates. You choose: - **Security recommendation** line on/off ("For your security, do not share this code") - **Code expiration** footer (set it to match the `expires_in` you'll use — default 5 minutes) - **Code delivery button**: choose **Copy code** (works everywhere) or **One-tap autofill** (Android only, requires app signature setup) 4. Submit. Authentication templates are usually approved within minutes to a few hours. 5. Back in Chatrixa, hit **Sync templates** so the approved template is available to the API. If you have exactly one approved authentication template, `/api/otp/send` picks it automatically — no configuration needed. ## Step 6 — Business verification (for production volume) Unverified businesses are limited to **250 business-initiated conversations per day** — fine for testing, not for launch. 1. In **Business settings → Security centre → Start verification**, submit your legal business name, address, and a supporting document (commercial registration, utility bill, or bank statement matching the legal name). 2. Review typically takes 1–5 business days. 3. Once verified, your messaging limit rises automatically to **1,000 conversations/day**, then scales to 10k → 100k → unlimited as you send with good quality ratings (Meta upgrades tiers automatically based on volume and quality over 7-day windows). ## Step 7 — Understand Meta's charges - Authentication conversations are billed by **Meta directly to your WABA** at per-country rates (roughly $0.006–$0.045 per conversation window; check Meta's current rate card for your markets — Gulf rates are on the lower end). - A conversation window lasts 24 h — multiple OTPs to the same number within the window count as **one** conversation. - Add a payment method to the WABA under **Billing & payments**, or messages will stop when the free tier is exhausted. ## Step 8 — Get your Chatrixa API token and go live 1. In Chatrixa: **Developer Tools → Access Tokens → Generate** (full access, or *Specific permissions* with **Send and verify OTP codes** — `otp:send`). 2. Send a test code: ```bash curl -X POST https://chatrixa.com/api/otp/send \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{"phone": "+965XXXXXXXX"}' ``` 3. Verify it: ```bash curl -X POST https://chatrixa.com/api/otp/verify \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{"phone": "+965XXXXXXXX", "code": "123456"}' ``` You're live. See [Ramz pricing & credits](/developers/guides/ramz-pricing) for how usage is billed, and the [OTP API guide](/developers/guides/otp) for every parameter and error code. ## Launch checklist - [ ] Business Portfolio created with legal details - [ ] Meta app created with WhatsApp product - [ ] Dedicated phone number added, verified, display name approved - [ ] Number connected to Chatrixa (embedded signup or manual credentials) - [ ] AUTHENTICATION template approved and synced (per language) - [ ] Business verification submitted / approved - [ ] Payment method attached to the WABA - [ ] Test OTP sent and verified end-to-end - [ ] Production traffic ramped gradually to build quality rating --- # Ramz Pricing & Credits Ramz (رمز) — Chatrixa’s verification product — is billed per **successfully delivered code** — one credit per accepted `/api/otp/send`. Verification checks (`/api/otp/verify`) are always free, and sends that WhatsApp fails to accept are refunded automatically. ## What a credit costs | Pack | Credits | Price | Per verification | |---|---|---|---| | Starter | 1,000 | $15 | $0.015 | | Growth | 10,000 | $120 | $0.012 | | Scale | 50,000 | $500 | $0.010 | Credits are prepaid, never expire, and stack — buy any pack again at any time. ## What's included free - **25 credits** are granted to every organization when it first uses Ramz — enough to integrate and test end-to-end. - **Chatrixa subscription plans include a monthly allowance** of verifications (varies by plan; your plan's allowance is shown on your Ramz usage page). Allowance is consumed before prepaid credits and resets monthly. ## Why this is cheaper than SMS-based verification Codes are delivered over **your own WhatsApp Business Account**. Meta bills authentication conversations directly to your WABA at its regional rates (fractions of a cent to a few cents, and multiple codes to the same number within 24 hours count as one conversation). Chatrixa credits are the platform fee only — there is no per-message delivery markup, which is how the effective cost lands well under SMS-based providers charging $0.05+ per verification. ## Running out When your allowance and credits are both exhausted, `/api/otp/send` returns: ```json { "statusCode": 402, "code": "INSUFFICIENT_CREDITS", "message": "..." } ``` Top up from your Ramz usage page in the Chatrixa dashboard (**Developer Tools → Ramz**). Your current balance and month-to-date usage are also available programmatically: ```bash curl https://chatrixa.com/api/otp/usage -H "Authorization: Bearer YOUR_API_TOKEN" ``` ## Notes - Billing applies per organization, across all API tokens. - Abuse controls (per-phone cooldowns, hourly caps, attempt limits) are documented in the [OTP API guide](/developers/guides/otp) and are not affected by your credit balance. - Setting up WhatsApp for the first time? Follow the [WhatsApp / Meta Setup guide](/developers/guides/whatsapp-setup). --- # WooCommerce Plugin Verify customer phone numbers at WooCommerce checkout with WhatsApp one-time passcodes. **Download:** [chatrixa-otp-woocommerce.zip](/developers/plugins/chatrixa-otp-woocommerce/download) ## What it does - Adds a *Phone verification* box under the billing fields on the classic checkout: **Send verification code → enter code → Verify** - **Login with WhatsApp** (optional): customers log in on the My Account page by entering their billing phone and the code they receive on WhatsApp — no password. Accounts are matched server-side by billing phone; administrator and shop-manager accounts are always excluded - Blocks order placement server-side until the billing phone is verified - Optionally remembers verified phones per customer account, so returning customers skip verification - Stamps verified orders with `_chatrixa_otp_verified` order meta - Your API token stays in WordPress options on the server — it is never sent to the shopper's browser ## Requirements - WordPress 5.8+ with WooCommerce 6.0+ - **Classic checkout** (the `[woocommerce_checkout]` shortcode). The block-based checkout is not yet supported — block checkouts are left unaffected, not broken. - A Chatrixa account with a connected WhatsApp number and one approved AUTHENTICATION template ## Installation 1. Download the zip above. 2. In WordPress: **Plugins → Add New → Upload Plugin**, choose the zip, install and activate. 3. Open **WooCommerce → Chatrixa OTP**. 4. Enter: - **Chatrixa URL** — e.g. `https://chatrixa.com` (or your own installation URL) - **API Token** — from Chatrixa → Developer Tools → Access Tokens (full access, or *Specific permissions* with **Send and verify OTP codes** — `otp:send`) - Optional: a specific template name/language, code length, expiry 5. Optionally enable **Login with WhatsApp**. 6. Save. The settings page shows a live connection check. ## How enforcement works The verified phone number is stored in the WooCommerce session on the **server** during the AJAX verify call. At checkout submission the plugin compares the billing phone against the session (and, when *verify once per customer* is enabled, the customer's user meta) — a shopper cannot bypass verification by manipulating the browser. ## Troubleshooting | Symptom | Fix | |---|---| | "No approved AUTHENTICATION template found" | Create an Authentication template in Chatrixa → Templates, wait for approval, sync | | Codes not arriving | Confirm the phone is a WhatsApp number in international format; check Chatrixa → Chats for the delivery status | | "Connection failed" on the settings page | Check the URL has no trailing path and the token was copied fully | | Widget not visible at checkout | Your theme must use the classic checkout shortcode, not the checkout block | --- # OpenCart Extension WhatsApp phone verification for the OpenCart 4 checkout. **Download:** [chatrixa_otp.ocmod.zip](/developers/plugins/chatrixa-otp-opencart/download) ## What it does - Injects a *Phone verification* widget under the telephone field on the default checkout - Blocks the checkout register/guest step server-side until the submitted phone number has been verified in the session - The Chatrixa API token stays in your OpenCart settings on the server ## Requirements - OpenCart 4.x with the default checkout. Third-party one-page checkouts may need the enforcement event trigger adjusted to their route. - A Chatrixa account with a connected WhatsApp number and one approved AUTHENTICATION template ## Installation 1. Download `chatrixa_otp.ocmod.zip` above. 2. In the OpenCart admin: **Extensions → Installer**, upload the zip. 3. Go to **Extensions → Extensions**, choose type **Modules**, find *Chatrixa OTP* and click **Install** (this registers the two catalog events), then **Edit**. 4. Enable the module and enter: - **Chatrixa URL** — e.g. `https://chatrixa.com` - **API Token** — from Chatrixa → Developer Tools → Access Tokens (full access, or *Specific permissions* with **Send and verify OTP codes** — `otp:send`) - Optional template name and language 5. Save. ## How it works Two events are registered on install and removed on uninstall: | Event | Trigger | Purpose | |---|---|---| | `chatrixa_otp_inject_ui` | `catalog/view/checkout/checkout/after` | Appends the widget markup and JS to the checkout page | | `chatrixa_otp_enforce` | `catalog/controller/checkout/register.save/before` | Rejects the step with a telephone-field error when the phone is unverified | The storefront AJAX endpoints are `extension/chatrixa_otp/otp/chatrixa.send` and `…chatrixa.check`; the verified number is kept in the OpenCart session, so enforcement happens server-side. **Enforcement scope:** the guard runs on the checkout register/guest step — where a phone number is entered or changed. A logged-in customer whose saved account details are reused without re-submitting that step is not re-verified; add the `enforce` event to your checkout's confirm route if you need every order re-verified. --- # PrestaShop Module WhatsApp phone verification for PrestaShop 1.7 / 8 checkout and address forms. **Download:** [chatrixaotp.zip](/developers/plugins/chatrixa-otp-prestashop/download) ## What it does - Adds a *Phone verification* widget under `phone` / `phone_mobile` fields on checkout and address forms - Rejects the customer address form server-side (via the `actionValidateCustomerAddressForm` hook) until the phone number is verified - Remembers the verified number in PrestaShop's encrypted customer cookie - The Chatrixa API token stays in your shop configuration on the server ## Requirements - PrestaShop 1.7.7+ or 8.x (1.7.7 introduced the `actionValidateCustomerAddressForm` hook used for enforcement) - A Chatrixa account with a connected WhatsApp number and one approved AUTHENTICATION template ## Installation 1. Download `chatrixaotp.zip` above. 2. In the PrestaShop back office: **Modules → Module Manager → Upload a module**, choose the zip. 3. Open the module configuration: - Enable checkout verification - **Chatrixa URL** — e.g. `https://chatrixa.com` - **API Token** — from Chatrixa → Developer Tools → Access Tokens (full access, or *Specific permissions* with **Send and verify OTP codes** — `otp:send`) - Optional template name and language 4. Save. ## How it works | Piece | Role | |---|---| | `displayHeader` hook | Registers the widget JS on `order` and `address` pages | | Front controller `module/chatrixaotp/verify` | AJAX `send` / `check` actions proxied to the Chatrixa OTP API | | `actionValidateCustomerAddressForm` hook | Adds a validation error to the phone field when it has not been verified | The verified number lives in the signed customer cookie and enforcement runs in server-side form validation, so it cannot be skipped by manipulating the widget. **Enforcement scope:** it applies whenever an address form with a phone field is submitted (new address, or editing an existing one). A returning customer who reuses an already-saved address without editing it is not re-verified. --- # SDKs Official client libraries for the OTP API. All of them are thin, dependency-free wrappers over the same two HTTP calls — pick your stack. | SDK | Requirements | Download | |---|---|---| | PHP | PHP 7.4+, curl | [chatrixa-otp-php.zip](/developers/plugins/chatrixa-otp-php/download) | | Laravel | Laravel 9–12 | [chatrixa-otp-laravel.zip](/developers/plugins/chatrixa-otp-laravel/download) | | Node.js | Node 18+ | [chatrixa-otp-node.zip](/developers/plugins/chatrixa-otp-node/download) | | Python | Python 3.8+ | [chatrixa-otp-python.zip](/developers/plugins/chatrixa-otp-python/download) | ## PHP ```php use Chatrixa\Otp\ChatrixaOtpClient; $client = new ChatrixaOtpClient('https://chatrixa.com', 'YOUR_API_TOKEN'); $sent = $client->send('+14155552671', ['expires_in' => 300]); $check = $client->verify('+14155552671', $_POST['code']); if (!empty($check['verified'])) { // phone confirmed } ``` ## Laravel ```php use Chatrixa\OtpLaravel\Facades\ChatrixaOtp; ChatrixaOtp::send('+14155552671'); if (ChatrixaOtp::verify('+14155552671', $request->input('code'))) { // phone confirmed } ``` Configure with `CHATRIXA_URL` and `CHATRIXA_API_TOKEN` in `.env` (publish the config with `php artisan vendor:publish --tag=chatrixa-config`). ## Node.js ```js const { ChatrixaOtp } = require('chatrixa-otp'); const otp = new ChatrixaOtp({ baseUrl: 'https://chatrixa.com', token: process.env.CHATRIXA_API_TOKEN }); await otp.send('+14155552671', { expiresIn: 300 }); const check = await otp.verify('+14155552671', submittedCode); if (check.verified) { // phone confirmed } ``` ## Python ```python from chatrixa_otp import ChatrixaOtp otp = ChatrixaOtp("https://chatrixa.com", "YOUR_API_TOKEN") otp.send("+14155552671", expires_in=300) result = otp.verify("+14155552671", submitted_code) if result["verified"]: ... # phone confirmed ``` ## Other stacks The API is plain JSON over HTTPS — see the [OTP guide](/developers/guides/otp) for the raw requests, or the [API Reference](/developers/api) for the full schema.