Skip to content

Errors

HTTP codes, errors field structure and client-side error handling strategy.

Wajub uses conventional HTTP codes. In summary: 2xx success, 4xx client-side error (missing parameter, failure, insufficient permissions), 5xx Wajub-side error (rare).

HTTP codes

CodeMeaning
200Success.
201Resource created (payment/transfer initialized).
202Accepted, asynchronous processing in progress.
400Malformed request.
401Invalid authentication (API key).
403Insufficient permissions on a restricted key, or an IP not on the key's allow-list.
404Resource not found.
406A private/restricted key is required but a public key was used.
422Validation failed — see errors. Also returned when an Idempotency-Key is reused with a different request body (on POST /payments only today; the errors.idempotency_key field explains the conflict).
429Too many requests (rate limit).
500Internal error.

Error structure

status is always a human-readable HTTP reason phrase (Unprocessable Content, Not Found, Too Many Requests…), never the literal string "error".

422 Unprocessable Content
{
"status": "Unprocessable Content",
"message": "Some fields are invalid",
"code": 422,
"errors": {
  "amount": ["The amount must be at least 100."],
  "customer.email": ["The customer.email must be a valid email address."]
}
}
messagestringoptional
Global message, safe to log.
codeintegeroptional
Duplicated HTTP code.
errorsobjectoptional
Present on 422. Field → message list map. Nested fields use dot notation.

Handling errors properly

try {
const res = await wajub.payments.initialize(params);
} catch (err) {
if (err.code === 422) {
  // Per-field validation errors
  showFieldErrors(err.errors);
} else if (err.code === 429) {
  await sleep(err.retryAfter * 1000);  // back-off
} else {
  reportToSentry(err);
}
}

Inspect an error after the fact

Any request in error remains viewable in Konsole → API Logs: you'll see the sent body, the exact response and the provider involved.