Skip to content

Bridge messages

Documents @snap4id-sdk/embed-protocol 1.0.0 · protocol 1.0

Each message travels in the envelope { v: 1, id, type, payload, replyTo? }; the tables describe payload. Receivers drop unknown payload keys, never reject them. The React Native component sends and answers all of these for you; a native host handles them itself. The JSON Schemas ship in @snap4id-sdk/embed-protocol under schema/.

Sent by the Snap4ID page to your app.

Always the first message. The page says who it is and which trust mode Snap4ID has on file for you; answer with the host hello within the handshake time, or the page shows handshake_timeout.

Page → hostAlways firstAnswer: host hello

Field Type Required Description
protocolVersion string (protocol version) yes The page’s protocol version (1.0). Same major ⇒ compatible.
page object yes What the page was opened for.
page.partnerId string (non-empty) yes Your partner id, from the URL.
page.jobId string (job id) Set when the page was opened to resume a job (/embed/{partnerId}/job/{jobId}).
trustMode "verifier" | "backend" verifier (the page has the receipt checked: Snap4ID, or your verifier server) or backend (your own backend checks and unlocks). Check it matches your app; absent when your configuration is unavailable (then embed_unavailable follows).
productIds object The product the page sells: your in-app purchase item, one store product id per store, as you gave them to Snap4ID at onboarding. Look up the price of the id for your store and answer with price.result after your hello. Absent when your configuration is unavailable.
productIds.ios string (non-empty) Your App Store product id.
productIds.android string (non-empty) Your Google Play product id.
{
"v": 1,
"id": "a3c5e1f0-4d2b-4c8e-9f1a-2b3c4d5e6f70",
"type": "hello",
"payload": {
"protocolVersion": "1.0",
"page": {
"partnerId": "your-partner-id"
},
"trustMode": "verifier",
"productIds": {
"ios": "pl.example.app.idphoto",
"android": "pl.example.app.idphoto"
}
}
}

A new job exists. Store its id if you want to reopen the job later (/embed/{partnerId}/job/{jobId}).

Page → hostNo reply

Field Type Required Description
jobId string (job id) yes The new job’s id.
{
"v": 1,
"id": "0b8f5c2e-7a41-4d3b-9e6c-000000000002",
"type": "job.created",
"payload": {
"jobId": "eu-6f1c2b9e-3d4a-4b8f-9c2e-1a7d5e3f0b42"
}
}

The user pressed the order button. Buy productId in the store bound to paymentRef and answer with one purchase.result carrying replyTo = this message’s id. One request per paymentRef.

Page → hostAnswer: purchase.result

Field Type Required Description
jobId string (job id) yes The job being paid.
productId string (non-empty) yes The store product to buy (one of the product ids Snap4ID holds for you).
paymentRef string (payment ref) yes Fresh per request. Binds the store purchase to this job.
storeBinding object yes What to put into the store purchase; both fields equal paymentRef.
storeBinding.appAccountToken string (payment ref) yes App Store: pass as the purchase option appAccountToken.
storeBinding.obfuscatedProfileId string (payment ref) yes Google Play: pass as obfuscatedProfileId in the billing flow params.
{
"v": 1,
"id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
"type": "purchase.request",
"payload": {
"jobId": "eu-6f1c2b9e-3d4a-4b8f-9c2e-1a7d5e3f0b42",
"productId": "pl.example.app.idphoto",
"paymentRef": "3b241101-e2bb-4255-8caf-4136c566a962",
"storeBinding": {
"appAccountToken": "3b241101-e2bb-4255-8caf-4136c566a962",
"obfuscatedProfileId": "3b241101-e2bb-4255-8caf-4136c566a962"
}
}
}

A receipt that is not bound to the paymentRef is refused (binding_mismatch). Keep the purchase unfinished until the job is unlocked: see payments and trust.

The job is paid and every file has a link. Sent once per page load and again whenever a paid job is reopened, so store it idempotently by jobId and copy the files: links expire with the job.

Page → hostAt least onceUnlock evidence

