QMSDocs
Admin guidesIntegration webhooks
Admin
Updated 30 Nov 2026 · v1.0

Integration webhooks

BetterQ can call your own systems as things happen: when a token or appointment is requested, once it has its number, and when serving finishes. All optional.

What the webhooks do

A webhook is a message BetterQ sends to a web address you provide, so your own system is told about something the instant it happens. Nothing about the queue changes for your staff or customers — this is purely a way to plug BetterQ into the systems you already run.

The three webhooks
Token/Appointment requested
Sent the moment a customer asks for a token or books an appointment, on every channel. This one happens before the number is given out, and BetterQ waits for the reply (up to 5 seconds): it can set the customer’s priority for this visit and hand back extra details for the representative to see.
Token/Appointment issued
Sent a moment later, once the visit has its number. It carries the number itself along with the priority, the channel, the contact details and everything the customer entered. BetterQ sends it in the background and does not wait for a reply — nothing it sends back is used.
Served
Sent when a representative completes a token at their counter. Also sent in the background with no waiting — this one tells your system a visit is finished; it can’t change anything in the queue.
Note
All three webhooks are optional and independent. Leaving a web address blank simply switches that webhook off. Every request is a POST with a JSON body, and every request is signed (see below). BetterQ makes each call once — a call that fails is not tried again.
Which one do I want?
If you want to decide the customer’s priority, or show your representatives details from your own records, use the requested webhook — it is the only one BetterQ waits for. If you want to know the token number so you can message the customer yourself or file the visit in your own system, use the issued webhook. Many organisations use both.

Setting them up

Select your name at the bottom of the menu on the left, choose App Settings, then Integration Webhooks. You need the Manage organisation settings permission to see App Settings. There are three boxes — one for each webhook — where you paste the web address BetterQ should call. Fill in the one(s) you want and select Save changes at the top. You can use one, two or all three. The Learn more button beside it opens this page.

Setting
What it does
Token/Appointment requested webhook URL
Called the moment a customer asks for a token or books an appointment, before the number is given out. BetterQ waits for the reply. Leave blank to switch it off.
Token/Appointment issued webhook URL
Called once the visit has its number. Sent in the background; BetterQ does not wait for a reply. Leave blank to switch it off.
Served webhook URL
Called when a representative completes a token. Sent in the background; BetterQ does not wait for a reply. Leave blank to switch it off.
  • All three calls are always sent as a POST request, with the headers Content-Type: application/json, Accept: application/json and X-Signature — there is nothing to choose.
  • Every call times out after 5 seconds. This can’t be changed: a queue screen must never wait longer than that on an outside system.
  • Each box takes a full web address, starting with https:// (or http://), of up to 2,048 characters. Anything else is refused when you save, with a message under the box, and nothing in App Settings is saved until it is fixed.
  • Your address must be reachable over the public internet, and should answer with a success status (a 2xx) as fast as it can.
  • All three share the same signing secret, so your systems verify every call the same way.
The Integration Webhooks section of App Settings.

How requests are signed

So your system can be sure a call really came from BetterQ, every request is signed. BetterQ generates a secret for you the first time you save any webhook address — until then the section says “A signing secret is generated automatically the first time you save any webhook URL.” The secret is 64 characters long and stays hidden as dots until you select Reveal; then Copy puts it on your clipboard and Hide covers it again. Regenerate replaces it after asking you to confirm, and the old one stops working at once. Anyone who can open App Settings can reveal or regenerate it. Clearing all three addresses keeps the secret, ready for when you add one again.

On every request BetterQ takes the exact bytes of the JSON body and produces an HMAC-SHA256 using your secret. It sends the result — the letters sha256= followed by the hex digest — in a header named X-Signature:

HTTP header
X-Signature: sha256=HMAC_SHA256(your_secret, raw_request_body)

To verify a call, compute the same thing from the raw body you received and your copy of the secret, then compare the two with a constant-time check. If they don’t match, reject the request. Read the raw body before parsing it as JSON — re-serialising a parsed object can change a byte and break the check.

How the body is written
The body is compact JSON on one line. Forward slashes are written as \/ and letters outside plain English, such as £ or é, as \u codes — £ arrives as \u00a3. Any JSON reader turns these back into the right characters, but they are part of the signed bytes, which is another reason to check the signature on the raw body. Numbers that identify things, such as a queue’s id, are sent as text, and a set of answers with nothing in it is sent as an empty list, [], rather than {}.
<?php

$secret = 'paste-your-signing-secret-here';

// The raw body BEFORE decoding — the signature is over these exact bytes.
$body = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_SIGNATURE'] ?? '';
$expected = 'sha256=' . hash_hmac('sha256', $body, $secret);

