# VendID MRZ API — docs

Read the machine-readable zone (MRZ) of passports (TD3), ID cards (TD1) and TD2 documents. Send an image, get JSON with every ICAO 9303 check digit verified. Servers in the EU (Belgium); the image is read in memory and dropped.

HTML version: https://vend-id.com/sdk/docs · Everything in one file for AI assistants (recipes for React, Vue, Next.js, PHP, WebViews, field mapping, migration): https://vend-id.com/llms-full.txt · OpenAPI 3.1: https://github.com/kaza/vendid-passport-sdk/blob/main/openapi/openapi.yaml · Examples: https://github.com/kaza/vendid-passport-sdk

> [!WARNING]
> **Free / development tier: the first request takes ~7–10 s (warm-up).** The reading engine scales to zero when nobody uses it. The first request after a quiet spell takes ~7–10 s while it starts; after that ~0.5 s per scan. It stays warm for ~15 minutes after the last request.
>
> - Call `POST https://vend-id.com/v1/warmup` with your key when your page or app opens (see "POST /v1/warmup" below) — the engine is warm by the time the user holds up the passport.
> - Set your client timeout to 30 s or more. `mrz.js` waits 25 s per request and shows „Starting the reader…" meanwhile.
> - Paid and volume plans: always-warm engine, no cold start.

## Quickstart (60 seconds)

1. Get a free key at https://vend-id.com/sdk#get-key — it is shown at once and e-mailed. No card.
2. Run this, with the specimen passport if you have none at hand:

```sh
curl -o passport.jpg https://vend-id.com/sdk/specimen.jpg
curl https://vend-id.com/v1/mrz \
  -H "Authorization: Bearer YOUR_KEY" \
  -F "image=@passport.jpg"
```

## Keys

Send the key as `Authorization: Bearer vid_…`. A key looks like `vid_` + 32 letters and digits. We store only its hash: if you lose it, request a new one. A key in a browser page can be read by anyone who opens the page — fine for testing and for pages behind your login; for public pages call the API from your server, or let `mrz.js` send frames through your server route (`apiBase`).

## POST https://vend-id.com/v1/mrz

Body: `multipart/form-data` with the image in the field `image`, or the raw image with `Content-Type: image/jpeg` (or png, webp). Max 10 MB. A photo of the data page or a whole camera frame both work: the document is found in the image. CORS is open, so browsers on any site can call it.

```sh
# raw body instead of multipart
curl https://vend-id.com/v1/mrz -H "Authorization: Bearer YOUR_KEY" \
  -H "Content-Type: image/jpeg" --data-binary @passport.jpg
```

```js
// JavaScript (browser or Node 18+)
const form = new FormData();
form.append('image', file);              // a File or Blob
const res = await fetch('https://vend-id.com/v1/mrz', {
  method: 'POST', headers: { Authorization: 'Bearer YOUR_KEY' }, body: form,
});
const mrz = await res.json();            // 200 → fields, 422 → {error, reason}
```

```python
# Python
import requests
r = requests.post("https://vend-id.com/v1/mrz",
                  headers={"Authorization": "Bearer YOUR_KEY"},
                  files={"image": open("passport.jpg", "rb")})
print(r.status_code, r.json())
```

## Response — 200 OK

```json
{
  "format": "TD3",
  "document_type": "P",
  "issuing_state": "UTO",
  "surname": "ERIKSSON",
  "given_names": "ANNA MARIA",
  "document_number": "L898902C3",
  "nationality": "UTO",
  "birth_date": "1974-08-12",
  "sex": "F",
  "expiry_date": "2012-04-15",
  "optional_data": "ZE184226B",
  "check_digits": { "document_number": true, "birth_date": true, "expiry_date": true, "composite": true },
  "mrz": ["P<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<",
          "L898902C36UTO7408122F1204159ZE184226B<<<<<10"],
  "ms": 612,
  "specimen": true
}
```

- `format`: TD3 passport · TD1 ID card · TD2. Dates are ISO (`YYYY-MM-DD`), or `null` when the MRZ date does not exist. `sex`: `F`, `M`, `X` or empty. `ms`: time on our side. `specimen: true` only for the ICAO specimen (free, never counted).
- A 200 always has valid check digits. Warm, a read takes ~0.5 s; the first call after a quiet spell takes ~7–10 s (cold start, see the warning at the top).

## POST https://vend-id.com/v1/warmup

Wakes the reading engine so the next read is fast. Same key as `/v1/mrz`, no body. Free: never counted, never billed. CORS is open, so call it from the browser the moment your check-in page or scan screen opens.