Field Type Required Description
jobId string (job id) yes The paid job.
orderCode string (non-empty) yes Six-character order code; shown to the user and quoted to support.
artifacts array of object (≥ 1) yes Every deliverable file, whatever the done screen shows. Using them: receiving the files.
artifacts[].code string (non-empty) yes Stable artifact code (for example the main photo, the print sheet, the transparent PNG).
artifacts[].title string yes Title in the session locale.
artifacts[].mimeType string (non-empty) yes image/jpeg, image/png or application/pdf.
artifacts[].filename string (file name) yes A safe file name to save under.
artifacts[].url string (URL) yes Time-limited signed HTTPS download URL, usually on storage.googleapis.com. Treat it as opaque: do not parse or rewrite it, do not assume a host.
artifacts[].expiresAt string (date-time) yes When the link (and the job) expires: 30 days after creation.
{
"v": 1,
"id": "0b8f5c2e-7a41-4d3b-9e6c-000000000004",
"type": "job.completed",
"payload": {
"jobId": "eu-6f1c2b9e-3d4a-4b8f-9c2e-1a7d5e3f0b42",
"orderCode": "7K3M9Q",
"artifacts": [
{
"code": "photo-main",
"title": "Zdjęcie do dowodu",
"mimeType": "image/jpeg",
"filename": "snap4id-photo.jpg",
"url": "https://storage.googleapis.com/example-bucket/…/photo.jpg?GoogleAccessId=…&Expires=…&Signature=…",
"expiresAt": "2026-12-24T12:00:00.000Z"
}
]
}
}

The user tapped Save on a file. Sent only when your host hello granted capabilities.save.

Page → hostNeeds capabilities.save

Field Type Required Description
jobId string (job id) yes The job.
code string (non-empty) yes The artifact code from job.completed.
{
"v": 1,
"id": "0b8f5c2e-7a41-4d3b-9e6c-000000000005",
"type": "artifact.save",
"payload": {
"jobId": "eu-6f1c2b9e-3d4a-4b8f-9c2e-1a7d5e3f0b42",
"code": "photo-main"
}
}

The user tapped Share on a file. Sent only when your host hello granted capabilities.share.

Page → hostNeeds capabilities.share

Field Type Required Description
jobId string (job id) yes The job.
code string (non-empty) yes The artifact code from job.completed.
{
"v": 1,
"id": "0b8f5c2e-7a41-4d3b-9e6c-000000000006",
"type": "artifact.share",
"payload": {
"jobId": "eu-6f1c2b9e-3d4a-4b8f-9c2e-1a7d5e3f0b42",
"code": "photo-main"
}
}

The flow moved to another step. Show title in your own header (the page has no chrome of its own).

Page → hostNo reply

Field Type Required Description
step "capture" | "processing" | "payment" | "done" yes The current step.
title string A title for your header, in the session locale (overridable for capture and done).
{
"v": 1,
"id": "0b8f5c2e-7a41-4d3b-9e6c-000000000007",
"type": "stepChanged",
"payload": {
"step": "payment",
"title": "Zamówienie"
}
}

Whether the page can go back. While true, send back on the system back gesture instead of closing.

Page → hostNo reply

Field Type Required Description
canGoBack boolean yes The page has a step to go back to.
{
"v": 1,
"id": "0b8f5c2e-7a41-4d3b-9e6c-000000000008",
"type": "canGoBack",
"payload": {
"canGoBack": true
}
}

The user is done (“Back” on the done screen, or the end of done screen none). Close the flow screen.

Page → hostNo reply

No fields: the payload is {}.

{
"v": 1,
"id": "0b8f5c2e-7a41-4d3b-9e6c-000000000009",
"type": "close",
"payload": {}
}

Something went wrong in the page. A fatal code ends the session; close the flow. Codes and actions: error codes.

Page → hostNo reply

Field Type Required Description
code string (error code) yes One of the bridge error codes.
fatal boolean yes Fixed per code. true ends the session.
message string For logs only; never show it to the user.
paymentRef string (payment ref) Only with duplicate_purchase: the purchase to refund.
{
"v": 1,
"id": "0b8f5c2e-7a41-4d3b-9e6c-000000000010",
"type": "error",
"payload": {
"code": "duplicate_purchase",
"fatal": false,
"paymentRef": "3b241101-e2bb-4255-8caf-4136c566a962"
}
}

