Check in at the door
Scan and admit
A till reads a pass's code and admits the holder. This guide sets the pass's check-in rules and shows the till calls. You need a pass: make one with issue on purchase.
Set the rules
single admits a pass once. Paste the pass id into the path.
curl -X PUT "https://passbook.mobile/api/v1/passes/0193a1b2-7c00-7000-8000-0000000000c1/check-in" \ -H "Authorization: Bearer $PASSBOOK_KEY" \ -H "Content-Type: application/json" \ -d '{ "rules": { "mode": "single" }}'import { PassBook } from '@passbook/sdk';const pb = new PassBook({ apiKey: process.env.PASSBOOK_KEY ?? '' });await pb.passes.checkInRules.update('0193a1b2-7c00-7000-8000-0000000000c1', { rules: { mode: 'single' } });Read them back with the rules.
Find the code
A till reads the code the pass's barcode carries. It is passJson.barcodes[0].message in the pass detail; the QR on the pass encodes it.
Call the till
A till call needs a key bound to a terminal, and names the terminal in x-passbook-device. Terminals belong to Scanning in an organization: a sandbox has none. Its key gets 422 DEVICE_REQUIRED without the header and 404 TERMINAL_NOT_FOUND with one. Run these with a till key from your organization.
import { PassBook } from '@passbook/sdk';const pb = new PassBook({ apiKey: process.env.PASSBOOK_KEY ?? '' });// A terminal key names its device on every call.const headers = { 'x-passbook-device': 'door-1' };const input = { code: 'PB-4F7K-92QX', method: 'camera' as const };const seen = await pb.terminal.resolve( { idempotencyKey: crypto.randomUUID(), input, clientTs: Date.now() }, { headers },);console.log(seen);const admitted = await pb.terminal.act( { idempotencyKey: crypto.randomUUID(), input, clientTs: Date.now(), actionId: 'auto' }, { headers },);console.log(admitted);scan/resolve shows what a code would do and records nothing. scan/actions with actionId: "auto" applies the pass's check-in rule. Every call takes its own idempotencyKey, so a retry from a flaky connection is safe.
Undo a scan
POST /scan/scans/{scanId}/undo reverses an admit made by mistake, inside the undo window and only for scans the same key made. See the terminal reference.
Result
The rules read back as you set them. Open the pass's downloadUrl: the test preview shows the pass the till would read.