```sh
curl -X POST https://vend-id.com/v1/warmup -H "Authorization: Bearer YOUR_KEY"
# 202 {"state":"warming","eta_ms":7000}   engine starting, ready in ~7 s
# 200 {"state":"ready","eta_ms":0}         already warm
```

```js
// when the page opens — don't wait for it
fetch('https://vend-id.com/v1/warmup', { method: 'POST', headers: { Authorization: 'Bearer YOUR_KEY' } });
```

Errors: 401 as for `/v1/mrz`; 502 `engine_unavailable` (retry, or just scan: a read wakes the engine too). Set client timeouts for `/v1/mrz` to 30 s or more.

## Errors

| Status | `error` | Meaning |
|---|---|---|
| 422 | `no_document` | No passport or ID card found in the image. |
| 422 | `no_mrz` | Document found, but not the MRZ lines (the `<<<` lines). Show the bottom of the data page. |
| 422 | `blurry` | MRZ too blurry to read. |
| 422 | `check_digits` | Read, but the check digits don't match: no result is better than a wrong one. |
| 400 | `bad_request` | No image in the request. |
| 401 | `missing_api_key` / `invalid_api_key` | No key, or a key we don't know. |
| 413 | `body_too_large` | Image over 10 MB. |
| 415 | `unsupported_image` | Not a JPEG, PNG or WebP image. Check the file; do not retry. |
| 429 | `quota_exceeded` | Abuse protection only: more than 10,000 calls in a month on one key (20× the free scans). Resets on the 1st (UTC). Running past the 500 free scans never answers 429: the key keeps working. |
| 502 | `engine_unavailable` | The reader did not answer. Retry. |

422 bodies: `{"error":"blurry","reason":"…","ms":237}`. 401 bodies carry `get_key`, 429 bodies `limit` (calls a month), `used`, `message`. Failed reads (422) are free: only reads with valid check digits count.

## mrz.js — camera drop-in

One script tag. It opens a full-screen camera view, sends frames to `/v1/mrz` until one reads, and hands you the same JSON. No build step, no dependencies, works in every current browser over HTTPS (phone or laptop webcam).

```html
<script src="https://vend-id.com/sdk/mrz.js"></script>
<button onclick="scan()">Scan passport</button>
<script>
  async function scan() {
    const r = await VendIdMrz.open({ key: 'YOUR_KEY' });
    console.log(r.surname, r.given_names, r.document_number, r.birth_date);
  }
</script>
```

| Call | What it does |
|---|---|
| `VendIdMrz.open({ key, onResult?, onError?, apiBase? })` | Camera overlay. Promise resolves with the result; rejects on a key, quota or connection error, or with `code: 'closed'` when the user closes it. „No passport? Use the specimen" reads the ICAO specimen. No answer within 25 s: the overlay says so and offers „Try again"; closing it then rejects with `name: 'VendIdMrzTimeoutError'`, `code: 'timeout'`. |
| `VendIdMrz.scanImage({ key, image, apiBase? })` | One File or Blob (e.g. from `<input type="file">`) → result. No camera. Rejects with `code` = the API error code. No answer within 25 s: rejects with `VendIdMrzTimeoutError`, `code: 'timeout'`. |
| `VendIdMrz.close()` | Closes an open overlay. |

`apiBase` (default `https://vend-id.com`): frames go to `apiBase + '/v1/mrz'`. Point it at a route on your server that adds the key, and the key never reaches the page. HTTP errors carry `err.status` and `err.body`.

## Plans and limits

- Free: 500 successful scans a month, every month, no card. Past 500 your key keeps working; we contact you about a plan. Test and staging keys never count.
- Pay as you go: €0.01 per successful scan, no monthly fee, first 500 a month free. Budget alerts at 80 % and 100 %; stop at your budget or keep going.
- Starter: €29 a month including 5,000 scans, then €0.01 per scan. Unlimited keys with usage per key; SEPA direct debit or bank transfer.
- Always warm: on paid and volume plans the engine stays warm — no ~7–10 s cold start.
- Volume (from 100,000 scans a month) or the engine on your own servers: ask for an offer.
- All plans: https://vend-id.com/sdk#mrz-plans

## VendID Passport SDK (on the device)

The same reading on the user's device — browser (JavaScript + WebAssembly), Android, iOS, Flutter and React Native; on phones also the passport chip by NFC with Passive Authentication. The package and a test licence come with your SDK request: https://vend-id.com/sdk?product=passport-sdk#get-key

---

VendID by Späti to GO KG, Vienna, Austria · [Imprint](https://vend-id.com/imprint) · [Privacy](https://vend-id.com/privacy) · [DPA](https://vend-id.com/dpa) · [Security](https://vend-id.com/security) · [Trust](https://vend-id.com/trust)