Sent by your app to the page (the React Native component sends them for you).

Your answer to the page hello, with replyTo = the page hello’s id. Tells the page what your app is and can do, the user’s consent, and optional cosmetic overrides.

Host → pageReply to page hello

Field Type Required Description
protocolVersion string (protocol version) yes Your protocol version: 1.0.
platform "ios" | "android" | "test" yes ios or android; test only with a fake store (accepted only by test deployments).
appVersion string (non-empty) yes Your app version, for support.
consent object The user’s analytics consent. Absent ⇒ analytics off.
consent.statistics boolean true only if the user allowed statistics in your app.
consent.marketing boolean Ignored: Snap4ID never uses marketing in embedded pages.
capabilities object What the done screen may offer. Absent ⇒ both false.
capabilities.save boolean yes Show Save buttons (you handle artifact.save).
capabilities.share boolean yes Show Share buttons (you handle artifact.share).
doneScreen "all" | "photo" | "none" Override the done screen: all files, the photo only, or none (you show the files).
theme map Theme token → value overrides, see theme. A wrong shape is ignored.
copy map Text overrides: copy id → { locale: text }. Ids and limits: texts. Invalid entries are dropped one by one.
{
"v": 1,
"id": "0b8f5c2e-7a41-4d3b-9e6c-000000000021",
"type": "hello",
"payload": {
"protocolVersion": "1.0",
"platform": "ios",
"appVersion": "4.2.0",
"consent": {
"statistics": true
},
"capabilities": {
"save": true,
"share": true
}
},
"replyTo": "a3c5e1f0-4d2b-4c8e-9f1a-2b3c4d5e6f70"
}

The store price of the product the page named in its hello (productIds), for your store, so the page can show it on its order button. Send it after your hello, with replyTo = the page hello’s id: never hold the hello for the store. No price (no id for your store, the store does not know it, a store error) ⇒ send products: {}; the page then shows no price.

Host → pageReply to page hello, after your hello

Field Type Required Description
products map yes The price, keyed by the product id you looked up (the one for your store); empty when you have none.
products.*.amount_minor integer (≥ 0) yes Price in minor units (grosze).
products.*.currency string (currency) yes ISO 4217 code, upper case.
products.*.display_price string (non-empty) yes The store’s localized price string, shown as is.
{
"v": 1,
"id": "0b8f5c2e-7a41-4d3b-9e6c-000000000025",
"type": "price.result",
"payload": {
"products": {
"pl.example.app.idphoto": {
"amount_minor": 1999,
"currency": "PLN",
"display_price": "19,99 zł"
}
}
},
"replyTo": "a3c5e1f0-4d2b-4c8e-9f1a-2b3c4d5e6f70"
}

The outcome of a purchase.request (replyTo = its id). Without replyTo it is an unsolicited result for the open job: a purchase that resolved later, such as an approved “Ask to Buy”.

Host → pageReply to purchase.request, or unsolicited

Field Type Required Description
jobId string (job id) yes The job from the request.
paymentRef string (payment ref) yes The paymentRef from the request.
status "succeeded" | "cancelled" | "failed" | "pending" | "busy" yes succeeded (bought), pending (waiting for approval), cancelled (by the user), failed (see reason), busy (another purchase is in progress).
receipt object, kind one of "fake", "app-store", "play" Trust mode verifier: the store receipt, required with succeeded. Trust mode backend: omit it; send succeeded only after your backend unlocked the job.
reason string Why it failed, for logs.
price object The store price you charged, if known (Google Play receipts carry no price).
price.amount_minor integer (≥ 0) yes Minor units.
price.currency string (currency) yes ISO 4217, upper case.
{
"v": 1,
"id": "0b8f5c2e-7a41-4d3b-9e6c-000000000022",
"type": "purchase.result",
"payload": {
"jobId": "eu-6f1c2b9e-3d4a-4b8f-9c2e-1a7d5e3f0b42",
"paymentRef": "3b241101-e2bb-4255-8caf-4136c566a962",
"status": "succeeded",
"receipt": {
"kind": "app-store",
"jws": "eyJhbGciOiJFUzI1NiJ9.eyJ0cmFuc2FjdGlvbklkIjoiMjAwMDAwMDAwMSJ9.c2ln"
},
"price": {
"amount_minor": 1999,
"currency": "PLN"
}
},
"replyTo": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f"
}

