Error Handling
Beam uses HTTP response codes to indicate the success or failure of an API request.
In general:
- Codes in the 2xx range indicate success.
- Codes in the 4xx and 5xx range indicate an error.
When a request fails, Beam returns an error code and a short description as well as the HTTP status code. Use the error code to find out what went wrong, and to decide what your application should do next.
| Status Code | Error Code Enum | Description |
|---|---|---|
| 2xx | - | Everything worked as expected. No errors here. |
| 400 Bad Request | INVALID_JSON_ERROR | Bad or malformed JSON request |
| 400 Bad Request | INVALID_XML_ERROR | Bad or malformed XML request |
| 400 Bad Request | API_VALIDATION_ERROR | Inputs are failing validation. Check the message for details and retry. |
| 401 Unauthorized | INVALID_CREDENTIALS_ERROR | Missing valid authentication credentials (e.g. no Authorization header). |
| 403 Forbidden | NO_PERMISSION_ERROR | Request is authenticated but not authorized to perform the action. |
| 403 Forbidden | OPERATION_NOT_ALLOWED_ERROR | This operation is not currently allowed; please contact support. |
| 404 Not Found | NOT_FOUND_ERROR | The requested resource doesn’t exist. |
| 409 Conflict | REQUEST_CONFLICT_ERROR | Request blocked due to conflict. |
| 412 Precondition Failed | IDEMPOTENCY_KEY_ERROR | The same idempotency key was already provided with a different payload |
| 422 Unprocessable Content | MERCHANT_STATUS_INVALID_ERROR | The merchant status is currently invalid so the requested action is blocked. Please contact our support team. |
| 422 Unprocessable Content | CHARGE_PENDING | Charge is still pending, returning error for retry. |
| 422 Unprocessable Content | REFUND_PENDING | Refund is still pending, returning error for retry. |
| 422 Unprocessable Content | CARD_AUTHORIZATION_PENDING | Card authorization is still pending, returning error for retry. |
| 429 Too Many Requests | TOO_MANY_REQUESTS_ERROR | Too many requests. |
| 5xx | - | Something went wrong on our end. (These are rare.) |
Example Common Error Responses:
- Invalid Authentication Credentials, the provided API key is invalid or does not match the merchant ID.
{
"code": 401,
"message": "invalid authentication credentials; invalid authentication credentials; authentication failed",
"error": {
"errorCode": "INVALID_CREDENTIALS_ERROR",
"errorMessage": "invalid authentication credentials; invalid authentication credentials; authentication failed"
}
}- Not Found, the requested resource could not be found. This can happen if the resource ID is incorrect or does not exist.
{
"code": 404,
"message": "not found",
"error": {
"errorCode": "NOT_FOUND_ERROR",
"errorMessage": "not found"
}
}Rate limits and retries
Beam limits how often you can call the API. If you go over the limit, Beam answers 429 with
TOO_MANY_REQUESTS_ERROR instead of processing the request.
Retry with exponential backoff and jitter:
- Wait a second or two after the first attempt.
- Roughly double the wait after each attempt that fails.
- Add a small random amount to each wait, so that your retries do not all happen at the same moment.
- Give up after a few attempts, and report the problem instead of retrying forever.
This applies to polling too, not only to failed calls. Polling too fast is the most common way to reach the limit, so use the same backoff when you poll a charge, a refund, or a payment link for its status.
Webhooks avoid the problem. Beam calls your endpoint as soon as a status is final, so you do not need to poll at all. See the Webhook guide.
You can also retry 5xx responses and timeouts, because those requests may not have been processed. Send the same
idempotency key each time, so a retry cannot charge or refund the shopper twice.