# 🔗Public APIs for Custom Pricing (CP)

The **Custom Pricing Public API** is a feature of the **BSS B2B Solution** Shopify app.\
It allows developers to manage and sync **customer-specific pricing rules** directly from external systems such as ERPs, CRMs, or custom integrations.

> ⚙️ **Requirements**
>
> * Install the **BSS B2B Solution** Shopify app
> * Upgrade to the **Platinum plan**
> * Obtain your **Access Key**

These are **REST APIs** — you can use them to:

* Manage customer pricing rules
* Calculate variant prices based on active rules
* Retrieve product and customer data
* Automate B2B price synchronization

***

### 🔑 How to Get Your Access Key

1. Install the **BSS B2B Solution** app from Shopify.
2. Navigate to the **Public API** page inside the app.
3. Click **Copy** to copy your **Access Key**.
4. Include it in every API request body.

***

## 🧱 Rule Endpoints

Before using the endpoints, familiarize yourself with the **Rule model fields** below.

| Field                    | Description                                         | Values                                                                                                                                                                                        |
| ------------------------ | --------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `priority`               | Determines which rule takes precedence over others. | Integer                                                                                                                                                                                       |
| `status`                 | Activation status of the rule.                      | <p><code>0</code>: Inactive<br><code>1</code>: Active</p>                                                                                                                                     |
| `apply_to`               | Defines which customers the rule applies to.        | <p><code>0</code>: All customers<br><code>1</code>: Logged-in customers<br><code>2</code>: Not-logged-in customers<br><code>3</code>: Specific customers<br><code>4</code>: Customer tags</p> |
| `exclude_customer`       | Exclude rules for certain customers.                | <p><code>0</code>: None<br><code>1</code>: Customer tags<br><code>2</code>: Specific customers</p>                                                                                            |
| `product_condition_type` | Determines which products are targeted.             | <p><code>0</code>: All products<br><code>1</code>: Specific products<br><code>2</code>: Product collections<br><code>3</code>: Product tags<br><code>4</code>: Specific variants</p>          |
| `exc_product_type`       | Excludes certain products from the rule.            | <p><code>0</code>: None<br><code>1</code>: Specific products<br><code>2</code>: Product collections<br><code>3</code>: Product tags<br><code>4</code>: Specific variants</p>                  |
| `discount_type`          | Discount method to apply.                           | <p><code>0</code>: Apply a fixed price<br><code>1</code>: Subtract a fixed amount<br><code>2</code>: Subtract a percentage (%)</p>                                                            |
| `market_condition_type`  | Determines which markets the rule applies to.       | <p><code>0</code>: All markets<br><code>1</code>: Specific markets</p>                                                                                                                        |

***

### 📘 Get Rules by Domain

**Endpoint**

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

**Headers**

```
Content-Type: application/json
```

**Request Body**

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

**Response**

{% code expandable="true" %}

```json
{
  "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,
      "variant_ids": ["6586590625965", "6586590658733", "6586590691501"],
      "discount_type": 2,
      "discount_value": "10.00",
      "market_condition_type": 1,
      "market_ids": ["49314136349"],
      "createdAt": "2023-03-09T03:38:50.000Z",
      "updatedAt": "2023-06-15T02:16:47.000Z"
    },
    {
      "id": 545507,
      "name": "test4",
      "status": 0,
      "apply_to": 3,
      "customer_ids": ["6819529654557", "6905095291165"],
      "product_ids": ["8174450049309"],
      "discount_type": 0,
      "discount_value": "50.00",
      "market_condition_type": 0
    }
  ]
}
```

{% endcode %}

***

### 📗 Get Rule by ID

**Endpoint**

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

**Request Body**

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

**Response**

{% code expandable="true" %}

```json
{
  "success": true,
  "rule": {
    "id": 79,
    "name": "Discount 20%l",
    "priority": 1,
    "status": 1,
    "apply_to": 0,
    "variant_ids": ["6586590625965", "6586590658733", "6586590691501"],
    "discount_type": 2,
    "discount_value": "10.00",
    "market_condition_type": 1,
    "market_ids": ["49314136349"]
  }
}
```

{% endcode %}

***

### 📕 Get Rules by Products

**Endpoint**

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

**Request Body**

```json
{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx",
  "product_ids": [7208233467979, 7208233467980],
  "product_tags": ["b2b", "pants"]
}
```

> You can get rules either by **product IDs** or **product tags**.

**Response**

```json
{
  "success": true,
  "data": [
    { "productId": "8249126813999", "ruleId": 40, "ruleName": "VIP group", "appliedPrice": 27100 },
    { "productId": "8249222791471", "ruleId": 40, "ruleName": "VIP group", "appliedPrice": 63.5 }
  ]
}
```

