Standard Envelope
Every Loyalife API response wraps its payload in a results object:
{
"results": {
"IsSucessful": true,
"ErrorCode": "000",
"ExceptionMessage": "Success",
"ReturnObject": { ... },
"Count": 0
}
}
IsSucessful is spelled with one “s” — this matches the service’s actual response field name.
Fields
| Field | Type | Description |
|---|
IsSucessful | boolean | true if the request was processed successfully. |
ErrorCode | string | "000" on success. A non-zero code indicates an error. |
ExceptionMessage | string | "Success" on success; error description on failure. |
ReturnObject | any | The response payload — varies by endpoint. May be an object, array, boolean, or scalar. |
Count | integer | Number of records returned (used on list endpoints). |
Success Response
{
"results": {
"IsSucessful": true,
"ErrorCode": "000",
"ExceptionMessage": "Success",
"ReturnObject": true,
"Count": 0
}
}
Error Response
{
"results": {
"IsSucessful": false,
"ErrorCode": "E001",
"ExceptionMessage": "Member not found",
"ReturnObject": null,
"Count": 0
}
}
Checking for Errors
Always check IsSucessful first — the HTTP status code alone is not sufficient. A 200 OK response can still contain IsSucessful: false when the request was received but the business logic failed.
response = requests.post(url, ...)
data = response.json()["results"]
if not data["IsSucessful"]:
raise Exception(f"API error {data['ErrorCode']}: {data['ExceptionMessage']}")
return data["ReturnObject"]
Universal Error Codes
These codes may be returned by any API endpoint.
| Code | ExceptionMessage | Meaning |
|---|
000 | Success | Request succeeded |
997 | Exception occurred | Unexpected server-side error |
998 | Invalid request | Request is structurally invalid |
999 | Bad request | Payload not constructed properly — missing or malformed fields |
HTTP Transport Codes
These are standard HTTP status codes returned at the transport layer, separate from the ErrorCode field in the envelope.
| HTTP Status | Meaning |
|---|
400 | Bad request — malformed payload |
401 | Unauthorized — missing or expired Bearer token |
500 | Internal server error |
501–503 | Server down / gateway unavailable |
A 200 OK HTTP response does not guarantee success. Always check IsSucessful in the response envelope — business logic errors return 200 with IsSucessful: false and a non-zero ErrorCode.