Skip to content

Unlock a job after a verified store purchase

Documents @snap4id-sdk/partner-api 1.0.0

POST
/api/v1/partner/jobs/{jobId}/unlock
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',
});

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.

jobId
required

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).

string
/^([a-z]{2}-)?[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/

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).

Media typeapplication/json

Partner API unlock request

object
payment_ref
required

Payment_ref bound into the store purchase

string
/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89aAbB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/
platform
required
string
Allowed values: ios android test
product_id
required

Store product id

string
>= 1 characters <= 256 characters
transaction_id
required

Store transaction / order id (1..128 printable)

string
/^[\x20-\x7e]{1,128}$/
original_transaction_id
string
/^[\x20-\x7e]{1,128}$/
environment
required
string
Allowed values: production sandbox xcode test
price

Store price (optional)

object
amount_minor
required

Amount in minor units (e.g. grosze)

integer
currency
required

ISO 4217, upper case (e.g. PLN)

string
/^[A-Z]{3}$/
price_source

Required with price

string
Allowed values: store host
receipt

Raw store receipt, audit only (≤ 64 KiB serialised)

Examples

Exampleexample
{
"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"
}

OK

Media typeapplication/json

Partner API unlock response

object
job_id
required
string
/^([a-z]{2}-)?[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/
status
required
string
Allowed value: paid
order_code
required
string
/^[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{6}$/

Examples

Exampleexample
{
"job_id": "eu-6f1c2b9e-3d4a-4b8f-9c2e-1a7d5e3f0b42",
"status": "paid",
"order_code": "7K3M9Q"
}

invalid_request, payment_ref_mismatch, unknown_product, environment_not_allowed

Media typeapplication/json

Embed / Partner API error

object
error
required
object
code
required
string
Allowed values: invalid_request payment_ref_mismatch unknown_product environment_not_allowed

Examples

{
"error": {
"code": "invalid_request"
}
}

unauthorized

Media typeapplication/json

Embed / Partner API error

object
error
required
object
code
required
string
Allowed values: unauthorized

Examples

Exampleunauthorized
{
"error": {
"code": "unauthorized"
}
}

not_found

Media typeapplication/json

Embed / Partner API error

object
error
required
object
code
required
string
Allowed values: not_found

Examples

Examplenot_found
{
"error": {
"code": "not_found"
}
}

transaction_already_used, already_paid, job_not_payable

Media typeapplication/json

Embed / Partner API error

object
error
required
object
code
required
string
Allowed values: transaction_already_used already_paid job_not_payable

Examples

{
"error": {
"code": "transaction_already_used"
}
}

Retryable server error (body not part of the contract). Retry with a fresh x-request-id; the unlock resumes where it stopped.