Documentation
Overview
An intent is one request of yours for the passports of one guest (or of one group). Your server creates it with the API key and gets a link for the phone and the address of its QR code. The guest opens the link, the scanner reads the passport with the phone camera, and the passport arrives in the intent. You learn of it in three ways, use any:
- a webhook: we POST each passport to the address you name in the intent;
- a request: your server asks for the intent by its id whenever it likes;
- the JavaScript library: your page shows the QR code and gets the passport the moment it is scanned.
Three things open three doors. The API key creates intents and reads everything of yours; keep it on your server. The intent id reads the passports of that one intent and nothing else; your server hands it to your own page. The link of the phone can add passports to that one intent and reads nothing.
Authentication
Send the API key in the Authorization header of every request to https://webmrz.com/v1:
Authorization: Bearer wm_live_... Requests are JSON (Content-Type: application/json) or an ordinary form; answers are JSON. Times are UTC in ISO 8601.
Create an intent
POST /v1/intents
curl https://webmrz.com/v1/intents \
-H "Authorization: Bearer wm_live_..." \
-H "Content-Type: application/json" \
-d '{
"webhook_url": "https://example.com/hooks/webmrz",
"max_passports": 2,
"reference": "booking-1042"
}' | Parameter | |
|---|---|
webhook_url | Where to POST the passports: an https address on port 443 of a public host. Optional. |
max_passports | How many passports the link takes, from 1 to 20. Default 1. With more than one the guest scans them one after another and may stop earlier ("Done, no more passports"). |
reference | Your own label, up to 200 characters: a booking number, a user id. It comes back with the intent and in every webhook. Optional. |
expires_in | Seconds the link waits to be opened, from 60 to 86400. Default 900. A link that was opened stays usable for 10 minutes after the last thing the phone did. |
return_url | An https address the phone offers as "Continue" when the guest is done. Optional. |
The answer is the intent, HTTP 201. Show qr_url as a picture (<img src>, an SVG) or send url to the guest as a link.
The intent
{
"id": "in_9fQ2mXc7Jr0aTn4vB8yKpL3sWd6ZhE1u",
"object": "intent",
"status": "completed",
"url": "https://webmrz.com/s/k3VbQ9xT2mLpA7cJrN5wYe",
"qr_url": "https://webmrz.com/qr/k3VbQ9xT2mLpA7cJrN5wYe.svg",
"max_passports": 1,
"passports_count": 1,
"reference": "booking-1042",
"webhook_url": "https://example.com/hooks/webmrz",
"return_url": null,
"device": "iPhone · Safari",
"created_at": "2026-11-27T10:00:00Z",
"expires_at": "2026-11-27T10:15:00Z",
"opened_at": "2026-11-27T10:01:12Z",
"completed_at": "2026-11-27T10:01:40Z",
"data_deleted_at": null,
"passports": [
{
"position": 1,
"scanned_at": "2026-11-27T10:01:40Z",
"document_type": "P",
"issuing_country": "UTO",
"surname": "ERIKSSON",
"given_names": "ANNA MARIA",
"document_number": "L898902C3",
"nationality": "UTO",
"date_of_birth": "1974-08-12",
"sex": "F",
"date_of_expiry": "2032-04-15",
"personal_number": "ZE184226B",
"name_truncated": false,
"mrz": [
"P<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<",
"L898902C36UTO7408122F3204153ZE184226B<<<<<16"
],
"read": { "source": "camera", "frames": 3 },
"image": {
"url": "https://webmrz.com/v1/intents/in_9fQ2.../passports/1/image",
"content_type": "image/jpeg",
"bytes": 311204
}
}
]
} status | |
|---|---|
pending | Created, the link was not opened yet. |
opened | A phone opened the link (device says which); passports may be arriving. |
completed | Every passport that was asked for is in, or the guest said there are no more, or the time ran out with at least one passport in. |
expired | The time ran out and no passport was scanned. |
canceled | You took the intent back. |
The passport
The fields are read from the two code lines at the bottom of the photo page (the MRZ, ICAO 9303) and are exactly what the code says: upper-case Latin letters, three-letter state codes. A passport reaches you only when every check digit of its code is right.
| Field | |
|---|---|
document_type | P, sometimes with a second letter the issuing state adds. |
issuing_country, nationality | Three-letter codes of the code line (ISO 3166-1 alpha-3 with the ICAO additions; Germany's single D is given as DEU). |
surname, given_names | As the code line spells them. name_truncated is true when the name did not fit the line and was cut off there. |
document_number | The passport number. |
date_of_birth, date_of_expiry | YYYY-MM-DD; null when the code gives no full date. |
sex | M, F or X (unspecified). |
personal_number | The optional field of the second line; an empty string when the passport has none. |
mrz | The two lines themselves, 44 characters each. |
read | How it was read: source is camera (with frames, the number of camera frames that agreed on the code) or file (the guest chose a photo instead of the camera). |
image | The photo of the page: fetch url with your API key. |
The same passport scanned twice into one intent is one passport.
Read, cancel, photo
GET /v1/intents/{id} | The intent with its passports. |
POST /v1/intents/{id}/cancel | The link stops working. What was scanned stays readable until it is deleted. |
GET /v1/intents/{id}/passports/{position}/image | The photo of the page, image/jpeg. |
GET /v1/intents/{id}/passports | The state and the passports without the API key, for your page: this is what the JavaScript library reads. Open to pages of any origin (CORS); no photos here. |
Webhooks
When the intent names a webhook_url, we POST to it:
passport.scannedfor each passport, with the passport and the intent as it stands;intent.completedonce, when the intent is completed.
POST /hooks/webmrz HTTP/1.1
Content-Type: application/json
webhook-id: evt_4Hn2kQ8sVb1xZc7Wm0LpTy3R
webhook-timestamp: 1795773700
webhook-signature: v1,K5oZfzN95Z9UVu1EsfQmfVNQhnkZ2pj9o9NDN/H/pI4=
{
"id": "evt_4Hn2kQ8sVb1xZc7Wm0LpTy3R",
"type": "passport.scanned",
"created_at": "2026-11-27T10:01:40Z",
"intent": { ...the intent as above... },
"passport": { ...the passport that was just scanned... }
} Answer with any 2xx within 10 seconds. Anything else is tried again after 1 and 5 minutes, half an hour, 2 and 6 hours. Redirects are not followed. An event may arrive more than once: its id stays the same.
Webhooks are signed by the Standard Webhooks scheme with the webhook secret that came with your API key (whsec_...): the signature is the HMAC-SHA256 of {webhook-id}.{webhook-timestamp}.{body} under the base64-decoded secret. Check it before you trust a request; the ready libraries do it in one call.
import { Webhook } from "standardwebhooks";
const webhook = new Webhook(process.env.WEBMRZ_WEBHOOK_SECRET); // whsec_...
app.post("/hooks/webmrz", express.raw({ type: "application/json" }), (req, res) => {
let event;
try {
event = webhook.verify(req.body, req.headers); // throws when the signature is wrong or too old
} catch {
return res.status(400).end();
}
if (event.type === "passport.scanned") {
savePassport(event.intent.reference, event.passport);
}
res.status(204).end();
}); $secret = base64_decode(substr(getenv("WEBMRZ_WEBHOOK_SECRET"), 6)); // the part after "whsec_"
$body = file_get_contents("php://input");
$id = $_SERVER["HTTP_WEBHOOK_ID"] ?? "";
$timestamp = $_SERVER["HTTP_WEBHOOK_TIMESTAMP"] ?? "";
$expected = "v1," . base64_encode(hash_hmac("sha256", "$id.$timestamp.$body", $secret, true));
$valid = abs(time() - (int) $timestamp) < 300;
foreach (explode(" ", $_SERVER["HTTP_WEBHOOK_SIGNATURE"] ?? "") as $signature) {
$valid = $valid && hash_equals($expected, $signature);
}
if (! $valid) {
http_response_code(400);
exit;
}
$event = json_decode($body, true);
JavaScript library
For your page. It needs the id of the intent and nothing else: your API key never comes near a browser.
<div id="passport"></div>
<script src="https://webmrz.com/sdk/v1"></script>
<script>
// intentId comes from your server, which created the intent with the API key
WebMRZ.mount("#passport", intentId, {
onPassport: function (passport, intent) {
console.log(passport.surname, passport.document_number);
},
onComplete: function (intent) {
console.log("all " + intent.passports.length + " passports are in");
},
onExpire: function (intent) {
console.log("the code has expired: ask your server for a new intent");
}
});
</script> WebMRZ.mount(element, intentId, options) draws the QR code with a line that follows what the phone does, and calls you back. The options: onPassport(passport, intent), onComplete(intent), onExpire(intent), onUpdate(intent), onError(error), size (the side of the code in pixels), texts (your own lines: scan, opened, progress, completed, expired). It returns an object with stop().
// one answer, no watching
WebMRZ.get(intentId).then(function (intent) { console.log(intent.status, intent.passports); });
// your own interface: no QR code is drawn, only the callbacks
var watching = WebMRZ.watch(intentId, { onPassport: fill, onComplete: close, interval: 2000 });
watching.stop();
// a promise of the completed intent
WebMRZ.wait(intentId).then(function (intent) { fill(intent.passports[0]); }); The intent id lets a page read the passports of that intent, so hand it only to the page of the person who is to see them.
Errors and limits
{
"error": {
"code": "invalid_params",
"message": "Some parameters are not valid.",
"params": { "webhook_url": "An https address on port 443 of a public host, up to 500 characters." }
}
} | HTTP | code | |
|---|---|---|
| 400 | invalid_request | The body is neither a JSON object nor a form. |
| 401 | unauthorized | No API key, or a key that does not work. |
| 404 | not_found | No such intent (or it is not yours), no such endpoint. |
| 422 | invalid_params | params names each parameter that is wrong. |
| 429 | rate_limited | More than 120 intents in a minute. |
Data and privacy
- The code of the passport is read on the phone, in the browser. The server receives the two lines and one photo of the page, checks the lines again and keeps both for you.
- Before the camera starts the guest sees who asks for the passport: the name your API key was issued to.
- Passport data and photos are deleted 24 hours after the intent ended. The intent itself stays, without them:
data_deleted_atsays when. - The scanner page loads nothing from third parties.