Skip to content
Loyvo

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, 202Success. 202 means accepted and queued (SMS).
400The request is malformed, or a business rule failed (for example an expired redemption PIN).
401No key, or the key is invalid or revoked.
403The key is valid but not allowed to do this (missing permission, sender ID not approved, no credits).
404The endpoint or the object doesn't exist.
409Conflict: the action no longer applies (a campaign already sending) or the same Idempotency-Key is still being processed.
413The request body is too large.
422Validation failed: a field is missing or invalid.
429Too many requests. Wait for the Retry-After seconds, then retry.
500, 502, 503, 504Something 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).

422 Unprocessable Entity
{
  "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.

400 Bad Request
{
  "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.

404 Not Found
{
  "error": "No local wallet found for this customer"
}