***

### 📙 Get Rules by Customers

**Endpoint**

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

**Request Body**

```json
{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx",
  "customer_ids": [7208233467979, 7208233467980],
  "customer_tags": ["b2b", "pants"]
}
```

> You can get rules by **customer IDs** or **customer tags**.

**Response**

{% code expandable="true" %}

```json
{
  "success": true,
  "data": [
    {
      "customerId": "6764123291723",
      "rules": [
        { "ruleId": 2151079182, "ruleName": "Wholesale", "customerTags": ["b2b"] }
      ]
    }
  ]
}
```

{% endcode %}

***

### ✏️ Create or Update a Single Rule

**Endpoint**

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

> If no `id` is provided, a new rule is created.\
> If `id` exists, the existing rule is updated.

**Request Body**

{% code expandable="true" %}

```json
{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx",
  "rule": {
    "name": "Test rule",
    "priority": 1,
    "status": 0,
    "apply_to": 1,
    "product_condition_type": 4,
    "product_ids": ["5460196589730"],
    "discount_type": 2,
    "discount_value": "40",
    "exc_product_variants": [44531061752093, 45056544342301]
  }
}
```

{% endcode %}

**Response**

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

***

### ✨ Create or Update Multiple Rules

**Endpoint**

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

**Request Body**

{% code expandable="true" %}

```json
{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx",
  "rules": [
    {
      "name": "sencond1",
      "priority": 0,
      "status": 1,
      "discount_type": 2,
      "discount_value": 10.0
    },
    {
      "id": 545507,
      "name": "test4",
      "status": 0,
      "discount_type": 0,
      "discount_value": "50.00",
      "exc_product_tags": ["b2b", "wholesale"]
    }
  ]
}
```

{% endcode %}

**Response**

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

***

### ❌ Delete a Rule

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

**Body**

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

**Response**

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

***

### 🗑️ Delete Multiple Rules

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

**Body**

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

**Response**

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

***

### 🧹 Remove Existing Products from Rules

```
PUT https://b2b-solution-public-api.bsscommerce.com/api/v1/rule/delete-items
```

**Request Body**

```json
{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx",
  "rules": [
    {
      "id": 2,
      "product_condition_type": 1,
      "product_ids": ["8746948329722", "8746948821242"]
    }
  ]
}
```

**Response (Success)**

```json
{
  "success": true,
  "message": "Success",
  "data": {
    "success": ["Update rule with id 2 success"],
    "failed": []
  }
}
```

**Response (Error)**

```json
{
  "message": "Fail",
  "data": {
    "failed": [
      { "rule_id": 3, "errors": ["Invalid product_condition_type", "product_ids must be array"] }
    ]
  }
}
```

***

### 🧾 Get Applied Rules for Products

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

> If `customer_id` is `null`, the system checks rules that apply to **all** or **not-logged-in** customers.

**Request Body**

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

**Response**

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

***

### 💰 Get Variant Price List Based on Rules

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

**Request Body**

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

**Response**

{% code expandable="true" %}

```json
{
  "success": true,
  "priceList": [
    {
      "id": "6586590625965",
      "discount_type": 2,
      "value": "10.00",
      "name": "Discount 30%",
      "variants": [
        {
          "id": "39454422368429",
          "price": "70",
          "compareAtPrice": "85",
          "appliedRulePrice": 63
        }
      ]
    }
  ]
}
```

{% endcode %}

***

## 🧭 Product Endpoints

All product endpoints follow the same pattern — `domain` + `accessKey` required.

#### Search Products

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

**Cursor**\
`afterIndex` indicates where to continue fetching.\
If `null`, search starts from the beginning.

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

***

#### Get Product Tags

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

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

***

#### Get Products by Tags

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

* `"operation": "AND"` → all tags must match
* `"operation": "OR"` → any tag matches

***

#### Get Products by IDs

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

***

## 👥 Customer Endpoints

#### Search Customers

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

#### Get Customer Tags

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

#### Get Customers by IDs

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

#### Get Customers by Tags

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

> `"operation": "AND"` → must contain all tags\
> `"operation": "OR"` → contain any tag

***

## 📚 Collection Endpoints

> *Note: The “Get Collections” endpoint currently returns a `customers` array — behavior is identical to `/customer/search`.*

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

***

## ⚙️ Request Handling Policy

* Requests are processed **one at a time**.
* A new request starts only after the previous one completes.
* If a **server error** occurs, please wait up to **3 minutes** before retrying.

***

