API Reference

Create a payment session

Create an amount-locked checkout session and receive a client token.

Request

POST/api/v1/payment-sessions

Creates an amount-locked checkout session and returns a one-time client token for @zippypay/checkout. Send the request from trusted backend infrastructure with your API key.

Headers

NameTypeRequiredDescription
X-Api-KeystringRequiredBusiness API key with a zp_live_ prefix and 32-character Base64URL secret.
Content-TypestringRequiredapplication/json
Idempotency-KeystringOptionalOptional non-empty string. A UUID v4 is strongly recommended.
X-Correlation-IdstringOptionalOptional trace identifier. Zippy generates a UUID when omitted.

JSON body

NameTypeRequiredDescription
amountdecimal stringRequiredUSD amount locked for the session lifetime, e.g. "25.00".
currencystringOptionalOptional. "USD" only (default).
merchantReferencestringOptionalOptional merchant order reference. Max 200 characters. Unique per business.
successUrlurlOptionalOptional HTTPS redirect after successful checkout. Origin must match a registered allowed checkout domain or your registered business website.
failureUrlurlOptionalOptional HTTPS redirect after failure or expiry. Same origin rules as successUrl.
metadataobjectOptionalOptional non-sensitive JSON object. Max 4096 UTF-8 bytes. No arrays.

Field validation

Amount and currency

amount must be a positive USD decimal string with up to two fractional digits (for example 25.00 or 0.50). The amount is locked when the session is created and is not echoed in the create response — the Checkout SDK reads the locked value returned to the Checkout SDK when checkout loads.

currency accepts USD only. Omit it to use the default.

Merchant reference

merchantReference is optional (max 200 characters). When supplied, it must be unique among active sessions for your business. Reusing a reference for a different payload returns 409 payment-session.reference-conflict.

Redirect URLs

When successUrl or failureUrl are sent:

  • Must use HTTPS (credentials in URLs are not allowed).
  • The URL origin must match a registered allowed checkout domain under Integrations → Allowed browser origins, or your registered business website.
  • If redirect URLs are sent but no permitted origins exist, create fails.

Valid redirect URLs (checkout.acme.com registered)

json
{
  "successUrl": "https://checkout.acme.com/order/123/success",
  "failureUrl": "https://checkout.acme.com/order/123/cancel"
}

Invalid or unregistered origins return 400 payment-session.redirect-url-invalid.

Metadata

metadata must be a JSON object with string keys and scalar values only — no arrays. Keep values non-sensitive. Exceeding 4096 UTF-8 bytes returns 400 payment-session.metadata-too-large.

Idempotency

Generate one UUID v4 for each logical create operation and reuse it only when retrying the same request. The server accepts any non-empty string, but UUID v4 is strongly recommended.

Recommended header

http
Idempotency-Key: 83596f5e-2134-4e66-8304-20d61f290cf0
  • Same tenant, route, key, and payload: returns the existing session.
  • Same key with a different payload: 409 IDEMPOTENCY_CONFLICT.
  • Reuse after the associated session becomes terminal: 409 IDEMPOTENCY_CONFLICT.

Response

201 response excerpt

json
{
  "sessionId": "550e8400-e29b-41d4-a716-446655440000",
  "clientToken": "zps_REDACTED",
  "expiresAt": "2026-08-31T12:30:00.000Z"
}

Errors

NameTypeDescription
400Bad RequestValidation failure, unknown property, redirect URL invalid, or metadata too large.
401UnauthorizedMissing, invalid, expired, or revoked API key (api-key.invalid, api-key.revoked, api-key.expired).
403Forbiddenbusiness.compliance-not-approved, business.not-active, or business.payment-id-not-configured.
409ConflictIdempotency key reused incompatibly or merchantReference conflict.
429Too Many RequestsRate limit exceeded (120/min per API key). Retry after Retry-After.