if (! hash_equals($expected, $signature)) {
    http_response_code(401); // Not from BetterQ — reject it.
    exit;
}

$payload = json_decode($body, true);
Warning
Treat the secret like a password — anyone who has it could imitate BetterQ’s calls. Store it somewhere safe on your side, and update your system straight away whenever you regenerate it.

The token/appointment requested webhook

This webhook fires every time a visit begins — a walk-in token taken at the kiosk, the QR page, the website or an embedded screen, a token a staff member issues on behalf of a customer, and an appointment booking, whoever makes it. BetterQ waits for the reply (up to 5 seconds) before finishing, because the reply can decide the customer’s priority. The customer sees the screen working for that moment.

Note
Because it fires before the number is given out, this webhook does not carry a token number — there isn’t one yet. If your system needs the number, use the issued webhook instead, or as well.

What BetterQ sends

FieldWhat it is
typewalk-in for a token, or appointment for a booking.
service_categoryThe name of the service the customer chose. null on a queue that offers no separate services.
queueThe queue (line) they joined — its id (as text) and name.
custom_field_dataThe answers to the custom fields you flagged as lookup fields, keyed by each field’s slug. A lookup field the customer left blank is sent as null. A multi-choice field is sent as a list. With no lookup fields on the form, this is an empty list, []. See Custom fields.
appointment_dataFor a booking only: the name, email, mobile, date (YYYY-MM-DD) and time (HH:MM, in the queue’s own time zone) the customer entered. email or mobile is null when not given. It is null for a walk-in.
Requested — request body (walk-in)
json
{
  "type": "walk-in",
  "service_category": "Account Opening",
  "queue": { "id": "12", "name": "Main Branch" },
  "custom_field_data": {
    "national_id": "199512345678",
    "account_number": "0041233219"
  },
  "appointment_data": null
}

For an appointment booking the type is appointment and appointment_data carries the booking details:

appointment_data (bookings only)
json
"appointment_data": {
  "name": "Lim Siew Lan",
  "email": "lim.sl@example.com",
  "mobile": "+60195520034",
  "date": "2026-07-13",
  "time": "09:00"
}

What your system replies with

Reply with a 2xx status and a JSON object as the body. Both fields are optional — send an empty object, {}, and the visit simply stays Regular. Do send a body, though: an empty reply, or anything that is not a JSON object, counts as a failed call (see When calls keep failing).

Requested — expected response
json
{
  "tier": "vip",
  "customer_data": {
    "email": { "label": "Email", "value": "lim.sl@example.com" },
    "mobile": { "label": "Mobile", "value": "+60195520034" },
    "account_manager": { "label": "Account manager", "value": "Aisha Rahman" }
  }
}
Reply fieldWhat BetterQ does with it
tierOne of vip, priority or regular, written in lower case exactly like that. Sets the customer’s priority — but only where the tier is decided automatically (see the next table). Anything else, or a missing tier, leaves the visit Regular. An appointment booking is always the appointment tier — BetterQ sets that itself, so any tier you return for a booking is ignored.
customer_dataA set of entries, each with a text label and a text value, shown as the Customer record — to the representative while they serve, and on the visit’s token profile afterwards. Entries whose label or value are not plain text are dropped. Entries named mobile and email also fill in contact details the customer did not give — see How email and mobile number are handled. This works for bookings as well as walk-ins. See Serving a customer and Token profile.

When the returned priority is used

How the visit beganIs the returned tier used?
Kiosk, QR page, or websiteYes — the reply sets the priority.
Staff issuing on behalf, priority left on AutomaticYes — the reply sets the priority.
Staff issuing on behalf, priority chosen by handNo — the staff member’s choice wins.
Appointment bookingNo — an appointment is always the appointment tier, set by BetterQ.
Nothing ever goes wrong for the customer
If the webhook isn’t set up, can’t be reached, times out, answers with an error status (4xx or 5xx), or sends back anything BetterQ can’t read (including a reply larger than 10 KB), the customer is simply treated as Regular. They’re never shown an error, turned away, or made to wait longer than the 5 seconds. You can see how a visit’s priority was decided on its token profile.

The token/appointment issued webhook

This webhook fires a moment after the one above, once the visit actually has its number — for every walk-in token and every appointment booking, on every channel. It is the one to use when your own system needs to know which number the customer was given: to text them yourself, to print something, or to file the visit in your own records.

BetterQ sends it in the background and does not wait for a reply. Whatever you send back is ignored, and a call that fails changes nothing for the customer — their token is already theirs. Verify the signature the same way and answer with any 2xx.

What BetterQ sends