Would you like me to format this as a **Markdown developer doc** (with copyable code blocks and collapsible sections like Shopify’s API reference style)? It’ll be perfect for publishing to your docs site.

**You said:**

Yes, help me Markdown developer doc (with copyable code blocks and collapsible sections like Shopify’s API reference style

**ChatGPT said:**

Thought for 4 seconds

Below is a **publish-ready Markdown developer doc** you can drop straight into your docs site.\
It uses **collapsible sections** (`<details><summary>…</summary>`) like Shopify’s docs and keeps your technical content **100% accurate**.

***

## B2B B2B Solution **Custom Pricing** Public API for Shopify Stores

The **Custom Pricing Public API** is a feature of the **BSS B2B Solution** Shopify app.

> **Requirements**
>
> * App installed
> * **Platinum** plan
> * **Access Key** (from the app’s **Public API** page → **Copy**)

These REST APIs let you:

* Manage **customer pricing rules**
* **Calculate variant prices** based on active rules
* **Search** customers & **get** products

***

### 🔑 Get the Access Key

1. Open the **B2B/Wholesale Solution** app in Shopify.
2. Go to **Public API**.
3. Click **Copy** to copy your **accessKey**.
4. Include it in every request body.

***

### 📦 Rule Endpoints

#### Rule Model Reference

\<details> \<summary>\<strong>Fields & Enumerations\</strong>\</summary>

**priority** — determines which rule wins when multiple rules apply.

**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
```

\</details>

***

#### Get Rules by Domain

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

**Headers**

```
Content-Type: application/json
```

**Body**

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

**Response (example)**

{% code expandable="true" %}

```json
{
  "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"
    }
  ]
}
```

{% endcode %}

***

#### Get Rule by ID

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

**Headers**

```
Content-Type: application/json
```

**Body**

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

**Response (example)**

{% code expandable="true" %}

```json
{
  "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
  }
}
```

{% endcode %}

***

#### Get Rules by Products

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

**Headers**

```
Content-Type: application/json
```

**Body**

```json
{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx",
  "product_ids": [7208233467979, 7208233467980],
  "product_tags": ["b2b", "pants"]
}
```

> You can choose to get rules by **product IDs** or **product tags**.

**Response (example)**

{% code expandable="true" %}

```json
{
  "success": true,
  "data": [
    {
      "productId": "8249126813999",
      "ruleId": 40,
      "ruleName": "VIP group",
      "appliedPrice": 27100
    },
    {
      "productId": "8249222791471",
      "ruleId": 40,
      "ruleName": "VIP group",
      "appliedPrice": 63.5
    }
  ]
}
```

{% endcode %}

***

#### Get Rules by Customers

**POST** `https://b2b-solution-public-api.bsscommerce.com/api/v1/rule/get-rules-by-customers`

**Headers**

```
Content-Type: application/json
```

**Body**

```json
{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx",
  "customer_ids": [7208233467979, 7208233467980],
  "customer_tags": ["b2b", "pants"]
}
```

> You can choose to get rules by either **customer IDs** or **customer tags**.

**Response (example)**

{% code expandable="true" %}

```json
{
  "success": true,
  "data": [
    {
      "customerId": "6764123291723",
      "rules": [
        {
          "ruleId": 2151079182,
          "ruleName": "Wholesale",
          "customerTags": ["b2b"]
        }
      ]
    },
    {
      "customerId": "7196156198987",
      "rules": [
        {
          "ruleId": 2151079182,
          "ruleName": "Wholesale",
          "customerTags": ["b2b"]
        }
      ]
    },
    {
      "customerId": "7905261387851",
      "rules": [
        {
          "ruleId": 2151079182,
          "ruleName": "Wholesale",
          "customerTags": ["b2b"]
        }
      ]
    }
  ]
}
```

{% endcode %}

***

#### Create or Update a Single Rule

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

**Headers**

```
Content-Type: application/json
```

**Body**

> If there is **no `id`**, a **new** rule is created.\
> If there **is an `id`**, that rule is **updated**.

{% code expandable="true" %}

```json
{
  "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": []
  }
}
```

{% endcode %}

**Response (example)**

