Your chat platform or your own server asks your shop for a link. The link opens your website signed in as the customer of a phone number, for 24 hours. This page is the full reference. For what it does and how to switch it on, see Shop in WhatsApp with your chatbot. For a Libromi chatbot, see Set up chat shopping links in Libromi.
Call it from a server or a chat platform only. Never call it from a browser, and never put the secret in a web page or an app.
The request
POST {API address}
Content-Type: application/json
The API address is on Shop › WhatsApp › Chat shopping links. It has the form https://{api host}/api/chat/v1/sites/{site}/sessions, where {site} is your website's number.
Authenticate in one of two ways.
Sign a request
Recommended whenever your platform can run code. Send two headers:
X-QC-Timestamp: <the current Unix time, in seconds>
X-QC-Signature: sha256=<signature>
- Take the exact bytes of the JSON body you send.
- Join the timestamp, a dot and the body:
timestamp + "." + body.
- Compute HMAC-SHA256 of that text with the secret as the key, written as lowercase hex.
- Send it as
sha256= followed by the hex. The sha256= prefix is required.
Sign the bytes you send. Changing the JSON after signing, even its spacing or key order, breaks the signature. A request more than 5 minutes from our clock is refused, and the same signed request is accepted only once in 10 minutes, so sign every request anew.
curl (bash)
SECRET='qcs_…'
URL='https://api.example.com/api/chat/v1/sites/42/sessions'
TS=$(date +%s)
BODY='{"phone":"+971501234567","name":"Arjun","intent":"shop"}'
SIG=$(printf '%s.%s' "$TS" "$BODY" | openssl dgst -sha256 -hmac "$SECRET" -hex | sed 's/^.* //')
curl -sS -X POST "$URL" \
-H "Content-Type: application/json" \
-H "X-QC-Timestamp: $TS" \
-H "X-QC-Signature: sha256=$SIG" \
-d "$BODY"
Node.js (18 or later)
import crypto from 'node:crypto';
async function chatLink(url, secret, payload) {
const body = JSON.stringify(payload);
const ts = Math.floor(Date.now() / 1000).toString();
const sig = crypto.createHmac('sha256', secret).update(`${ts}.${body}`).digest('hex');
const res = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'X-QC-Timestamp': ts, 'X-QC-Signature': `sha256=${sig}` },
body,
});
return { status: res.status, data: await res.json() };
}
PHP
$body = json_encode(['phone' => '+971501234567', 'name' => 'Arjun', 'intent' => 'shop']);
$ts = (string) time();
$sig = hash_hmac('sha256', $ts . '.' . $body, $secret);
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $body,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json', "X-QC-Timestamp: $ts", "X-QC-Signature: sha256=$sig"],
]);
$answer = json_decode(curl_exec($ch), true);
Python
import hashlib, hmac, json, time, urllib.request
def chat_link(url: str, secret: str, payload: dict) -> dict:
body = json.dumps(payload, separators=(",", ":")).encode()
ts = str(int(time.time()))
sig = hmac.new(secret.encode(), ts.encode() + b"." + body, hashlib.sha256).hexdigest()
req = urllib.request.Request(url, data=body, method="POST", headers={
"Content-Type": "application/json", "X-QC-Timestamp": ts, "X-QC-Signature": "sha256=" + sig})
with urllib.request.urlopen(req) as r:
return json.load(r)
Simple key
For chat platforms that can only add a fixed header. Switch on Allow simple key (no signature) on the card first, then send:
Authorization: Bearer <secret>
A simple key is limited to 120 links a minute per shop, and anyone who sees the header can make links, so prefer signing when you can. If a request has an X-QC-Signature header at all, the signature is checked and the key is ignored.
The body
| Field | Required | What to send |
|---|
phone | Yes | The customer's number with its country code: +971501234567, or the same digits without + (8 to 15 digits, not starting with 0). A local number starting with 0 is refused. Send only a number your platform has verified, such as the WhatsApp sender's number |
name | No | The chat profile name, up to 100 characters. Used only when a new customer is created |
locale | No | en, ar or another language your website offers |
intent | No | shop (the default), checkout or reorder |
path | No | For shop: where to land, a path on your website such as /collections/fruits. It must start with exactly one /, up to 512 characters. Without it, the home page opens |
lines | For checkout | 1 to 50 lines, each {productId, variantId, quantity}. variantId is optional. quantity is above zero, with up to 3 decimals for weighed products |
referralCode | No | A customer's referral code, up to 64 characters. A new customer joins through it |
externalRef | No | Your own reference, such as the conversation number, up to 191 characters. It is kept with any order placed in that session |
A body is at most 32 KB.
| Intent | Opens |
|---|
shop | The website, at path or the home page |
checkout | The checkout with the lines. Lines that cannot be bought are left out and listed in unavailableLines. If none can be bought: 422 line_unavailable |
reorder | The checkout with the lines of the customer's last order that can still be bought, up to what can be ordered. None: 422 nothing_to_reorder |
Which customer. The account your website's phone sign-in finds for that number. A new number creates a customer, phone verified, even when your shop takes no new sign-ups. A removed customer, one waiting for your approval, or a staff account gets 403 customer_blocked.
The answer
200
{
"url": "https://shop.example.com/wa/3q2-7wEXAMPLEtokenEXAMPLEtokenEXAMPLEtok",
"expiresIn": 600,
"customer": { "isNew": true },
"unavailableLines": [
{ "index": 1, "productId": 123, "code": "out_of_stock", "message": "This product is out of stock." },
{ "index": 2, "productId": 124, "code": "quantity_exceeds_max", "message": "Fewer of this product can be ordered.", "maxQuantity": 2 }
],
"referral": { "applied": true }
}
url: send it to the customer as a button or link. It works once, for 10 minutes, and only on your shop.
customer.isNew: whether this request created the customer.
unavailableLines: only for checkout lines that were left out. Codes: unknown, unavailable, out_of_stock, quantity_exceeds_max (with maxQuantity).
referral: only when you sent a referralCode. {applied: true}, or {applied: false, reason, message} with a reason such as invalid, self, disabled or existing_customer.
Link previews do not use the link up.
Errors
Every error is {code, message}, sometimes with more fields.
| Status | code | Meaning |
|---|
| 401 | bad_signature | A signature or timestamp header is missing or malformed, or the signature does not match |
| 401 | stale_timestamp | X-QC-Timestamp is more than 5 minutes from our time. Sync your server clock |
| 401 | replayed | The same signed request was already received in the last 10 minutes |
| 401 | simple_key_disabled | You sent a simple key, but Allow simple key (no signature) is off |
| 401 | bad_key | The simple key is missing or does not match |
| 403 | disabled | Chat shopping links are switched off, or there is no secret |
| 403 | customer_blocked | This customer cannot shop here, with a reason such as removed, not_approved or staff_account |
| 404 | none | Unknown website, or the website is not live |
| 413 | payload_too_large | The body is over 32 KB |
| 422 | invalid_request | The body is malformed, with errors by field. A phone that is not a number with its country code shows e164 |
| 422 | invalid_phone | A local number starting with 0, or a number your shop cannot use |
| 422 | path_invalid | path is not a path on your website |
| 422 | line_unavailable | checkout: no line can be bought, with the details under lines |
| 422 | nothing_to_reorder | reorder: no earlier order with products that can be bought |
| 429 | rate_limited | Too many requests, with retry_after in seconds and a Retry-After header |
Limits
| Limit | |
|---|
| Links per shop | 600 a minute with signed requests, 120 a minute with a simple key, counted separately |
| Links per phone number | 10 a minute |
| Refused requests (401) | 30 a minute from one address. After that every request from it gets 429 until the minute ends. Accepted requests never count |
What happens next
Opening the link signs the customer in on your website for 24 hours, never extended. See what the customer gets.
Orders from these sessions have the source WhatsApp (web). The order webhooks carry a chat block, {"external_ref": "…", "channel": "whatsapp_web"}, with your externalRef, so your platform can match the order to the chat. It is null for other orders. See Order events.
When your WhatsApp is connected, the customer also gets your WhatsApp order updates on the chat's number. Free text goes out for 24 hours from when the link was made; after that, only approved templates.
Security
- Keep the secret on your server or in your platform's secret storage. Never log it, and never log the full link: log
externalRef instead.
- Send only phone numbers your platform has verified. Whoever opens the link is signed in as that customer.
- Send each link only to that customer.
- Rotate the secret if it may have leaked; the old one keeps working for 24 hours. Revoke it at once if it did.