Update a pass
Change fields, notify
Change a field on a pass you made, handle a stale version, and end the pass if the order is cancelled. You need a pass: make one with issue on purchase and keep its id and version.
Change a field
PATCH takes the fields to change under input. notify: true asks for a push to phones that have the pass.
curl -X PATCH "https://passbook.mobile/api/v1/passes/0193a1b2-7c00-7000-8000-0000000000c1" \ -H "Authorization: Bearer $PASSBOOK_KEY" \ -H "Content-Type: application/json" \ -d '{ "input": { "attendee": "Ada Lovelace" }, "notify": true}'import { PassBook } from '@passbook/sdk';const pb = new PassBook({ apiKey: process.env.PASSBOOK_KEY ?? '' });// notify pushes the change to phones that have the pass.const pass = await pb.passes.update('0193a1b2-7c00-7000-8000-0000000000c1', { input: { attendee: 'Ada Lovelace' }, notify: true,});console.log(pass.version);Paste the pass id into the path. The answer is the pass with version one higher.
Guard against a stale write
Send If-Match with the version you last read. If someone else changed the pass first, the answer is 412 VERSION_CONFLICT. In the console, add the If-Match chip and set an old version to see it.
Handle it by reading the pass again and retrying with the new version. See VERSION_CONFLICT.
Read what changed
curl -X GET "https://passbook.mobile/api/v1/passes/0193a1b2-7c00-7000-8000-0000000000c1/events" \ -H "Authorization: Bearer $PASSBOOK_KEY"import { PassBook } from '@passbook/sdk';const pb = new PassBook({ apiKey: process.env.PASSBOOK_KEY ?? '' });for await (const event of pb.passes.activity.list('0193a1b2-7c00-7000-8000-0000000000c1')) { console.log(event.kind, event.at);}The activity list shows the update and its new version, newest first. The pass detail lists every version.
Void a pass
A voided pass shows as void and scans are refused. The record and its link stay.
curl -X POST "https://passbook.mobile/api/v1/passes/0193a1b2-7c00-7000-8000-0000000000c1/void" \ -H "Authorization: Bearer $PASSBOOK_KEY"import { PassBook } from '@passbook/sdk';const pb = new PassBook({ apiKey: process.env.PASSBOOK_KEY ?? '' });const pass = await pb.passes.void('0193a1b2-7c00-7000-8000-0000000000c1');console.log(pass.status);Undo it:
curl -X POST "https://passbook.mobile/api/v1/passes/0193a1b2-7c00-7000-8000-0000000000c1/unvoid" \ -H "Authorization: Bearer $PASSBOOK_KEY"import { PassBook } from '@passbook/sdk';const pb = new PassBook({ apiKey: process.env.PASSBOOK_KEY ?? '' });const pass = await pb.passes.unvoid('0193a1b2-7c00-7000-8000-0000000000c1');console.log(pass.status);To end a pass for good, see pass lifecycle.
Result
Open the pass's downloadUrl after each call. The preview page shows the new field, and the void state after a void. Nothing is pushed in a sandbox; the preview and the activity list are the proof.