Public APIs for Custom Pricing (CP)

B2B/Wholesale Custom Pricing Public API for Shopify Stores

Custom pricing public API is an feature of B2B/Wholesale Solution shopify app. To use APIs, you must install app, upgrade to Platinum plan and get the access key.

These APIs are REST APIs. You can use them to manage customer pricing rules, calculate variants' price based on rules, search customers, get products, etc. Detailed instructions on how to do it is showing bellow:

How to get the access key

After you install B2B/Wholesale Solution Shopify app. Go to Public API page, click on the Copy button.

Rule endpoints

There are fields of rule, you need to understand: - priority: decides whether a rule is prioritized over another or not. - status:

0: inactive
1: active

- apply_to:

0: All customers
1: Logged-in customers
2: Not-logged-in customers
3: Specific customers
4: Customer tags

- exclude_customer:

0: None
1: Customer tags
2: Specific customers

- product_condition_type:

0: All products
1: Specific products
2: Product collections
3: Product tags
4: Specific variants

- exc_product_type:

0: None
1: Specific products
2: Product collections
3: Product tags
4: Specific variants

- discount_type:

0: Apply a price to selected products
1: Decrease a fixed amount of the original prices of selected products
2: Decrease the original prices of selected products by a percentage (%)

- market_condition_type:

0: All markets
1: Specific markets

Get rules by domain

POST https://b2b-solution-public-api.bsscommerce.com/api/v1/rule/get-by-domain

Headers

Body

{ 
  "domain": "abc.myshopify.com", 
  "accessKey": "xxx" 
}

Response

{
    "success": true,
    "rules": [
        {
            "id": 536662,
            "shop_id": 9204,
            "name": "Discount 20%l",
            "priority": 1,
            "status": 1,
            "apply_to": 0,
            "customer_ids": [],
            "customer_tags": [],
            "product_condition_type": 4,
            "product_ids": [],
            "variant_ids": [
                "6586590625965",
                "6586590658733",
                "6586590691501"
            ],
            "product_collections": [],
            "product_tags": [],
            "discount_type": 2,
            "discount_value": "10.00",
            "published_at": null,
            "unpublished_at": null,
            "date_rule_type": 0,
            "start_date": null,
            "end_date": null,
            "exc_customer_tags": "",
            "exclude_from": 0,
            "exc_customers": "",
            "market_condition_type": 1,
            "market_ids": [
                "49314136349"
            ],
            "file_theme_index": 0,
            "createdAt": "2023-03-09T03:38:50.000Z",
            "updatedAt": "2023-06-15T02:16:47.000Z"
        },
        {
            "id": 545507,
            "shop_id": 9204,
            "name": "test4",
            "priority": 0,
            "status": 0,
            "apply_to": 3,
            "customer_ids": [
                "6819529654557",
                "6905095291165"
            ],
            "customer_tags": [],
            "product_condition_type": 0,
            "product_ids": [
                "8174450049309"
            ],
            "product_collections": [],
            "product_tags": [],
            "discount_type": 0,
            "discount_value": "50.00",
            "published_at": null,
            "unpublished_at": null,
            "date_rule_type": 0,
            "start_date": null,
            "end_date": null,
            "exc_customer_tags": "",
            "exclude_from": 0,
            "exc_customers": "",
            "market_condition_type": 0,
            "market_ids": [],
            "file_theme_index": 0,
            "createdAt": "2023-03-15T07:33:24.000Z",
            "updatedAt": "2023-06-05T01:59:50.000Z"
        }
    ]
}

Get rule by ID

POST https://b2b-solution-public-api.bsscommerce.com/api/v1/rule/get-by-id

Headers

Body

{
  "domain": "abc.myshopify.com", 
  "accessKey": "xxx",
  "id": 79
}

Response