```json
{
  "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**

```
Content-Type: application/json
```

**Body**

> If there is **no `id`**, a rule is **created**.\
> If an **`id` exists**, that rule is **updated**.

{% code expandable="true" %}

```json
{
  "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": []
    }
  ]
}
```

{% endcode %}

**Response (example)**

```json
{
  "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**

```
Content-Type: application/json
```

**Body**

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

**Response**

```json
{
  "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**

```
Content-Type: application/json
```

**Body**

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

**Response**

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

***

#### Remove Existing Products from Rules

**PUT** `https://b2b-solution-public-api.bsscommerce.com/api/v1/rule/delete-items`

**Headers**

```
Content-Type: application/json
```

**Body**

{% code expandable="true" %}

```json
{
  "domain": "abc.myshopify.com",
  "accessKey": "xxx",
  "rules": [
    {
      "id": 2,
      "product_condition_type": 1,
      "product_ids": [
        "8746948329722",
        "8746948821242",
        "7622399262970",
        "7622389432570"
      ],
      "product_collections": [],
      "product_tags": [],
      "product_variants": []
    },
    {
      "id": 3,
      "product_condition_type": 1,
      "product_ids": [
        "8746948329722",
        "8746948821242",
        "7622399262970",
        "7622389432570"
      ],
      "product_collections": [],
      "product_tags": [],
      "product_variants": []
    }
  ]
}
```

{% endcode %}

**Response (success)**

```json
{
  "success": true,
  "message": "Success",
  "data": {
    "success": ["Update rule with id 2 success"],
    "failed": []
  }
}
```

**Response (error)**

```json
{
  "message": "Fail",
  "data": {
    "success": [],
    "failed": [
      {
        "rule_id": 3,
        "errors": ["Invalid product_condition_type", "product_ids must be array"]
      }
    ]
  }
}
```

***

#### Get Applied Rules for Products

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

**Headers**

```
Content-Type: application/json
```

**Body**

> If `customer_id` is `null`, the system checks Custom Pricing Rules that apply to **all customers** or **not-logged-in customers**.

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

**Response (example)**

```json
{
  "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**

```
Content-Type: application/json
```

**Body**

> If `customer_id` is `null`, the system checks Custom Pricing Rules that apply to **all customers** or **not-logged-in customers**.

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

**Response (example)**

{% code expandable="true" %}

```json
{
  "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
        }
      ]
    }
  ]
}
```

{% endcode %}

***

### 🛍️ Product Endpoints

#### Search Products

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

**Headers**

```
Content-Type: application/json
```

**Body**

> `afterIndex` is a cursor. If `null`, search starts from the beginning.\
> Example cursor:\
> `eyJsYXN0X2lkIjo2NjU1NDU2Mzc5MDUzLCJsYXN0X3ZhbHVlIjo2NjU1NDU2Mzc5MDUzfQ==`

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

**Response (example)**

{% code expandable="true" %}

```json
{
  "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 }
  }
}
```

{% endcode %}

***

#### Get Product Tags

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

**Headers**

```
Content-Type: application/json
```

**Body**

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

**Response (example)**

{% code expandable="true" %}

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

{% endcode %}

***

#### Get Products by Tags

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

**Headers**

```
Content-Type: application/json
```

**Body**

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

> `"AND"` → returned products must contain **all** tags.\
> `"OR"` → returned products need **any one** tag in the array.

**Response (example)**

{% code expandable="true" %}

```json
{
  "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
    }
  ]
}
```

{% endcode %}

***

#### Get Products by IDs

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

**Headers**

```
Content-Type: application/json
```

**Body**

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

**Response (example)**

{% code expandable="true" %}

```json
{
  "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
    }
  ]
}
```

{% endcode %}

***

### 👤 Customer Endpoints

#### Search Customers

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

**Headers**

```
Content-Type: application/json
```

**Body**

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

**Response (example)**

{% code expandable="true" %}

```json
{
  "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=="
    }
  ]
}
```

{% endcode %}

***

#### Get Customer Tags

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

**Headers**

```
Content-Type: application/json
```

**Body**

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

**Response (example)**

```json
{
  "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**

```
Content-Type: application/json
```

**Body**

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

**Response (example)**

```json
{
  "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**

```
Content-Type: application/json
```

**Body**

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

> `"AND"` → returned products/customers must contain **all** tags.\
> `"OR"` → returned products/customers need **any** tag in the array.

**Response (example)**

{% code expandable="true" %}

```json
{
  "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=="
    }
  ]
}
```

{% endcode %}

***

### 🗂️ Collection Endpoints

> **Note:** As provided, **Get Collections** uses the `/customer/search` endpoint and returns a `customers` array.

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

**Headers**

```
Content-Type: application/json
```

**Body**

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

**Response (example)**

{% code expandable="true" %}

```json
{
  "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=="
    }
  ]
}
```

{% endcode %}

***

### ⚙️ Request Handling Policy

* The system **handles one request at a time**.
* The next request starts **after** the current one completes.
* If a **server error** occurs, it may take **up to 3 minutes** to recover and process a new request.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-shpf.bsscommerce.com/b2b-wholesale-solution/api-integration/public-apis/public-apis-for-custom-pricing-cp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
