- The application handles most calls and, on failure, returns the structured error envelope below; parse it for the precise cause.
- The infrastructure in front of the API (gateway, authentication, throttling) can answer first, and those responses may not carry the envelope.
400 from malformed JSON and a 400 from a field that fails validation require different fixes. The envelope’s code and errors disambiguate them.
Error envelope
Errors raised by the application share the same JSON shape: a problem-details-style object (the Paylead error profile). Three fields are always present (code, title, status); errors and instance are added when relevant. Errors raised at the edge may not include it.
Code examples coming soon. The Paylead API (v2) is still under construction. Request and response examples for this section will be published once the contract is finalized. In the meantime, contact your Paylead account manager for early-access details.
Example 400 response
Locating the failing field in nested payloads
errors[].loc appears when the failure traces back to a specific field of the input payload, for example a missing value, a wrong type, or a format mismatch. Most other failures, including business-rule errors such as 409 Conflict, do not carry field-level detail: errors is null in that case.
When present, loc is a path from the request body down to the offending field: one segment per level, either an object key or the numeric index of an item inside a list. Read it left to right to walk down to the exact field that failed.
Some payloads nest several levels of lists. Creating transactions, for example, sends a list of banks, each holding a list of accounts, each holding a list of transactions. A failure on the type of the first transaction of the first account of the first bank looks like this:
Nested loc example
HTTP status codes
Returned by the application
On failure, these carry the error envelope above.Raised at the edge
Some requests never reach the application: the API gateway and upstream infrastructure answer first (throttling and gateway failures). These responses may not carry the error envelope: the body can be empty, plain text, or a different JSON shape, so branch on the HTTP status and never assume a parseablecode / title.
Authentication is also enforced here:
401 and 403 (listed above) are returned by the application with the envelope, but an edge rejection may arrive without it. 502 behaves the same way: the application returns it with the envelope when an upstream dependency such as the PSP is unavailable, while a gateway can also emit a 502 without one. Handle both.
Paylead error codes
Thecode field is what you branch on. The codes below are the ones the Perks endpoints return, grouped by the operation that raises them. Each endpoint’s own reference page lists the codes it can return.
Match the full code. Two codes sharing an HTTP status carry unrelated causes, and each one maps to its own message on the payout and IBAN flows.
Returned by every endpoint
Enrollment (
POST /perks/consumers)
Pool and KYC
Payment account (
/perks/consumers/{consumer_id}/accounts/payment)
Payout (
POST /perks/consumers/{consumer_id}/pools/me/payouts)
Segments (
/perks/consumers/{consumer_id}/segments/{segment_reference})
Vouchers (
/perks/consumers/{consumer_id}/vouchers, .../vouchers/orders, beta)
Upstream (any PSP-backed operation)
Handling common errors
400 Bad Request
400 Bad Request
The payload is malformed JSON, or a field fails validation.Fix. Read the
errors array: each entry points at the offending field and the rule it broke. Coerce the value on the client and resend. If errors is empty, the body itself was not valid JSON.403 Forbidden
403 Forbidden
The token is valid but is not allowed to access this resource, for example it was issued for a different Program or environment, or it lacks the required scope (
LOYALTIES, PERKS, TX_INJECTION, or ALL).Fix. Confirm you are using the token issued for this Program and this environment (sandbox vs production), and that it carries the scope the endpoint needs. See Authentication.404 Not Found
404 Not Found
No resource matches the given ID, for example no Consumer with that
consumer_id.Fix. Verify the ID and confirm the resource was created against the same environment. Create it if needed.409 Conflict
409 Conflict
500 / 502 Server errors
500 / 502 Server errors
Something failed inside Paylead (
500) or in an upstream dependency (502). Not your fault, but you still need to handle it.Fix. Retry idempotent calls with exponential backoff. If the issue persists, share the response body (including the instance when present) with Paylead support.Retry strategy
What’s next
FAQ
Common integration questions, answered.
Security
Data protection and regulatory compliance for your integration.
Support
Contact Paylead support. Share the failing response, including its
instance when present.