{
    "success": true,
    "rule": {
        "id": 79,
        "name": "Discount 20%l",
        "priority": 1,
        "status": 1,
        "apply_to": 0,
        "customer_ids": [],
        "customer_tags": [],
        "exclude_from": 0,
        "exc_customers": [],
        "exc_customer_tags": [],
        "product_condition_type": 4,
        "product_ids": [],
        "variant_ids": [
            "6586590625965",
            "6586590658733",
            "6586590691501"
        ],
        "product_collections": [],
        "product_tags": [],
        "market_condition_type": 1,
        "market_ids": [
            "49314136349"
        ],
        "discount_type": 2,
        "discount_value": "10.00",
        "start_date": null,
        "end_date": null
    }
}

Create or Update a single rule

POST https://b2b-solution-public-api.bsscommerce.com/api/v1/rule/save

Headers

Body

If there is no ID in the request data, a new rule will be created. Otherwise, the existing rule with ID will be updated.

{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx",
   "rule": {
        "name": "Test rule",
        "priority": 1,
        "status": 0,
        "apply_to": 1,
        "product_condition_type":4,
        "customer_ids": [],
        "customer_tags": [],
        "product_ids": [
           "5460196589730"
         ],
        "variant_ids": [],
        "product_collections": [],
        "product_tags": [],
        "discount_type": 2,
        "discount_value": "40",
        "exclude_from":0,
        "exc_customers": ["5462063382693"],
        "exc_customer_tags": [],
        "exc_product_type": 4,
        "exc_specific_products": [],
        "exc_product_tags": [],
        "exc_product_collections": [],
        "exc_product_variants": [
            44531061752093,
            45056544342301
        ],
        "market_condition_type": 0,
        "market_ids": []
    }
}

Response

{
    "success": true,
    "message": "Create the rule successfully",
    "ruleId": 11
}

Create or Update multiple rules

POST https://b2b-solution-public-api.bsscommerce.com/api/v1/rule/bulk-save

Headers

Body

If there is no ID in the request data, a new rule will be created. Otherwise, the existing rule with ID will be updated.

{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx",
  "rules": [
  {
        "name": "sencond1",
        "priority": 0,
        "status": 1,
        "apply_to": 0,
        "product_condition_type": 0,
        "customer_ids": [],
        "customer_tags": [],
        "product_ids": [],
        "variant_ids": [],
        "product_collections": [],
        "product_tags": [],
        "exc_customer_tags": "",
        "exclude_from": 0,
        "exc_customers": "",
        "exc_product_type": 0,
        "exc_specific_products": [],
        "exc_product_tags": [],
        "exc_product_collections": [],
        "exc_product_variants": [],
        "discount_type": 2,
        "discount_value": 10.00,
        "date_rule_type": 0,
        "start_date": null,
        "end_date": null,
        "market_condition_type": 0,
        "market_ids": null
  },
    {
            "id": 545507,
            "name": "test4",
            "priority": 0,
            "status": 0,
            "apply_to": 3,
            "customer_ids": [
                "6819529654557",
                "6905095291165"
            ],
            "customer_tags": [],
            "product_condition_type": 0,
            "product_ids": [
                "8174450049309"
            ],
            "variant_ids": [],
            "product_collections": [],
            "product_tags": [],
            "discount_type": 0,
            "discount_value": "50.00",
            "date_rule_type": 0,
            "start_date": null,
            "end_date": null,
            "exc_customer_tags": "",
            "exclude_from": 0,
            "exc_product_type": 3,
            "exc_specific_products": [],
            "exc_product_tags": [
                "b2b",
                "wholesale"
            ],
            "exc_product_collections": [],
            "exc_product_variants": [],
            "exc_customers": "",
            "market_condition_type": 0,
            "market_ids": []
    }
  ]
}

Response

{
    "success": true,
    "message": [
        "Create new rule 'sencond1' with ID 214780831 successfully",
        "Update rule 'test4' with ID 545507 successfully"
    ]
}

Delete rule

POST https://b2b-solution-public-api.bsscommerce.com/api/v1/rule/delete

Headers

Body

{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx",
  "id": 79
}

Response

{
  "success": true,
  "message": "Deleted rule ID 79 successfully"
}

Delete multiple rules

