Unlock a job after a verified store purchase
Documents @snap4id-sdk/partner-api 1.0.0
import { createPartnerClient } from '@snap4id-sdk/partner-api';
const snap4id = createPartnerClient({ baseUrl: 'https://snap4.id', partnerId: 'your-partner-id', keyId: process.env.SNAP4ID_KEY_ID, privateKey: process.env.SNAP4ID_PARTNER_KEY_PEM, // Ed25519 PKCS#8 PEM});
const { order_code } = await snap4id.unlock('eu-6f1c2b9e-3d4a-4b8f-9c2e-1a7d5e3f0b42', { payment_ref: '3b241101-e2bb-4255-8caf-4136c566a962', platform: 'ios', product_id: 'pl.example.app.idphoto', transaction_id: '2000000000000001', environment: 'production', price: { amount_minor: 1999, currency: 'PLN' }, price_source: 'store',});# Signed with your Ed25519 key: build the canonical string and the five headers as described# in the overview (or use @snap4id-sdk/partner-api, which does it for you).curl -X POST 'https://snap4.id/api/v1/partner/jobs/eu-6f1c2b9e-3d4a-4b8f-9c2e-1a7d5e3f0b42/unlock' \ -H 'x-partner-id: your-partner-id' \ -H 'x-key-id: <your key id>' \ -H 'x-timestamp: <unix epoch ms>' \ -H 'x-request-id: <fresh UUID v4>' \ -H 'x-signature: <base64 Ed25519 signature>' \ -H 'content-type: application/json' \ --data '{"payment_ref":"3b241101-e2bb-4255-8caf-4136c566a962","platform":"ios","product_id":"pl.example.app.idphoto","transaction_id":"2000000000000001","environment":"production"}'Marks the job paid for a store purchase bound to one of its payment_refs. Checks, in order: signature (401) → body (400 invalid_request) → job ownership (404 not_found) → payment_ref issued for this job (400 payment_ref_mismatch) → product_id is one of the partner’s products (400 unknown_product) → environment allowed in this deployment and consistent with platform (400 environment_not_allowed) → transaction_id never used for another job (409 transaction_already_used) → job not already paid by another transaction (409 already_paid: the transaction stays consumed and the partner refunds it) → job payable (409 job_not_payable). Idempotent: the same (job, transaction_id) again answers the same 200 body. price is optional and requires price_source (and vice versa). receipt is stored for audit only (≤ 65536 bytes of serialised JSON); request body ≤ 131072 bytes, content-type: application/json. Served during maintenance.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Job id ({zone}-{uuid} or a legacy bare uuid). Unknown, malformed, unroutable and other partners’ jobs all answer the same 404 not_found (no existence oracle).
Job id ({zone}-{uuid} or a legacy bare uuid). Unknown, malformed, unroutable and other partners’ jobs all answer the same 404 not_found (no existence oracle).
Request Bodyrequired
Section titled “Request Bodyrequired”Partner API unlock request
object
Payment_ref bound into the store purchase
Store product id
Store transaction / order id (1..128 printable)
Store price (optional)
object
Amount in minor units (e.g. grosze)
ISO 4217, upper case (e.g. PLN)
Required with price
Raw store receipt, audit only (≤ 64 KiB serialised)
Examples
{ "payment_ref": "3b241101-e2bb-4255-8caf-4136c566a962", "platform": "ios", "product_id": "com.example.photo.passport", "transaction_id": "2000000812345678", "environment": "production", "price": { "amount_minor": 1999, "currency": "PLN" }, "price_source": "store"}Responses
Section titled “Responses”OK
Partner API unlock response
object
Examples
{ "job_id": "eu-6f1c2b9e-3d4a-4b8f-9c2e-1a7d5e3f0b42", "status": "paid", "order_code": "7K3M9Q"}invalid_request, payment_ref_mismatch, unknown_product, environment_not_allowed
Embed / Partner API error
object
object
Examples
{ "error": { "code": "invalid_request" }}{ "error": { "code": "payment_ref_mismatch" }}{ "error": { "code": "unknown_product" }}{ "error": { "code": "environment_not_allowed" }}unauthorized
Embed / Partner API error
object
object
Examples
{ "error": { "code": "unauthorized" }}not_found
Embed / Partner API error
object
object
Examples
{ "error": { "code": "not_found" }}transaction_already_used, already_paid, job_not_payable
Embed / Partner API error
object
object
Examples
{ "error": { "code": "transaction_already_used" }}{ "error": { "code": "already_paid" }}{ "error": { "code": "job_not_payable" }}Retryable server error (body not part of the contract). Retry with a fresh x-request-id; the unlock resumes where it stopped.
