docs
  1. SCAYLE Resource Center
  2. Developer Guides
  3. Pricing & Promotions
  4. Audiences

Audiences

Audiences within the SCAYLE Promotion Engine are finely tuned segments that enable precise customer outreach. These subsets allow you to craft tailored messages and promotions, ensuring resonance with specific customer characteristics, behaviors, or preferences.

Managing Audiences in Admin API

The Admin API offers several endpoints for managing audiences.

  • Create audience
  • Get audience
  • List audiences
  • Update audience
  • Delete audience

Create an Audience

Method signature

let response = await client.apis.Promotions.createAudience({}, {requestBody: audience});
let createdAudience = response.body;

Request body

All fields are required.

At least one company id value has to be provided within thecompanyIdsfield.

At least one customer id value has to be provided within thecustomerIdsfield.

PropertyDescription
name String

Internal name of the audience
descriptionString

Internal description of the audience
companyIdsInteger[], unique items

The list of company ids where the audience takes place
customerIdsInteger[], unique items

The list of customer ids

Example - Create an audience

let audience = {
    name: "VIP customers",
    description: "German VIP Customers from Hamburg only",
    companyIds: [
        100
    ],
    customerIds: [
        345,
        456,
        567
    ]
};

let response = await client.apis.Promotions.createAudience({}, {requestBody: audience});
let createdAudience = response.body;

console.log(createdAudience.id);

Update an audience

Method signature

let response = await client.apis.Promotions.updateAudience({audienceId: 'audienceId'}, {requestBody: audience});
let createdAudience = response.body;

Request body

All fields are required.

Note that when updating an audience, companyIds cannot be modified. You can only modify this parameter when creating the audience.

At least one customer id value has to be provided within thecustomerIdsfield.

PropertyDescription
name String

Internal name of the audience
descriptionString

Internal description of the audience
customerIdsInteger[], unique items

The list of customer ids

Example - Update an audience

let audience = {
  name: 'VIP customers updated',
  description: 'German VIP Customers from Hamburg only',
  customerIds: [345,456,567]
};

let response = await client.apis.Promotions.updateAudience({audienceId: '645e0c241a93369ff53f26e0'}, {requestBody: audience});
let updatedAudience = response.body;

console.log(updatedAudience.name);

Listing audiences

You can also request several audiences. We suggest that you fine-tune your search by, for example, combining filters and using pagination. As search results are paginated, you can set the amount of audiences displayed per page.

Method signature

let response = await client.apis.Promotions.getAudiences({});
let audiences = response.body.entities;

Options

ParameterDescription
filters[id]String

Comma-separated list of IDs of audiences that should be used for filtering.
filters[name]String

Name of audience
filters[companyId]String

Comma-separated list of company IDs that should be used for filtering.
filters[customerId]String

Comma-separated list of customer IDs that should be used for filtering.
cursorString

Valid cursor used for pagination.
limitInteger

Maximum number of entities in the result. Default value: 100
Min value: 1
Max value: 1000

Example - List audiences

Filter by id, name, companyIds, customerIds. Limit result set to 10 items per page, return the second page, using base64_encode(2)

let response = await client.apis.Promotions.getAudiences({
  'filters[id]' : '645e0c241a93369ff53f26e0'
  'filters[name]' : 'VIP customers',
  'filters[companyId]' : '100,101',
  'filters[customerId]' : '345,456,567',
  'limit' : 10,
  'cursor' : 'Mg=='
});
let audiences = response.body.entities;

audiences.forEach(
  audience => console.log(audience.name)
);

Get a single audience

Get a single audience by audience id.

Method signature

response = await client.apis.Promotions.getAudience({audienceId: 'audienceId'});
let audience = response.body;

Example

response = await client.apis.Promotions.getAudience({audienceId: '645e0c241a93369ff53f26e0'});
let audience = response.body;

console.log(audience.name);

Delete an audience

Delete a single audience by audience id.

Method signature

await client.apis.Promotions.deleteAudience({audienceId: 'audienceId'});

Example

await client.apis.Promotions.deleteAudience({audienceId: '645e0c241a93369ff53f26e0'});