Get started
Errors
Loyvo uses standard HTTP status codes. 2xx means success, 4xx means something in the request needs fixing, and 5xx means a problem on our side.
Status codes
| 200, 201, 202 | Success. 202 means accepted and queued (SMS). |
| 400 | The request is malformed, or a business rule failed (for example an expired redemption PIN). |
| 401 | No key, or the key is invalid or revoked. |
| 403 | The key is valid but not allowed to do this (missing permission, sender ID not approved, no credits). |
| 404 | The endpoint or the object doesn't exist. |
| 409 | Conflict: the action no longer applies (a campaign already sending) or the same Idempotency-Key is still being processed. |
| 413 | The request body is too large. |
| 422 | Validation failed: a field is missing or invalid. |
| 429 | Too many requests. Wait for the Retry-After seconds, then retry. |
| 500, 502, 503, 504 | Something went wrong on our side. Safe to retry with backoff. |
SMS API and api.loyvo.lk
Errors from the SMS API, and from api.loyvo.lk itself (unknown path, a product temporarily unavailable), have one shape: a machine-readable code, a human-readable message, the field at fault when there is one, and the request_id.
Build your logic on code and the HTTP status; messages may be reworded. Gateway codes you may see: not_found, upstream_unavailable (502), upstream_timeout (504) and request_too_large (413).
{
"error": {
"code": "validation_failed",
"message": "\"to\" must be a Sri Lankan mobile number.",
"field": "to",
"request_id": "req_6f1c2a9e0b7d4c3e"
}
}Loyalty API
Validation errors list the problem for each field under errors. Authentication errors return {"detail": "…"} with 401 or 403.
{
"status": "error",
"errors": {
"phone": ["Enter a valid phone number."]
}
}Wallet API
Errors carry a message in error. Validation errors return 422 with an issues list naming each invalid field.
{
"error": "No local wallet found for this customer"
}