The user made the system back gesture while the page reported canGoBack: true.

Host → pageNo reply

No fields: the payload is {}.

{
"v": 1,
"id": "0b8f5c2e-7a41-4d3b-9e6c-000000000023",
"type": "back",
"payload": {}
}

The user changed their analytics choice in your app during the session.

Host → pageNo reply

Field Type Required Description
consent object yes The new consent.
consent.statistics boolean true only if the user allowed statistics.
consent.marketing boolean Ignored.
{
"v": 1,
"id": "0b8f5c2e-7a41-4d3b-9e6c-000000000024",
"type": "consent.changed",
"payload": {
"consent": {
"statistics": false
}
}
}

Your host tells the page about a protocol problem. Only two codes may be sent this way.

Host → pageNo reply

Field Type Required Description
code string (error code) yes invalid_message (a page message failed validation and expected a reply) or unsupported_protocol.
fatal boolean yes true for unsupported_protocol, false for invalid_message.
message string For logs only.
{
"v": 1,
"id": "0b8f5c2e-7a41-4d3b-9e6c-000000000025",
"type": "error",
"payload": {
"code": "invalid_message",
"fatal": false
},
"replyTo": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f"
}

The receipt of a successful purchase.result, discriminated on kind.

StoreKit 2: the signed transaction (VerificationResult.jwsRepresentation).

Field Type Required Description
kind "app-store" yes Always app-store.
jws string (compact JWS) yes The compact JWS of the transaction, as StoreKit returns it.
{
"kind": "app-store",
"jws": "eyJhbGciOiJFUzI1NiJ9.eyJ0cmFuc2FjdGlvbklkIjoiMjAwMDAwMDAwMSJ9.c2ln"
}

Google Play Billing: the purchase data and its signature, unchanged.

Field Type Required Description
kind "play" yes Always play.
originalJson string (non-empty) yes Purchase.getOriginalJson(), as returned.
signature string (base64) yes Purchase.getSignature(), base64.
{
"kind": "play",
"originalJson": "{\"orderId\":\"GPA.1234-5678-9012-34567\",\"productId\":\"pl.example.app.idphoto\",\"obfuscatedProfileId\":\"3b241101-e2bb-4255-8caf-4136c566a962\"}",
"signature": "bXlzaWduYXR1cmU="
}

From the SDK’s fake store, for tests. Refused by production; accepted only by test deployments.

Field Type Required Description
kind "fake" yes Always fake.
testOnly true yes Always true.
transactionId string (non-empty) yes Fake transaction id.
productId string (non-empty) yes The product bought.
accountToken string (non-empty) yes The paymentRef the purchase was bound to.
purchasedAt string (non-empty) yes When it was “bought”.
{
"kind": "fake",
"testOnly": true,
"transactionId": "fake-0001",
"productId": "pl.example.app.idphoto",
"accountToken": "3b241101-e2bb-4255-8caf-4136c566a962",
"purchasedAt": "2026-11-24T12:00:00.000Z"
}

Named string formats used in the tables above.

Format Rule Example
job id An optional two-letter zone, a dash, then a lower-case UUID. eu-6f1c2b9e-3d4a-4b8f-9c2e-1a7d5e3f0b42
payment ref Lower-case UUID version 4. 3b241101-e2bb-4255-8caf-4136c566a962
protocol version major.minor. 1.0
file name Letters, digits, _, . and -; not only dots. snap4id-photo.jpg
currency ISO 4217, upper case. PLN
compact JWS Three base64url parts joined by dots. eyJh.eyJ0.c2ln
base64 Standard base64 with padding. bXlzaWduYXR1cmU=