POST https://b2b-solution-public-api.bsscommerce.com/api/v1/rule/mass-delete

Headers

Body

{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx",
  "ids": [79,80,81]
}

Response

{
  "success": true,
  "message": "Deleted multiple rule successfully"
}

Get Applied Rules for Products

POST https://b2b-solution-public-api.bsscommerce.com/api/v1/rule/get-products-applied-rules

Headers

Body

If customer_id is null, the system will check Custom Pricing Rules which applied for all customers or not-logged-in customers.

{
  "domain": "abc.myshopify.com",
  "product_ids": [ 6586590625965, 6586590658733, 6586590691501 ],
  "customer_id": 5127974846637,
  "accessKey": "xxxx"
}

Response

{
   "success":true,
   "productsAppliedRule":[
      {
         "id":"6586590625965",
         "discount_type":2,
         "value":"10.00",
         "name":"Discount 30%"
      },
      {
         "id":"6586590658733",
         "discount_type":2,
         "value":"10.00",
         "name":"Discount 30%"
      },
      {
         "id":"6586590691501",
         "discount_type":2,
         "value":"10.00",
         "name":"Discount 30%"
      }
   ]
}

Get Price List of Variants based on Applied Rules

POST https://b2b-solution-public-api.bsscommerce.com/api/v1/rule/get-variants-price-list

Headers

Body

If customer_id is null, the system will check Custom Pricing Rules which applied to all customers or not-logged-in customers.

{
  "domain": "abc.myshopify.com",
  "product_ids": [ 6586590625965, 6586590658733, 6586590691501 ],
  "customer_id": 5127974846637,
  "accessKey": "xxx"
}

Response

{
   "success":true,
   "priceList":[
      {
         "id":"6586590625965",
         "discount_type":2,
         "value":"10.00",
         "name":"Discount 30%",
         "variants":[
            {
               "id":"39454422368429",
               "price":"70",
               "compareAtPrice":"85",
               "appliedRulePrice":63
            },
            {
               "id":"39454422401197",
               "price":"55",
               "compareAtPrice":"85",
               "appliedRulePrice":49.5
            }
         ]
      },
      {
         "id":"6586590658733",
         "discount_type":2,
         "value":"10.00",
         "name":"Discount 30%",
         "variants":[
            {
               "id":"39454422433965",
               "price":"40",
               "compareAtPrice":"44",
               "appliedRulePrice":36
            }
         ]
      },
      {
         "id":"6586590691501",
         "discount_type":2,
         "value":"10.00",
         "name":"Discount 30%",
         "variants":[
            {
               "id":"39454422466733",
               "price":"43",
               "compareAtPrice":"45",
               "appliedRulePrice":38.7
            }
         ]
      }
   ]
}

Product endpoints

Search products

POST https://b2b-solution-public-api.bsscommerce.com/api/v1/product/search

Headers

Body

Index is a cursor value, where you want to start searching. If afterIndex is null, the system will search products from the beginning. For example:

afterIndex: "eyJsYXN0X2lkIjo2NjU1NDU2Mzc5MDUzLCJsYXN0X3ZhbHVlIjo2NjU1NDU2Mzc5MDUzfQ=="
{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx",
  "afterIndex": null,
  "first": 20,
  "searchQuery": "ocean"
}

Response