FieldWhat it is
token_noThe number the customer was given — the whole point of this webhook.
tierThe priority the visit ended up with: vip, priority, regular, or appointment for a booking. This is the final answer, after your requested-webhook reply and any choice a staff member made.
issued_viaHow the visit began: kiosk, qr, web, embed (an embedded screen on your own site) or operator (a staff member issuing or booking on behalf). An appointment the customer booked themselves carries the channel they booked on, such as web.
queueThe queue (line) they joined — its id (as text) and name.
service_categoryThe name of the service the customer chose. null on a queue that offers no separate services.
emailThe email address on file for the visit, or null. See How email and mobile number are handled.
mobileThe mobile number on file for the visit, or null.
custom_field_dataEverything the customer entered on the issuance form, keyed by each field’s slug — not only the lookup fields. A field they left blank is absent. A multi-choice field is sent as a list, and a tick box as "1" (ticked) or "0". If your form has more than one Mobile Number field, the number the customer gave appears under each of them. With nothing entered, this is an empty list, []. See Custom fields.
appointment_dataFor a booking only: the name, date (YYYY-MM-DD), time (HH:MM) and mode — onsite or online. It is null for a walk-in. The booking’s email and mobile are not repeated here; they are the top-level email and mobile.
More fields than the requested webhook
The requested webhook sends only the fields you flagged as lookup fields, because its job is to identify the customer. This one sends every answer the customer gave, because its job is to record what happened. You do not need to flag anything for it.
Issued — request body (walk-in)
json
{
  "token_no": "0207",
  "tier": "vip",
  "issued_via": "kiosk",
  "queue": { "id": "12", "name": "Main Branch" },
  "service_category": "Account Opening",
  "email": "lim.sl@example.com",
  "mobile": "+60195520034",
  "custom_field_data": {
    "national_id": "199512345678",
    "account_number": "0041233219",
    "reason_for_visit": "Open a new account"
  },
  "appointment_data": null
}

For an appointment booking the tier is always appointment, and appointment_data carries the booking details:

Issued — request body (appointment)
json
{
  "token_no": "9004",
  "tier": "appointment",
  "issued_via": "web",
  "queue": { "id": "12", "name": "Main Branch" },
  "service_category": "Mortgage Advice",
  "email": "lim.sl@example.com",
  "mobile": "+60195520034",
  "custom_field_data": { "national_id": "199512345678" },
  "appointment_data": {
    "name": "Lim Siew Lan",
    "date": "2026-07-13",
    "time": "09:00",
    "mode": "onsite"
  }
}
Tip
The date and time are given in your queue’s own timezone — the same ones the customer saw when they booked.

How email and mobile number are handled

BetterQ may need to reach the customer — to text them their token number (where text delivery is switched on for the queue), to email or text an appointment confirmation, and to send a service review invitation afterwards. It works out the mobile number and email for a visit in a fixed order.

Key concepts
First, what the customer gave
The mobile number and email the customer entered themselves — a Mobile Number or Email question on the issuance form (on the kiosk, the web page or an embedded screen), or the phone and email typed when booking an appointment.
Then, your reply’s customer_data
If the customer left a detail blank, BetterQ looks for a mobile or an email entry inside your requested webhook reply’s customer_data and uses its value. So your system can supply contact details BetterQ wouldn’t otherwise have — for example a kiosk walk-in you recognised only by an ID number.
Note
These details are kept with the visit when it is created, and are only ever used to message the customer. They never affect the tier, and a customer with no number and no email is simply never messaged — the visit is unaffected. Sending them by text also needs text messaging to be set up for your organisation.

The served webhook

This webhook fires when a representative completes a token from their counter screen. It tells your system the visit is done and sends the details of what happened. BetterQ makes the call quietly in the background — completing a token is never held up waiting for you — and it ignores the reply, so just verify the signature the same way and answer with any 2xx.

Not every finished visit sends it
The served webhook is not sent when a supervisor marks a token complete from the token list, or when a token is cancelled, closed as a no-show or expired at the end of the day. If your system needs to know about those, check the visit on its token profile or in the Token List report.
FieldWhat it is
token_noThe customer’s token number.
repWho served the customer — their representative id (as text), name and email.
queueThe queue the visit belonged to — its id (as text) and name.
typewalk-in or appointment.
service_categoryThe name of the service. null when there is none.
customers_custom_field_dataThe customer’s answers to your lookup fields only, keyed by slug — the same fields the requested webhook sends. An empty list, [], when there are none.
reps_custom_field_dataEverything the representative filled in on their side, keyed by slug. A tick box is "1" or "0". An empty list, [], when there is nothing.
appointment_dataFor an appointment only: the booking’s name, email, mobile, date (YYYY-MM-DD) and time (HH:MM, in the queue’s own time zone). null otherwise.
Served — request body
json
{
  "token_no": "0207",
  "rep": { "id": "4", "name": "Nadeesha Perera", "email": "nadeesha@example.com" },
  "queue": { "id": "12", "name": "Main Branch" },
  "type": "walk-in",
  "service_category": "Account Opening",
  "customers_custom_field_data": { "national_id": "199512345678" },
  "appointment_data": null,
  "reps_custom_field_data": { "outcome_note": "Verified NIC" }
}
Corrected answers
A representative who served a customer can correct their answers, both while serving and afterwards. The served webhook sends the answers as they stand when the token is completed, so a correction made before then is included. It is sent only once — a correction made after completion is not sent to you.

