# 🔗Public APIs for Uploading

When a request is made, the app automatically uploads all **enabled rules** to your **active theme**, keeping your storefront pricing logic up-to-date.

***

## 🔑 Get the Access Key

1. Get your API Key. If you don’t have one yet, please [follow this document](/b2b-wholesale-solution/api-integration/public-apis.md) to generate it.
2. Include it in the request body for endpoints that require it.

***

## 🔐 Authentication

All requests require an **Access Key** generated in your app.\
You can include this in the request body or as a Bearer token header:

```http
Authorization: Bearer <accessKey>
```

> ⚠️ **Important:** Each endpoint has a rate limit of **1 request per module per 5 minutes**.\
> Exceeding this limit returns a `429 Too Many Requests` response.

***

### I. 🧾 Upload Custom Pricing Rules

Upload all active **Custom Pricing** rules from your app or system to Shopify.

#### Endpoint

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

#### Request Body

| Field       | Type   | Required | Description                                            |
| ----------- | ------ | -------- | ------------------------------------------------------ |
| `domain`    | String | ✅        | Your store’s `myshopify.com` domain                    |
| `accessKey` | String | ✅        | API Access Key generated from the BSS B2B Solution app |

#### Example Request

```bash
curl -X POST "https://b2b-solution-public-api.bsscommerce.com/api/v1/rule/upload" \
  -H "Content-Type: application/json" \
  -d '{
        "domain": "bsscommerce-store.myshopify.com",
        "accessKey": "yt1pRFAU8ARdwQORhz/Ww7vyS+xxxxxxxxxxxxxx"
      }'
```

#### Responses

| Code                    | Meaning             | Notes                                              |
| ----------------------- | ------------------- | -------------------------------------------------- |
| `200 OK`                | Upload successful   | All enabled rules were applied to the active theme |
| `429 Too Many Requests` | Rate limit exceeded | Wait 5 minutes before sending another request      |

***

### II. 📦 Upload Volume Pricing Rules

Upload all active **Quantity-based** or **Volume-based** rules to your store.

#### Endpoint

```http
POST https://b2b-solution-public-api.bsscommerce.com/api/v1/qb/rule/upload
```

#### Request Body

| Field       | Type   | Required | Description                           |
| ----------- | ------ | -------- | ------------------------------------- |
| `domain`    | String | ✅        | Your store’s `myshopify.com` domain   |
| `accessKey` | String | ✅        | API Access Key generated from the app |

#### Example Request

```bash
curl -X POST "https://b2b-solution-public-api.bsscommerce.com/api/v1/qb/rule/upload" \
  -H "Content-Type: application/json" \
  -d '{
        "domain": "bsscommerce-store.myshopify.com",
        "accessKey": "yt1pRFAU8ARdwQORhz/Ww7vyS+xxxxxxxxxxxxxx"
      }'
```

#### Responses

| Code                    | Meaning                     | Notes                              |
| ----------------------- | --------------------------- | ---------------------------------- |
| `200 OK`                | Rules uploaded successfully | Quantity/Amount Breaks were synced |
| `429 Too Many Requests` | Rate limit exceeded         | Wait 5 minutes before retrying     |

***

### III. 💰 Upload Price List Rules

Upload all active **Price List** rules to your Shopify store.

#### Endpoint

```http
POST https://b2b-solution-public-api.bsscommerce.com/api/v1/pl/rule/upload
```

#### Request Body

| Field       | Type   | Required | Description                           |
| ----------- | ------ | -------- | ------------------------------------- |
| `domain`    | String | ✅        | Your store’s `myshopify.com` domain   |
| `accessKey` | String | ✅        | API Access Key generated from the app |

#### Example Request

```bash
curl -X POST "https://b2b-solution-public-api.bsscommerce.com/api/v1/pl/rule/upload" \
  -H "Content-Type: application/json" \
  -d '{
        "domain": "bsscommerce-store.myshopify.com",
        "accessKey": "yt1pRFAU8ARdwQORhz/Ww7vyS+xxxxxxxxxxxxxx"
      }'
```

#### Responses

| Code                    | Meaning                     | Notes                                          |
| ----------------------- | --------------------------- | ---------------------------------------------- |
| `200 OK`                | Rules uploaded successfully | Price List data has been deployed to the theme |
| `429 Too Many Requests` | Rate limit exceeded         | Wait 5 minutes before sending another request  |

***

## 🧠 Data Storage and Limitations

When uploading rules through these APIs, the data is stored in **Shopify metafields** as JSON.

| Specification           | Details                                                     |
| ----------------------- | ----------------------------------------------------------- |
| **Maximum metafields**  | 10 keys                                                     |
| **Data type**           | JSON                                                        |
| **Max size per key**    | 2,000,000 characters                                        |
| **Total max data size** | \~20,000,000 characters                                     |
| **Exceeding data**      | Any content beyond this limit will **not be uploaded**      |
| **Uploaded content**    | Primarily rule data and minimal setting data                |
| **Active rules only**   | Only enabled rules are uploaded — inactive ones are ignored |

## ✅ Example Automation Flow

1. External system (ERP/CRM) updates B2B rules.
2. System triggers a POST request to the relevant **upload API**.
3. B2B/Wholesale Solution validates data and pushes it to the Shopify metafields.
4. Storefront automatically reflects updated pricing and rule logic.

***

With these **Public Upload APIs**, your development team can fully automate pricing rule synchronization — ensuring your B2B store always delivers accurate, real-time pricing without manual updates.


---

# 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-uploading.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.