{
   "success":true,
   "productList":{
      "edges":[
         {
            "node":{
               "id":"gid://shopify/Product/6586580271277",
               "title":"Ocean Blue Shirt",
               "handle":"ocean-blue-shirt",
               "productType":"",
               "totalVariants":1,
               "hasOnlyDefaultVariant":true,
               "priceRange":{
                  "minVariantPrice":{
                     "currencyCode":"VND",
                     "amount":"50.0"
                  },
                  "maxVariantPrice":{
                     "currencyCode":"VND",
                     "amount":"50.0"
                  }
               },
               "featuredImage":{
                  "transformedSrc":"https://cdn.shopify.com/s/files/1/0538/3874/1677/products/young-man-in-bright-fashion_925x_5251bcfa-6939-4d7a-9287-dd9bf058ed03.jpg?v=1616405807"
               },
               "onlineStoreUrl":null
            },
            "cursor":"eyJsYXN0X2lkIjo2NTg2NTgwMjcxMjc3LCJsYXN0X3ZhbHVlIjo2NTg2NTgwMjcxMjc3fQ=="
         },
         {
            "node":{
               "id":"gid://shopify/Product/6655456379053",
               "title":"Riri Bracelet",
               "handle":"riri-bracelet-rose",
               "productType":"women's bracelets",
               "totalVariants":1,
               "hasOnlyDefaultVariant":false,
               "priceRange":{
                  "minVariantPrice":{
                     "currencyCode":"VND",
                     "amount":"68.0"
                  },
                  "maxVariantPrice":{
                     "currencyCode":"VND",
                     "amount":"68.0"
                  }
               },
               "featuredImage":{
                  "transformedSrc":"https://cdn.shopify.com/s/files/1/0538/3874/1677/products/2015-04-20_Accessories_31_23500_21376.jpg?v=1619597977"
               },
               "onlineStoreUrl":null
            },
            "cursor":"eyJsYXN0X2lkIjo2NjU1NDU2Mzc5MDUzLCJsYXN0X3ZhbHVlIjo2NjU1NDU2Mzc5MDUzfQ=="
         }
      ],
      "pageInfo":{
         "hasNextPage":false,
         "hasPreviousPage":false
      }
   }
}

Get Product Tags

POST https://b2b-solution-public-api.bsscommerce.com/api/v1/product/get-tags

Headers

Body

{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx"
}

Response

{
   "success":true,
   "productTags":{
      "tags":[
         "cotton blouse",
         "Couch",
         "cowl",
         "cpace",
         "Crane",
         "cream",
         "crepe wool",
         "crew",
         "crew neck",
         "crewneck",
         "crisp"
      ],
      "last_cursor":"Y3Jpc3A="
   }
}

Get Products by Tags

POST https://b2b-solution-public-api.bsscommerce.com/api/v1/product/get-by-tags

Headers

Body

{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx",
  "afterIndex": null,
  "first": 20,
  "tags": ["tag1","tags2","t3"],
  "operation": "AND" 
}

"Operation" is "AND" or "OR". If you use "AND", returned products must contain all tags. If you use "OR", returned products just need to belong to one tag in the array (["tag1","tags2","t3"]).

Response

{
   "success":true,
   "productList":[
      {
         "id":"gid://shopify/Product/6586590625965",
         "title":"Anchor Bracelet Mens",
         "handle":"leather-anchor",
         "productType":"Bracelet",
         "totalVariants":2,
         "hasOnlyDefaultVariant":false,
         "priceRange":{
            "minVariantPrice":{
               "currencyCode":"VND",
               "amount":"55.0"
            },
            "maxVariantPrice":{
               "currencyCode":"VND",
               "amount":"70.0"
            }
         },
         "featuredImage":{
            "transformedSrc":"https://cdn.shopify.com/s/files/1/0538/3874/1677/products/anchor-bracelet-mens_925x_8dcf313c-5c78-41ea-874d-59804d449315.jpg?v=1616407017"
         },
         "onlineStoreUrl":null
      }
   ]
}

Get Products by IDs

POST https://b2b-solution-public-api.bsscommerce.com/api/v1/product/get-by-ids

Headers

Body

{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx",
  "ids": [ 6586590625965 ]
}

Response

{
   "success":true,
   "productList":[
      {
         "id":"gid://shopify/Product/6586590625965",
         "title":"Anchor Bracelet Mens",
         "handle":"leather-anchor",
         "productType":"Bracelet",
         "totalVariants":2,
         "hasOnlyDefaultVariant":false,
         "priceRange":{
            "minVariantPrice":{
               "currencyCode":"VND",
               "amount":"55.0"
            },
            "maxVariantPrice":{
               "currencyCode":"VND",
               "amount":"70.0"
            }
         },
         "featuredImage":{
            "transformedSrc":"https://cdn.shopify.com/s/files/1/0538/3874/1677/products/anchor-bracelet-mens_925x_8dcf313c-5c78-41ea-874d-59804d449315.jpg?v=1616407017"
         },
         "onlineStoreUrl":null
      }
   ]
}

