Skip to main content

Creates a new catalog rule

POST 

https://euwest.api.elasticpath.com/catalogs/rules

If you have multiple catalogs, create catalog rule resources. With catalog rules, you can display different catalogs to different shoppers. For example, you can display a preferred pricing catalog to a few special customers. Or you can display one catalog to shoppers using your website and a different catalog to shoppers using your mobile app. Finally, you can define custom criteria by creating tags.

note
  • If you have one catalog for all customers and channels, you can omit creating this resource.
  • Due to the way catalogs are cached in Commerce, using catalog rules to display catalogs sometimes causes a 5-minute time delay before the catalogs are displayed.
  • You cannot create catalog rules for organization catalogs.

For ideas about the kinds of business scenarios you can achieve with catalog rules, see Catalog Rules. To understand how catalogs are matched to shoppers by using rules, see Resolving Catalog Rules.

Request

Bodyrequired

Creates a catalog rule with the following attributes.

    data objectrequired
    attributes objectrequired
    namestringrequired

    The name of a catalog rule. The name must not contain spaces.

    Possible values: non-empty

    Example: rule-123
    descriptionstringnullable

    A brief description of the purpose of a catalog rule.

    Default value:
    Example: Catalog Rule for most favored customers
    account_idsstring[]nullable

    The list of accounts who are eligible to see this catalog. If this field is empty, the rule matches all accounts.

    customer_idsstring[]nullable

    The list of customers who are eligible to see this catalog. If empty, the rule matches all customers.

    channelsstring[]nullable

    The list of channels in which this catalog can be displayed. A channel is the shopping experience, such as a mobile app or web storefront. If empty, the catalog rule matches all channels. The channel will eventually be included in the bearer token that is used for authorization, but currently, you must set the EP-Channel header in your requests.

    tagsstring[]nullable

    A list of user-defined tags that can be used to further restrict the eligibility criteria for this rule. Requests populate the catalog rule tag using the EP-Context-Tag header.

    schedules object[]nullable

    Specifies a time period when a catalog is displayed, such as on a specific date or during summer. Requests populate the rule tag using the EP-Context-Tag header.

    The schedules attribute must include the following.

    • valid_from matches the date and time that the catalog is displayed from.
    • valid_to matches the date and time the catalog is displayed to.

    Commerce runs on UTC time.

    You can offset the timezone by adding the offset to the end of the date and time. For example, a catalog which contains a sale hierarchy that should appear for a set timeframe may be scheduled to publish on a given date and time within a given timezone. For instance, a sale that should begin on 1st of June 2022 05:00 ET and end on the 15th of June 2022 at 23:50 PT would have a valid schedule of "valid_from": "2022-06-01T05:00:00.000-05:00", "valid_to": "2022-06-15T11:59:99.000-08:00".

  • Array [
  • valid_fromdate-timenullable

    Matches the date and time that the catalog is displayed from.

    Example: 2020-09-22T09:00:00
    valid_todate-timenullable

    Matches the date and time the catalog is displayed to.

    Example: 2020-09-22T09:00:00
  • ]
  • catalog_idstringrequired

    The unique identifier of a catalog.

    Example: d09b4e16-08a5-4f42-817c-6e0d98acbb63
    pricebook_idstringnullable

    The unique identifier of a price book to associate with a rule. You can specify a pricebook_id or a pricebook_ids but not both. If you specify both, a 422 unprocessable entity error is displayed.

    pricebook_ids object[]

    If you want multiple price books for different scenarios, such as seasonal sales, business versus retail pricing, and reward programs, when creating a catalog, you can specify up to five price books. You must configure a priority for your price books. Product prices are displayed in the catalog according to the priority of the price books.

    Possible values: <= 5

  • Array [
  • iduuidrequired

    A unique identifier of a price book.

    priorityintegerrequired

    Priority is a number and the price book with the highest number has the highest priority.

  • ]
  • typestringrequired

    This represents the type of object being returned. Always catalog_rule.

    Possible values: [catalog_rule]

    Example: catalog_rule

Responses

The created catalog rule

