error object that includes a machine-readable code and a human-readable message.
Error response structure
| Field | Type | Description |
|---|---|---|
status | string | Always "error" for failed requests |
timestamp | string | ISO 8601 time the error occurred |
path | string | The request path that triggered the error |
error.code | string | Machine-readable error code |
error.message | string | Human-readable description of the error |
Error types
400 Bad request
Returned when the request is malformed or missing required fields.- A required field is missing from the request body (
amount,description,currency,customerName,customerPhoneNumber,items, orapi_secret) - A field value has the wrong type or format (e.g. a non-numeric
amount) - The
itemsarray is empty
401 Unauthorized
Returned when thex-api-secret header is missing, incorrect, or has been revoked.
- The
x-api-secretheader was not included in the request - The secret key is incorrect or belongs to a different environment (e.g. production key used against the QA server)
- The secret key has been rotated and the old value is no longer valid
404 Not found
Returned when the requested resource does not exist — for example, verifying anorderId that was never created.
- The
orderIdpassed to/trdp/verifydoes not exist - The order was created in a different environment (e.g. QA vs. production)
500 Internal server error
Returned for unexpected server-side failures. These are not caused by your request and should be retried with exponential back-off.If you consistently receive
500 errors, contact Star-Pay support. Do not retry 500 errors more than a few times without back-off.Handling errors in code
Common mistakes
Missing required fields
Missing required fields
Every order request requires
amount, description, currency, customerName, customerPhoneNumber, items, and api_secret. Omitting any of these returns a 400 BadRequestException. Validate your payload before sending.Wrong or missing API secret
Wrong or missing API secret
The
x-api-secret header must be present on every request. Additionally, api_secret must also be included in the request body for order creation. Using a QA secret against the production endpoint (or vice versa) will result in a 401.Expired or invalid order ID
Expired or invalid order ID
Passing an
orderId to /trdp/verify that was never created, belongs to a different merchant, or was created in a different environment returns a 404 ABC_001 error. Ensure you are storing and using the order_id returned in the OrderCreationResponse.Expired payment URL
Expired payment URL
If a customer tries to pay after the order’s
expires_at time, the payment will fail. Always set a reasonable expiredAt value and inform customers of the payment deadline.Phone number format
Phone number format
customerPhoneNumber must be in E.164 format (e.g. +251987654567). Passing a local format such as 0987654567 may result in a validation error.Error code reference
| HTTP status | Error code | Description |
|---|---|---|
400 | BadRequestException | Malformed request or missing required field |
401 | GEN_004 | Invalid or missing API secret |
404 | ABC_001 | Requested resource not found |
500 | GEN_004 | Unexpected server-side error |