Skip to main content

Errors

Pinch uses conventional HTTP status codes to indicate the result of a request, with a structured JSON envelope for the details.

Error envelope​

Every error response is a JSON object with this shape:

{
"error": {
"code": "invalid_request",
"message": "Field `providerOrderId` is required.",
"field": "providerOrderId",
"requestId": "req_8c2f9a1b3d4e5f"
}
}
FieldDescription
error.codeStable, machine-readable identifier. Use this in code, not message.
error.messageHuman-readable explanation. Safe to log; do not show to end users.
error.fieldPresent on validation errors. The field that failed.
error.requestIdEcho of the X-Request-Id response header. Include it when contacting support.

HTTP status code conventions​

StatusWhen you'll see it
200Success.
400Bad request — malformed JSON or invalid field shape.
401Unauthenticated — see Authentication.
403Authenticated but not authorized for this resource (e.g. wrong merchant).
404Resource not found — referenced an order or return that doesn't exist.
409Conflict — duplicate providerOrderId or providerReturnId.
422Unprocessable — field values failed validation (e.g. unknown currency code).
429Rate limited — slow down and retry with backoff.
500Internal error on Pinch. Retry with exponential backoff.
502 / 503Upstream or capacity issue. Retry with exponential backoff.

Error code catalog​

Authentication​

CodeHTTPMeaningFix
unauthenticated401Missing Authorization headerAdd the header
invalid_api_key401Key format invalid or revokedRotate or recheck
environment_mismatch401Key/base URL mismatchMatch pk_test_ ↔ qa-api.pinch.ai, pk_live_ ↔ api.pinch.ai
forbidden403Key not authorized for this merchant or resourceContact support

Request shape​

CodeHTTPMeaningFix
invalid_request400Malformed JSON or required field missingValidate payload against the schema
unprocessable_entity422Field present but value invalidCheck field constraints
unknown_field422Field not in schemaRemove or check spelling
invalid_currency_code422Currency must be ISO 4217 numeric (e.g. 840 for USD)Use the numeric code
invalid_timestamp422Timestamp must be epoch milliseconds as a stringPass String(Date.now())

Resource state​

CodeHTTPMeaningFix
not_found404Resource does not existVerify the ID
order_not_found404Return references an order Pinch hasn't seenSend the /v1/order first
duplicate_order409providerOrderId already exists for this merchantTreat as success — Pinch is idempotent by providerOrderId
duplicate_return409providerReturnId already existsSame as above

Capacity​

CodeHTTPMeaningFix
rate_limited429You're exceeding your rate limitRetry with exponential backoff
internal_error500Pinch failed internallyRetry with backoff; contact support if persistent
bad_gateway502Upstream issueRetry with backoff
service_unavailable503Temporary unavailabilityRetry with backoff

Idempotency​

POST /v1/order and POST /v1/return are idempotent on providerOrderId and providerReturnId respectively. Retrying the same identifier returns the original decision rather than creating a duplicate.

For other endpoints, use exponential backoff on transient failures:

attempt 1 → wait 1s
attempt 2 → wait 2s
attempt 3 → wait 4s
attempt 4 → wait 8s
attempt 5 → give up, alert

Always honor Retry-After if Pinch returns it in a 429 or 503 response.

Request IDs​

Every response includes an X-Request-Id header. Log it alongside your application logs. When you contact support@pinch.ai about a specific failure, include the request ID — Pinch can pull the full trace.

See also​