# Update prices across price lists

URL: https://docs.sparklayer.io/developers/api/pricing/update-pricing-for-multiple-price-lists
Operation: `PATCH /api/v1/batch-update-pricing` (operationId `updateMultiplePriceListPricing`)
OpenAPI spec: https://docs.sparklayer.io/openapi/pricing.yaml

Accepts a JSON array or a CSV file (`Content-Type: text/csv`); each entry names a SKU, a `price_list_slug` and the prices for that combination. Only the SKU and price list combinations you send are affected, and their existing prices are replaced.

Returns `404` if a referenced price list does not exist, `400` for validation errors (usually as an array of `{line, field, message}` objects), and `409` if the update clashed with another one running at the same time, in which case you can retry it.

`PATCH /api/v1/batch-update-pricing`

**Base URLs:** `https://app.sparklayer.io` (Live), `https://test.app.sparklayer.io` (Test)

**Authentication:** send `Authorization: Bearer <access_token>` and `Site-Id: <site id>` with every request. Get the token from [Get an access token](https://docs.sparklayer.io/developers/api/core/get-an-access-token.md); see [Authentication](https://docs.sparklayer.io/developers/authentication.md).

### Example request

```bash
curl -X PATCH "https://app.sparklayer.io/api/v1/batch-update-pricing" \
  -H "Authorization: Bearer $SPARKLAYER_TOKEN" \
  -H "Site-Id: $SPARKLAYER_SITE_ID" \
  -H "Content-Type: application/json" \
  -d '[
  {
    "sku": "SKU-1",
    "price_list_slug": "example-list",
    "display_tax_rate": 10,
    "pricing": [
      {
        "quantity": 1,
        "price": 10.49,
        "unit_of_measure": "pallet"
      }
    ]
  }
]'
```

Set `SPARKLAYER_TOKEN` to an access token and `SPARKLAYER_SITE_ID` to your Site ID. For the test environment, use `https://test.app.sparklayer.io`.

### Header parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Site-Id` | string | Yes | Your SparkLayer Site ID, from Settings > API in the SparkLayer Dashboard. Example: `jones-climbing` |

### Request body (required)

Send one of: `application/json`, `text/csv`.

List of sku, price list, quantity and price to update. Partial updates are supported, meaning only the SKUs present will be affected. For the given SKUs, existing prices are deleted then the supplied prices are inserted. If a SKU is provided but quantity and price are blank, all prices for that SKU are removed from the price list.

#### `application/json`

An array. Each item:

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `[].sku` | string | Yes | Length: max 128. |
| `[].price_list_slug` | string | Yes | |
| `[].display_tax_rate` | number (float) \| null | | Tax rate used only to display a tax-inclusive price, expressed as a whole percentage (10 means 10%). Stored prices remain net and the eCommerce platform remains authoritative for the tax actually charged at checkout. On an update the field has three states: omit it to leave any stored rate unchanged (so a price-only sync never disturbs it), send null to clear it, or send a value to set it. Min 0, max 100. |
| `[].pricing` | object[] | Yes | |
| `[].pricing[].quantity` | integer | Yes | The quantity at which the specified price is applicable. This allows for quantity discount pricing to be set up. Default: `1`. Min 1. |
| `[].pricing[].price` | number (float) | Yes | |
| `[].pricing[].unit_of_measure` | string \| null | | The unit of measure associated with this quantity. When specifying a unit of measure, it must match the pattern. To remove any value set, either omit the property or set the value as null. Pattern: `^[a-zA-Z0-9-]+$`. |

```json
[
  {
    "sku": "SKU-1",
    "price_list_slug": "example-list",
    "display_tax_rate": 10,
    "pricing": [
      {
        "quantity": 1,
        "price": 10.49,
        "unit_of_measure": "pallet"
      }
    ]
  }
]
```

#### `text/csv`

display_tax_rate is optional and applies to the whole SKU on a given price list, so it must be the same on every row for that SKU. A blank cell means the rate is unchanged, so a SKU's rate can be given on just one of its rows, and omitting the column entirely leaves every stored rate alone.

```csv
sku,   price_list_slug, quantity, price, unit_of_measure, display_tax_rate
SKU-1, example-list, 1,        10.99,                   , 10
SKU-1, example-list, 10,       9.99,  pallet            , 10
```

### Responses

#### 204: The prices were updated. No body.

#### 400: Validation errors

An array. Each item:

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `[].line` | integer | | line of input which the error relates to |
| `[].field` | string | | field which the error relates to |
| `[].message` | string | | human readable description of error |

```json
[
  {
    "line": 0,
    "field": "<field>",
    "message": "<message>"
  }
]
```

#### 404: Price list not found

#### 500: Internal server error

#### Other statuses: An error. The body describes the problem: see [Errors](https://docs.sparklayer.io/developers/errors.md).

`application/problem+json`: the standard error body (below).

### Error body

Error responses with a body use this RFC 7807 problem details object. See [Errors](https://docs.sparklayer.io/developers/errors.md) for every status code and which errors to retry.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `detail` | string | | Human-readable summary of the error |
| `status` | integer | | HTTP Status code returned from API |
| `title` | string | | Machine-readable error code |
| `type` | string | | |

```json
{
  "detail": "Data Validation Failed",
  "status": 400,
  "title": "invalid-api-request-contents",
  "type": "https://docs.sparklayer.io/tech-docs"
}
```
