Skip to main content

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

FieldTypeDescription
IsSucessfulbooleantrue if the request was processed successfully.
ErrorCodestring"000" on success. A non-zero code indicates an error.
ExceptionMessagestring"Success" on success; error description on failure.
ReturnObjectanyThe response payload — varies by endpoint. May be an object, array, boolean, or scalar.
CountintegerNumber 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.
CodeExceptionMessageMeaning
000SuccessRequest succeeded
997Exception occurredUnexpected server-side error
998Invalid requestRequest is structurally invalid
999Bad requestPayload 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 StatusMeaning
400Bad request — malformed payload
401Unauthorized — missing or expired Bearer token
500Internal server error
501–503Server 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.