Run your own messaging instead

You don’t have to use BetterQ’s built-in text messaging at all. If you’d rather send everything yourself — with your own text or email provider, your own wording and your own sending numbers — the webhooks give your system every moment it needs, including the token number. Leave the text-messaging (SMS) credentials blank in the SMS Delivery section of App Settings and drive it all from your side.

Key concepts
When the number is given out
The issued webhook carries the token number together with the customer’s email and mobile, so you can text or email the number yourself, in your own wording, from your own provider — the moment the customer takes it.
At completion — the full picture
The served webhook carries the token number, the service, the representative and the captured fields, so you can send a thank-you, a receipt, or a link to your own review or feedback form from your own system.
At the very start — if you need to decide something
The requested webhook fires before the number exists, so it cannot tell you the number. Use it only when you want to set the customer’s priority or put details from your records in front of the representative.
Make sure you have a number to send to
The issued webhook sends you whatever contact details are on file for the visit — its email and mobile fields — so a customer who typed either one can be messaged from your side straight away. Where the form asks for neither, identify the customer another way (such as an ID number) and look their details up in your own system. Appointment bookings carry the email and mobile the customer entered when booking.
Turn off what you’re replacing
So customers aren’t contacted twice, switch off the BetterQ features you’re taking over: leave the SMS credentials blank in the SMS Delivery section of App Settings, and turn off the built-in Service review if you send your own review link — otherwise BetterQ still emails its own review invitation whenever an email is on file.

A worked example

Here is a complete receiving endpoint for the Token/Appointment requested webhook — it checks the signature, looks the customer up, and replies with a tier and some details for the representative. The curl tab shows how to fire a correctly-signed test request at it from your own machine.

SECRET='paste-your-signing-secret-here'
BODY='{"type":"walk-in","service_category":"Account Opening","queue":{"id":"12","name":"Main Branch"},"custom_field_data":{"national_id":"199512345678"},"appointment_data":null}'

# Sign the exact bytes of the body, the same way BetterQ does.
SIGNATURE="sha256=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$SECRET" -hex | sed 's/^.*= //')"

curl -X POST https://your-system.example.com/betterq/requested \
  -H 'Content-Type: application/json' \
  -H "X-Signature: $SIGNATURE" \
  --data "$BODY"
Tip
The issued and served webhooks use the same signature check — verify them the same way, then simply reply with a 2xx. BetterQ ignores what they send back.

When calls keep failing

Calls to your systems can fail — the address might be down, unreachable, or rejecting the signature. A one-off failure is nothing to worry about, and it never affects a customer. But a run of them in a single day usually means the connection needs attention.

BetterQ counts failed calls to the Token/Appointment requested webhook through the day. A call counts as failed when your address can’t be reached or takes longer than 5 seconds, answers with an error status (4xx or 5xx), or replies with something that is not a JSON object or is larger than 10 KB. Once the day’s failures pass a limit, it emails your main administrator once — and only once that day, however many more fail — asking someone to check the connection. You set that limit as the Webhook failure threshold on the System configuration screen (5 a day unless changed, so the email goes out on the 6th failure). The count resets at midnight in your organisation’s time zone.

For as long as the day’s failures are over that limit, every administrator also sees a Token/Appointment requested webhook is failing alert under Needs attention on the Admin dashboard and in their bell. Unlike the email, it stays up for the rest of the day, even after the connection is fixed, and clears when the count resets at midnight.

Only the requested webhook is counted
The issued and served webhooks are sent in the background and nothing BetterQ does depends on their answer, so failures there are not counted and never trigger the email. The requested webhook is counted because BetterQ waits on it: when it goes quiet, customers stop being given the priority your records say they should have. If you rely on the issued or served webhook, watch for failures on your own side.
Tip
While a webhook is failing, walk-in customers are simply treated as Regular and messages about their visit don’t reach your system — but the queue itself carries on exactly as normal.
Was this page helpful?