Skip to content
BaxPayDevelopers

Get started

Errors

Every failure returns the same flat shape, so you can handle them in one place.

The error shape

curl -X POST https://sandbox-api.baxpay.com/v1/payment-links \
  -H "Authorization: Bearer $BAXPAY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{ "description": "Refund", "amount": -5, "businessWide": true }'
{
  "statusCode": 400,
  "message": ["amount must not be less than 0.01"],
  "error": "Bad Request",
  "timestamp": "2026-07-16T14:02:10.000Z",
  "path": "/v1/payment-links"
}
FieldAlways thereMeaning
statusCodeyesThe HTTP status, repeated in the body
messageyesA string, or an array of strings when several fields failed validation. Written for a human reading a log: show it, don't parse it
erroryesThe status name (Bad Request, Not Found, …)
timestamp, pathyesWhen and where it failed
codesometimesA stable, machine-readable reason (e.g. EREPORTING_PERIOD_INVALID). Branch on it when present
params, violations, reason, retryAfterSecondssometimesDetails for that code, such as each failed EN 16931 rule in violations
requestIdwith an API key, alwaysThe request id, also in the X-Request-Id header; yours if you sent X-Request-ID. Find the call in the request log

Handle message as either type:

const reason = Array.isArray(err.message) ? err.message.join('; ') : err.message;

Status codes

StatusMeaningWhat to do
200 201 204SuccessNothing
400Invalid request: validation, a business rule, or a missing/reused Idempotency-KeyFix the request. Retrying won't help
401Missing, unknown or revoked credentialCheck the key. API keys don't expire; a revoked one must be replaced
403Authenticated but not allowed, e.g. no BaxPay plan chosen yet, or a feature your plan doesn't includeRead message; don't retry
404No such resource in this key's modeCheck the id, and that a test key isn't looking for a live record
409The same Idempotency-Key is still being processedWait briefly and retry with the same key
429Rate limited (see limits)Wait for X-RateLimit-Reset, then retry
500 502 503Our side, or a payment partnerRetry with backoff and the same idempotency key

A record from the other mode answers exactly like one that doesn't exist:

curl https://sandbox-api.baxpay.com/v1/payment-links/00000000-0000-4000-8000-000000000000 \
  -H "Authorization: Bearer $BAXPAY_API_KEY"
{ "statusCode": 404, "message": "Payment link not found", "error": "Not Found" }
curl https://sandbox-api.baxpay.com/v1/payment-links \
  -H "Authorization: Bearer bx_test_0000"
{ "statusCode": 401, "message": "Invalid or revoked API key", "error": "Unauthorized" }

Retrying safely

A network timeout tells you nothing about whether the call went through. That's what idempotency keys are for.