Creating custom attributes for sourcing by using an API

You can create different types of custom attributes by using the createCustomAttribute API. After you create a custom attribute for sourcing purposes, you can define a promising rule to associate with it. Then, this rule is considered during the pre-purchase fulfillment calculations.

Before you begin

Procedure

  1. Open the createCustomAttribute API.
  2. Define a new custom attribute and specify the business purpose for which it is used.
    For example, you can define a new sourcing attribute that is called 3p.channel for sourcing purposes:
    POST https://api.watsoncommerce.ibm.com/configuration/{tenant}/v1/attributes/3p.channel
    {
      "isEnabled": true,
      "datatype": "string",
      "businessPurposes": [ "sourcing" ]
    }
  3. Create a new sourcing rule for this custom attribute.
    For example, you can define a new sourcing rule to consider only node1-node3 when the 3p.channel is Y.
    POST https://api.watsoncommerce.ibm.com/promising/{tenant}/v1/sourcing/rules
    {
      "isEnabled": true,
      "name": "3p.channel sourcing node restriction",
      "desc": "Only allow certain nodes when 3p.channel is Y",
      "effectiveDate": { "from": "2020-01-01T00:00:00Z", "to": "2030-01-01T00:00:00Z" },
      "expr": {
        "and": [
          { "3p.channel": { "eq": "Y" } },
        ]
      },
      "action": {
        "locationRestrictions": {
          "node": {
            "operator": "in",
            "value": [ "node1", "node2", "node3" ]
          }
        }
      }
    }
  4. Open the Calculate item delivery or pickup date using finite capacity windows (EDD) API and the Calculate pre-purchase shipment assignments using finite capacity windows (Checkout Assignments) API and pass the 3p.channel in sourcing criteria as shown in the following examples:
    POST https://api.watsoncommerce.ibm.com/promising/{tenantId}/v2/edd
    {
      "deliveryMethod": "SHP",
      "capacityUomToConsider": "UNITS",
      "shippingGroupId": "Free_Economy",
      "sourcingCriteria": { "3p.channel": "Y" },
      "destination": { "format": "ADDRESS", "value": { "countryCode": "US", "postalCode": "02144" } },
      "capacityCategoriesToConsider": { "categoryIds": [ "STANDARD_PRODUCT_CAPACITY" ] },
      "itemInfo": { "itemId": "LARGE_TV", "unitOfMeasure": "EACH", "productClass": "NEW" }
    }
    POST https://api.watsoncommerce.ibm.com/promising/{tenantId}/v2/calculateCheckoutAssignments
    {
      "deliveryMethod": "SHP",
      "capacityUomToConsider": "UNITS",
      "shippingGroupId": "Free_Economy",
      "sourcingCriteria": { "3p.channel": "Y" },
      "destination": { "format": "ADDRESS", "value": { "countryCode": "US", "postalCode": "02144" } },
      "cartLines": [
        {
          "lineNo": 1,
           "quantity": 1, "itemInfo": { "itemId": "LARGE_TV", "unitOfMeasure": "EACH", "productClass": "NEW" },
          "sourcingCriteria": { "3p.channel": "N" },
          "capacityCategoriesToConsider": { "categoryIds": [ "STANDARD_PRODUCT_CAPACITY" ] },
        },
    	{
          "lineNo": 2,
          "quantity": 2, "itemInfo": { "itemId": "FLOWERS", "unitOfMeasure": "EACH", "productClass": "NEW" },
          "sourcingCriteria": { "3p.channel": "Y" },
          "capacityCategoriesToConsider": { "categoryIds": [ "STANDARD_PRODUCT_CAPACITY" ] },
        }
      ]
    }
    For the Checkout assignments API, Line 1 does not consider the rule because 3p.channel is set to N but Line 2 does consider the rule. For Line 2, the sourcingCriteria can be left blank because it is already defined as 'Y' at the order level.