Schema
    data objectrequired

    A catalog rule specifies which catalog to use for a given shopper context.

    idstringrequired

    The catalog rule ID. Use this to get, modify, or delete the catalog rule.

    Example: 8dbb35b2-ef04-477e-974d-e5f3abe6faae
    attributes objectrequired
    namestringrequired

    The name of a catalog rule. The name must not contain any spaces.

    Example: rule-123
    descriptionstring

    A brief description of the purpose of a catalog rule.

    Default value:
    Example: Catalog Rule for most favored customers
    account_idsstring[]

    The list of accounts who are eligible to see this catalog. If this field is empty, the rule matches all accounts.

    customer_idsstring[]

    The list of customers who are eligible to see this catalog. If empty, the rule matches all customers.

    channelsstring[]

    The list of channels in which this catalog can be displayed. A channel is the shopping experience, such as a mobile app or web storefront. If empty, the catalog rule matches all channels. The channel will eventually be included in the bearer token that is used for authorization, but currently, you must set the EP-Channel header in your requests.

    tagsstring[]

    A list of user-defined tags that can be used to further restrict the eligibility criteria for this rule. Requests populate the catalog rule tag using the EP-Context-Tag header.

    schedules object[]

    Specifies a time period when a catalog is displayed, such as on a specific date or during summer. Requests populate the rule tag using the EP-Context-Tag header.

    The schedules attribute must include the following.

    • valid_from matches the date and time that the catalog is displayed from.
    • valid_to matches the date and time the catalog is displayed to.

    Commerce runs on UTC time.

    You can offset the timezone by adding the offset to the end of the date and time. For example, a catalog which contains a sale hierarchy that should appear for a set timeframe may be scheduled to publish on a given date and time within a given timezone. For instance, a sale that should begin on 1st of June 2022 05:00 ET and end on the 15th of June 2022 at 23:50 PT would have a valid schedule of "valid_from": "2022-06-01T05:00:00.000-05:00", "valid_to": "2022-06-15T11:59:99.000-08:00".

  • Array [
  • valid_fromdate-timenullable

    Matches the date and time that the catalog is displayed from.

    Example: 2020-09-22T09:00:00
    valid_todate-timenullable

    Matches the date and time the catalog is displayed to.

    Example: 2020-09-22T09:00:00
  • ]
  • catalog_idstringrequired

    The unique identifier of a catalog.

    Example: d09b4e16-08a5-4f42-817c-6e0d98acbb63
    created_atdate-timerequired

    The date and time a catalog rule was created.

    Example: 2020-09-22T09:00:00
    updated_atdate-timerequired

    The date and time a catalog release is updated.

    Example: 2020-09-22T09:00:00
    pricebook_idstringnullable

    The unique identifier of a price book to associate with a rule. You can specify a pricebook_id or a pricebook_ids but not both. If you specify both, a 422 unprocessable entity error is displayed.

    pricebook_ids object[]

    If you want multiple price books for different scenarios, such as seasonal sales, business versus retail pricing, and reward programs, when creating a catalog, you can specify up to five price books. You must configure a priority for your price books. Product prices are displayed in the catalog according to the priority of the price books.

    Possible values: <= 5

  • Array [
  • iduuidrequired

    A unique identifier of a price book.

    priorityintegerrequired

    Priority is a number and the price book with the highest number has the highest priority.

  • ]
  • typestringrequired

    This represents the type of object being returned. Always catalog_rule.

    Possible values: [catalog_rule]

    Example: catalog_rule
    links object

    Links allow you to move between requests.

    selfurinullable

    Single entities use a self parameter with a link the specific resource.

    firsturinullable

    Always the first page.

    lasturinullable

    This is null if there is only one page.

    prevurinullable

    This is null if there is only one page.

    nexturinullable

    This is null if there is only one page.

Authorization: Authorization

name: Authorizationtype: httpin: headerscheme: bearer
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://euwest.api.elasticpath.com/catalogs/rules");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer <Authorization>");
var content = new StringContent("{\n \"data\": {\n \"attributes\": {\n \"name\": \"rule-123\",\n \"description\": \"Catalog Rule for most favored customers\",\n \"account_ids\": [\n \"string\"\n ],\n \"customer_ids\": [\n \"string\"\n ],\n \"channels\": [\n \"string\"\n ],\n \"tags\": [\n \"string\"\n ],\n \"schedules\": [\n {\n \"valid_from\": \"2020-09-22T09:00:00\",\n \"valid_to\": \"2020-09-22T09:00:00\"\n }\n ],\n \"catalog_id\": \"d09b4e16-08a5-4f42-817c-6e0d98acbb63\",\n \"pricebook_id\": \"string\",\n \"pricebook_ids\": [\n {\n \"id\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n \"priority\": 0\n }\n ]\n },\n \"type\": \"catalog_rule\"\n }\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
Request Collapse all
Base URL
https://euwest.api.elasticpath.com
Auth
Body required
{
  "data": {
    "attributes": {
      "name": "rule-123",
      "description": "Catalog Rule for most favored customers",
      "account_ids": [
        "string"
      ],
      "customer_ids": [
        "string"
      ],
      "channels": [
        "string"
      ],
      "tags": [
        "string"
      ],
      "schedules": [
        {
          "valid_from": "2020-09-22T09:00:00",
          "valid_to": "2020-09-22T09:00:00"
        }
      ],
      "catalog_id": "d09b4e16-08a5-4f42-817c-6e0d98acbb63",
      "pricebook_id": "string",
      "pricebook_ids": [
        {
          "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
          "priority": 0
        }
      ]
    },
    "type": "catalog_rule"
  }
}
ResponseClear

Click the Send API Request button above and see the response here!

We use cookies to enhance your experience. By continuing to visit this site you agree to our use of cookies.