Customer endpoints

Search Customers

POST https://b2b-solution-public-api.bsscommerce.com/api/v1/customer/search

Headers

Body

{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx",
  "afterIndex": null,
  "first": 20,
  "searchQuery": "nta"
}

Response

{
   "success":true,
   "customers":[
      {
         "node":{
            "id":"gid://shopify/Customer/5127974846637",
            "displayName":"nta",
            "email":"abc@gmail.com",
            "firstName":"n",
            "lastName":"ta",
            "phone":null,
            "tags":[
               "wholesale"
            ],
            "note":""
         },
         "cursor":"eyJsYXN0X2lkIjo1MTI3OTc0ODQ2NjM3LCJsYXN0X3ZhbHVlIjo1MTI3OTc0ODQ2NjM3fQ=="
      }
   ]
}

Get Customer Tags

POST https://b2b-solution-public-api.bsscommerce.com/api/v1/customer/get-tags

Headers

Body

{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx"
}

Response

{
   "success":true,
   "customerTags":[
      {
         "node":"wholesale",
         "cursor":"d2hvbGVzYWxl"
      }
   ]
}

Get Customers by IDs

POST https://b2b-solution-public-api.bsscommerce.com/api/v1/customer/get-by-ids

Headers

Body

{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx",
  "ids": [5127974846637]
}

Response

{
   "success":true,
   "customerList":[
      {
         "id":"gid://shopify/Customer/5127974846637",
         "displayName":"nta",
         "email":"abc@gmail.com",
         "firstName":"n",
         "lastName":"ta"
      }
   ]
}

Get Customers by Tags

POST https://b2b-solution-public-api.bsscommerce.com/api/v1/customer/get-by-tags

Headers

Body

{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx",
  "afterIndex": null,
  "first": 20,
  "tags": ["tag1", "tags2"],
  "operation": "AND" 
}

"Operation" is "AND" or "OR". If you use "AND", returned products must contain all tags. If you use "OR", returned products just need to belong to one tag in the array (["tag1", "tags2"]).

Response

{
   "success":true,
   "customers":[
      {
         "node":{
            "id":"gid://shopify/Customer/5127974846637",
            "displayName":"nta",
            "email":"abc@gmail.com",
            "firstName":"n",
            "lastName":"ta",
            "phone":null,
            "tags":[
               "wholesale"
            ],
            "note":""
         },
         "cursor":"eyJsYXN0X2lkIjo1MTI3OTc0ODQ2NjM3LCJsYXN0X3ZhbHVlIjo1MTI3OTc0ODQ2NjM3fQ=="
      }
   ]
}

Collection endpoints

Get Collections

POST https://b2b-solution-public-api.bsscommerce.com/api/v1/customer/search

Request URL: https://b2b-solution-public-api.bsscommerce.com/api/v1/customer/search

Headers

Body

{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx",
  "afterIndex": null,
  "first": 20,
  "searchQuery": "nta"
}

Response

{
   "success":true,
   "customers":[
      {
         "node":{
            "id":"gid://shopify/Customer/5127974846637",
            "displayName":"nta",
            "email":"abc@gmail.com",
            "firstName":"n",
            "lastName":"ta",
            "phone":null,
            "tags":[
               "wholesale"
            ],
            "note":""
         },
         "cursor":"eyJsYXN0X2lkIjo1MTI3OTc0ODQ2NjM3LCJsYXN0X3ZhbHVlIjo1MTI3OTc0ODQ2NjM3fQ=="
      }
   ]
}

How do we handle your request?

  • We handle one request at a time. Once your request is completed, we will proceed with the next one.

  • In case of a server error, it may take up to 3 minutes to recover and process a new request.

Last updated