Skip to main content

Loyalty Groups API

The Loyalty Groups API allows you to manage loyalty group segmentation in the Nilo platform. Loyalty groups define tiers or segments of customers for targeted loyalty programs, controlling which challenges and point lists apply to different customer segments.

Understanding Loyalty Groups​

Loyalty groups in Nilo segment your customer base for loyalty programs:

  • Group Structure

    • Unique internal code for identification
    • Name for display purposes
    • Enabled/disabled status
    • Optional maximum redeemable points per order
    • Optional association with a point list
  • Usage

    • Link loyalty challenges to specific groups
    • Control point redemption limits per segment
    • Associate point lists with customer tiers

Important Considerations​

  1. Unique Codes: Each loyalty group requires a unique internal code
  2. Point Limits: Use maxRedeemablePointsPerOrder to cap point redemption per purchase
  3. Point Lists: Associate a point list to define earning rules for the group
  4. Challenges: Loyalty challenges can target specific groups via loyaltyGroupInternalCodes

Batch Operations​

Batch Upsert Loyalty Groups​

POST/batch/grouper/loyalty/upsert

This endpoint allows you to create or update multiple loyalty groups at once. The operation is processed asynchronously.

Use this endpoint when you need to:

  • Set up your loyalty tier structure (Gold, Silver, Bronze, etc.)
  • Synchronize loyalty groups from your CRM or loyalty management system
  • Update point redemption limits across multiple groups
  • Associate point lists with loyalty groups in bulk

Request Body Parameters​

ParameterTypeRequiredDescription
upsertarrayYesArray of loyalty group objects
upsert[].internalCodestringYesUnique loyalty group code
upsert[].namestringYesLoyalty group display name
upsert[].enabledbooleanYesWhether the group is active
upsert[].maxRedeemablePointsPerOrderintegerNoMaximum points redeemable per order (null for unlimited)
upsert[].pointListInternalCodestringNoPoint list to associate with this group

Request Body Example​

{
"upsert": [
{
"internalCode": "GROUP-GOLD",
"name": "Gold Members",
"enabled": true,
"maxRedeemablePointsPerOrder": 5000,
"pointListInternalCode": "POINTS-GOLD"
},
{
"internalCode": "GROUP-SILVER",
"name": "Silver Members",
"enabled": true,
"maxRedeemablePointsPerOrder": 2000,
"pointListInternalCode": "POINTS-SILVER"
},
{
"internalCode": "GROUP-BRONZE",
"name": "Bronze Members",
"enabled": true,
"maxRedeemablePointsPerOrder": 1000,
"pointListInternalCode": null
}
]
}

Response Codes​

CodeDescription
202Request accepted, processing initiated
400Bad request - Invalid parameters
403Forbidden - Insufficient permissions

Response Example​

{
"batchIds": ["550e8400-e29b-41d4-a716-446655440000"]
}

Example Usage​

const headers = {
Authorization: "YOUR_AUTH_TOKEN",
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
};

const data = {
upsert: [
{
internalCode: "GROUP-GOLD",
name: "Gold Members",
enabled: true,
maxRedeemablePointsPerOrder: 5000,
pointListInternalCode: "POINTS-GOLD",
},
{
internalCode: "GROUP-SILVER",
name: "Silver Members",
enabled: true,
maxRedeemablePointsPerOrder: 2000,
pointListInternalCode: "POINTS-SILVER",
},
{
internalCode: "GROUP-BRONZE",
name: "Bronze Members",
enabled: true,
maxRedeemablePointsPerOrder: 1000,
pointListInternalCode: null,
},
],
};

fetch(
"https://tm0cs5kjs6.execute-api.us-east-1.amazonaws.com/dev/batch/grouper/loyalty/upsert",
{
method: "POST",
headers: headers,
body: JSON.stringify(data),
}
)
.then((response) => response.json())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));

Error Codes​

When an operation fails, the API returns a structured error response:

{
"code": 404,
"message": "LOYALTY_GROUP_NOT_FOUND",
"object": {
"statusCode": 404,
"code": "LOYALTY_GROUP_NOT_FOUND",
"message": "Loyalty group not found",
"entity": "loyaltyGroup",
"entityCode": "LG-001",
"timestamp": "2026-05-18T15:16:47.000Z"
}
}

The object field provides additional context about the error:

FieldDescription
statusCodeHTTP status code
codeError code (same as top-level message)
messageHuman-readable error description
entityEntity type that caused the error
entityCodeThe internalCode of the entity involved
timestampWhen the error occurred (ISO 8601)

404 — Not Found​

Error CodeDescription
LOYALTY_GROUP_NOT_FOUNDThe loyalty group does not exist
POINT_LIST_NOT_FOUNDThe point list specified does not exist
STORE_NOT_FOUNDThe store specified does not exist

400 — Bad Request​

Error CodeDescription
MAX_REDEEMABLE_POINTS_PER_ORDER_IS_DECIMALThe maximum redeemable points per order must be an integer

409 — Conflict​

Error CodeDescription
NAME_ALREADY_EXISTA loyalty group with the same name already exists
INTERNAL_CODE_ALREADY_EXISTA loyalty group with the same internal code already exists
STORE_ALREADY_IN_LOYALTY_GROUPThe store is already assigned to this loyalty group
STORE_NOT_IN_LOYALTY_GROUPThe store is not in this loyalty group (when trying to remove)
LOYALTY_GROUP_HAS_NO_POINT_LISTCannot add a store because the loyalty group has no point list assigned

Security​

Authentication​

All endpoints require two types of authentication:

  • API Key in header: x-api-key
  • Authorization token in header: Authorization

Required Permissions​

  • For loyalty group operations: supplier/loyaltygroup.bulkwrite
Tana

Tana

Ask me anything about Nilo's API — endpoints, authentication, integration guides, or code examples.

Best practice: validate against the official documentation for the most up-to-date details.