# Update/Edit Wholesale Pricing using APIs

This document explains how to update an existing Wholesale Pricing rule using the Public API.

***

### 1. Endpoint

To update an existing Wholesale Pricing record, use the following endpoint:

```
PUT https://wholesale.samita.io/api/v1/wholesale-pricings/{id}
```

* `{id}` is the ID of the Wholesale Pricing record
* The ID can be obtained from the app interface (without the “#” symbol)
* Example reference:&#x20;

<figure><img src="https://810149679-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7AXvWN0Sv4Sg8s2aVRWp%2Fuploads%2FBM9wlJJCiosLthJLMyr9%2Fimage.png?alt=media&#x26;token=c1eaba22-8b3a-40ab-856d-b7a09af811b3" alt=""><figcaption></figcaption></figure>

#### Example:

```
PUT https://wholesale.samita.io/api/v1/wholesale-pricings/1
```

***

### 2. Request Headers

All API requests must include the following required headers:

| Header                  | Description                                     | Required |
| ----------------------- | ----------------------------------------------- | -------- |
| **`X-SAMITA-API-KEY`**  | API key provided in the Wholesale app           | Yes      |
| **`X-SAMITA-SHOP-URL`** | Shopify shop domain in format xxx.myshopify.com | Yes      |
| **`CONTENT-TYPE`**      | Must be `application/json`                      | Yes      |

If any required header is missing, the request will be rejected.

***

### 3. Request Body

*\_* The data used to update Wholesale Pricing must be sent in JSON format. A sample JSON structure is provided at the end of this document.

\_ Only the fields that need to be updated are required in the request. It is **not mandatory** to send all fields like in the Create API method.&#x20;

\_ Unspecified fields will remain unchanged

**Sample Request JSON:**&#x20;

```json
{​
  "title": "New Wholesale Pricing",​
  "status": true,​
  "apply_customer": {​
    "type": "all",​
    "tags": []​
  },​
  "exclude_customer": {​
    "type": "none",​
    "tags": []​
  },​
  "apply_product": {​
    "type": "all",​
    "product_ids": [],​
    "product_tags": [],​
    "collection_ids": [],​
    "apply_for_variants": false​
  },​
  "exclude_product": {​
    "type": "none",​
    "product_ids": [],​
    "collection_ids": []​
  },​
  "discount_for_variants": [​
    {​
      "id": 8516448190631,​
      "variant_pricing": true,​
      "variants": [​
        {​
          "id": 46747346763943,​
          "discount_groups": [​
            {​
              "name": "all",​
              "type": "percent",​
              "value": "10"​
            }​
          ]​
        }​
      ]​
    }​
  ],​
  "apply_market": {​
    "type": "all",​
    "handle": []​
  },​
  "discount_group": {​
    "type": "percent",​
    "value": "10"​
  },​
  "active_date": {​
    "types": ["start_date", "end_date"],​
    "start_at": "2026-01-15 10:00:00",​
    "end_at": "2026-01-15 10:00:00"​​
  }​
​}

```

***

#### c. title

* The name used to identify the Wholesale Pricing record
* Optional in Update API
* Must be a string
* Maximum length: **255 characters**

***

#### d. status

* Defines whether the record is active or not
* Optional in Update API
* Accepts only the following values:

| Value   | Description              |
| ------- | ------------------------ |
| `true`  | Pricing rule is active   |
| `false` | Pricing rule is inactive |

***

#### e. apply\_customer

Defines which customers are eligible for this pricing rule.

Structure:

```
"apply_customer": {​
    "type": "all",​
    "tags": []​
}
```

**type**

Accepted values:

* `all`
* `logged`
* `non-logged`
* `customer-tags`

**tags**

* Required only when `type == customer-tags`
* Must be a comma-separated array
* Example: `["wholesale","b2b"]`

***

#### f. exclude\_customer

Used to exclude specific customers from the pricing rule.

Structure:

```
"exclude_customer": {​
    "type": "none",​
    "tags": []​
}
```

**type**

* Default value: `none`
* Accepted values:

| Value           | Description                 |
| --------------- | --------------------------- |
| `none`          | Do not exclude any customer |
| `customer-tags` | Exclude customers by tags   |

**tags**

* Required only when `type == customer-tags`
* Example: `["vip","wholesale"]`

***

#### g. apply\_product (Required)

Defines which products the pricing rule will be applied to.

Structure:

```
"apply_product": {​
    "type": "all",​
    "product_ids": [],​
    "product_tags": [],​
    "collection_ids": [],​
    "apply_for_variants": false​
}
```

**type**

Accepted values:

* `all`
* `products`
* `collections`
* `product-tags`

Other fields are required depending on the selected type:

* `product_ids` → required if `type == products`
* `product_tags` → required if `type == product-tags`
* `collection_ids` → required if `type == collections`

**apply\_for\_variants**

* Accepted values: `true` or `false`
* Default value: `false`

***

#### h. exclude\_product

Defines products to be excluded from the rule.

Structure:

```
"exclude_product": {​
    "type": "none",​
    "product_ids": [],​
    "collection_ids": []​
}
```

Accepted types:

* `none`
* `products`
* `collections`

***

#### i. discount\_for\_variants

Used when discounts are configured per variant.

* Must be empty if `apply_product.apply_for_variants == false`
* Required when `apply_product.apply_for_variants == true`

**Example structure:**&#x20;

<pre><code>"discount_for_variants": [​
  {​
    "id": 8516448190631,​
    "variant_pricing": true,​
    "variants": [​
      {​
        "id": 46747346763943,​
        "discount_groups": [​
          {​
            "name": "all",​
            "type": "percent",​
            "value": "10"​
          }​
        ]​
      }​
    ]​
  }​
<strong>]
</strong></code></pre>

Structure:

* Array of products
* Each product contains:
  * `id` – Product ID
  * `variant_pricing` – Must be `true`
  * `variants` – Array of variants

Each variant contains:

* `id` – Variant ID
* `discount_groups` – Array of discount configurations

**discount\_groups rules**

* If `apply_customer.type` is `all`, `logged`, or `non-logged`\
  → Only **one item** is allowed
* If `apply_customer.type == customer-tags`\
  → Multiple discount groups can be provided

Fields inside discount\_groups:

| Field   | Description                              |
| ------- | ---------------------------------------- |
| `name`  | Must match customer type or customer tag |
| `type`  | Discount type                            |
| `value` | Discount value                           |

Accepted discount types:

* `percent`
* `amount`
* `fixed-amount`

Value rules:

* Must be a number greater than 0
* If type is `percent`, value must be **less than 100**

***

#### j. apply\_market (Required)

Defines which Shopify markets the rule applies to.

Structure:

```
"apply_market": {​
    "type": "all",​
    "handle": []​
}
```

**type**

Accepted values:

* `all`
* `specific-market`

**handle**

* Required only when `type == specific-market`
* Comma-separated list of market handles
* Example: `["japan","us"]`

***

#### k. discount\_group

Used when discount is not configured per variant.

Required when:

* `apply_product.type` is not `products`, OR
* `apply_product.type == products` AND variants are not applied

Structure:

```
"discount_group": {​
    "type": "percent",​
    "value": "10"​
}
```

Rules:

* `type` must be one of:
  * `percent`
  * `amount`
  * `fixed-amount`
* `value`
  * Must be greater than 0
  * If type is `percent`, value must be less than 100

***

#### l. active\_date

Used to configure start and end time for the pricing rule.

Structure:

```
"active_date": {​
    "types": ["start_date", "end_date"],​
    "start_at": "2026-01-15T10:00:00",​
    "end_at": "2026-01-15T10:00:00"​
}​
```

**types**

* Optional
* Accepted values: `start_date`, `end_date`
* Example: `["start_date","end_date"]`

**start\_at**

* Required if `types` includes `start_date`
* Format: `YYYY-MM-DD HH:MM:SS`

**end\_at**

* Required if `types` includes `end_date`
* Format: `YYYY-MM-DD HH:MM:SS`

***

### 4. API Response

#### a. Error Responses

**401 – Unauthorized**

Possible reasons:

* Missing shop URL
* Missing API key
* Invalid shop URL
* Invalid API key
* API key does not match the shop

***

**403 – This action is unauthorized**

* API key does not have Update permission
* Each API key can have: View, Create, Update, Delete permissions
* This API requires **Update** permission
* Also returned when the provided ID does not exist

***

**429 – Too Many Requests**

Rate limit exceeded:

* Maximum **1 request per 5 minutes**
* Maximum **50 requests per day**

***

#### b. Success Response

**200 – API Success**

* Wholesale Pricing record updated successfully
* Response returned in JSON format

Sample Response JSON:

```json
{
  "id": 1,
  "title": "New Wholesale Pricing",
  "status": true,
  "apply_customer": {
    "type": "all",
    "tags": []
  },
  "exclude_customer": {
    "type": "none",
    "tags": []
  },
  "apply_product": {
    "type": "all",
    "product_ids": [],
    "product_tags": [],
    "collection_ids": [],
    "apply_for_variants": false
  },
  "exclude_product": {
    "type": "none",
    "product_ids": [],
    "collection_ids": []
  },
  "discount_for_variants": [
    {
      "id": 8516448190631,
      "variant_pricing": true,
      "variants": [
        {
          "id": 46747346763943,
          "discount_groups": [
            {
              "name": "all",
              "type": "percent",
              "value": "10"
            }
          ]
        }
      ]
    }
  ],
  "apply_market": {
    "type": "all",
    "handle": []
  },
  "discount_group": {
    "type": "percent",
    "value": "10"
  },
  "active_date": {
    "types": [],
    "start_at": "",
    "end_at": ""
  },
  "created_at": "2026-01-15T10:00:00",
  "updated_at": "2026-01-15T10:00:00"
}
```
