Skip to main content

Promotion Groupers API

The Promotion Groupers API allows you to manage promotion groupers in the Nilo platform. Promotion groupers represent commercial segmentations that determine which stores can see specific promotions.

Understanding Promotion Groupers​

Promotion Groupers in Nilo represent commercial segments for targeting promotions:

  • Grouper Structure
    • Unique internal code for identification (same as segment code in your ERP)
    • Name for display and organization
    • Status (enabled/disabled)
    • Store associations (which stores belong to this segment)

Important Considerations​

  1. Unique Codes: Each grouper requires a unique internal code (typically your commercial segment code from ERP)
  2. Store Associations: Groupers define which stores can see promotions assigned to them
  3. Status Management: Groupers can be enabled or disabled without deletion
  4. Batch Operations: Support for bulk store assignment/removal

Single Grouper Operations​

Create Promotion Grouper​

POST/grouper/promotion

Creates a new promotion grouper in the Nilo platform.

Request Body Parameters​

ParameterTypeRequiredDescription
namestringYesName of the grouper
internalCodestringYesUnique identifier for grouper

Request Body Example​

{
"name": "Grouper 1",
"internalCode": "1235"
}

Example Usage​

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

const data = {
name: "Grouper 1",
internalCode: "1235",
};

fetch("https://api.nilo.com/grouper/promotion", {
method: "POST",
headers: headers,
body: JSON.stringify(data),
})
.then((response) => response.json())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));

Update Promotion Grouper​

PUT/grouper/{code}/promotion

Updates an existing promotion grouper.

Path Parameters​

ParameterTypeRequiredDescription
codestringYesGrouper code to update

Request Body Parameters​

ParameterTypeRequiredDescription
namestringYesNew name of grouper

Request Body Example​

{
"name": "Grouper 1"
}

Example Usage​

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

const data = {
name: "Grouper 1",
};

fetch("https://api.nilo.com/grouper/7234/promotion", {
method: "PUT",
headers: headers,
body: JSON.stringify(data),
})
.then((response) => response.json())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));

Change Promotion Grouper Status​

PUT/grouper/{code}/status/promotion

Enable or disable a specific promotion grouper.

Path Parameters​

ParameterTypeRequiredDescription
codestringYesGrouper code

Request Body Parameters​

ParameterTypeRequiredDescription
enabledbooleanYesNew status of the grouper

Request Body Example​

{
"enabled": true
}

Example Usage​

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

const data = {
enabled: true,
};

fetch("https://api.nilo.com/grouper/7234/status/promotion", {
method: "PUT",
headers: headers,
body: JSON.stringify(data),
})
.then((response) => response.json())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));

Batch Operations​

Batch Update Promotion Groupers​

POST/batch/grouper/promotion

Update multiple promotion groupers in a single operation.

Request Body Parameters​

ParameterTypeRequiredDescription
addobjectNoStores to add to groupers
removeobjectNoStores to remove from groupers

Request Body Example​

{
"add": {
"stores": [
{
"groupInternalCode": "2345",
"storeInternalCode": "124f"
}
]
},
"remove": {
"stores": [
{
"groupInternalCode": "2345",
"storeInternalCode": "125f"
}
]
}
}

Example Usage​

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

const data = {
add: {
stores: [
{
groupInternalCode: "2345",
storeInternalCode: "124f",
},
],
},
remove: {
stores: [
{
groupInternalCode: "2345",
storeInternalCode: "125f",
},
],
},
};

fetch("https://api.nilo.com/batch/grouper/promotion", {
method: "POST",
headers: headers,
body: JSON.stringify(data),
})
.then((response) => response.json())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));

Batch Upsert Promotion Groupers​

POST/batch/grouper/promotion/upsert

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

Use this endpoint when you need to:

  • Synchronize your promotion grouper structure from your ERP system
  • Create or update multiple promotion groupers simultaneously
  • Perform bulk imports of promotion grouper configurations

Request Body Parameters​

ParameterTypeRequiredDescription
upsertarrayYesArray of promotion grouper objects
upsert[].namestringYesGrouper name
upsert[].internalCodestringYesUnique grouper code (same as in ERP)
upsert[].enabledbooleanYesWhether the grouper is active

Request Body Example​

{
"upsert": [
{
"name": "Region North Promotions",
"internalCode": "PROMO-GRP-001",
"enabled": true
},
{
"name": "Region South Promotions",
"internalCode": "PROMO-GRP-002",
"enabled": true
},
{
"name": "Special Channel",
"internalCode": "PROMO-GRP-003",
"enabled": false
}
]
}

Response Codes​

CodeDescription
202Request accepted, processing initiated
402Bad request - Invalid parameters

Response Example​

{
"code": 202,
"batchIds": {},
"message": "Operation in processing"
}

Example Usage​

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

const data = {
upsert: [
{
name: "Region North Promotions",
internalCode: "PROMO-GRP-001",
enabled: true,
},
{
name: "Region South Promotions",
internalCode: "PROMO-GRP-002",
enabled: true,
},
],
};

fetch(
"https://tm0cs5kjs6.execute-api.us-east-1.amazonaws.com/dev/batch/grouper/promotion/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": "PROMOTION_GROUP_NOT_FOUND",
"object": {
"statusCode": 404,
"code": "PROMOTION_GROUP_NOT_FOUND",
"message": "Promotion group not found",
"entity": "promotionGroup",
"entityCode": "PROMO-GRP-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
PROMOTION_GROUP_NOT_FOUNDThe promotion grouper does not exist
STORE_NOT_FOUNDThe store specified in the operation does not exist

409 — Conflict​

Error CodeDescription
NAME_ALREADY_EXISTA promotion grouper with the same name already exists
INTERNAL_CODE_ALREADY_EXISTA promotion grouper with the same internal code already exists
STORE_ALREADY_IN_PROMOTION_GROUPThe store is already assigned to this promotion grouper
STORE_NOT_IN_PROMOTION_GROUPThe store is not assigned to this promotion grouper (when trying to remove)

Security​

Authentication​

All endpoints require two types of authentication:

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

Required Permissions​

For promotion grouper endpoints, the following permissions are required:

  • For write operations: supplier/grouper.write
  • For batch operations: supplier/grouper.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.