# Update a price list

URL: https://docs.sparklayer.io/developers/api/pricing/update-a-price-list
Operation: `PATCH /api/v1/price-lists/{slug}` (operationId `updatePriceList`)
OpenAPI spec: https://docs.sparklayer.io/openapi/pricing.yaml

Updates only the fields you send (`name`, `currency_code`, `rules` and `tax_inclusive_display`); the slug and source cannot be changed. Sending `rules` replaces all of the existing rules. Changing `currency_code` relabels the prices already on the list with the new currency without converting the amounts. Returns the updated price list, or `404` if it does not exist.

`PATCH /api/v1/price-lists/{slug}`

**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/price-lists/base-list" \
  -H "Authorization: Bearer $SPARKLAYER_TOKEN" \
  -H "Site-Id: $SPARKLAYER_SITE_ID" \
  -H "Content-Type: application/json" \
  -d '{
  "rules": [
    {
      "source_price_list_slug": "base-list",
      "adjustment_percentage": 0.103333,
      "adjustment_direction": "plus",
      "currency_exchange_rate": 1.254324
    }
  ],
  "name": "Base Price List",
  "currency_code": "GBP",
  "tax_inclusive_display": true
}'
```

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

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `slug` | string | Yes | The price list's slug. Example: `base-list` |

### 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 (`application/json`) (required)

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `rules` | object[] | | Length: max 5. |
| `rules[].source_price_list_slug` | string | | Source PriceList slug. Length: min 1, max 64. |
| `rules[].adjustment_percentage` | number | | Adjustment percent expressed as a decimal fraction between 0 and 1 - E.g. 15% should be set as 0.15. Min 0, max 1. |
| `rules[].adjustment_direction` | "plus" \| "minus" | | Adjustment direction (plus, minus) |
| `rules[].currency_exchange_rate` | number \| null | | Exchange rate between the currency of the source price list and the price list to which this rule belongs. If null, the rate will be determined automatically based on current market rates. Min 0.000001. |
| `name` | string | | Name. Length: min 1, max 128. |
| `currency_code` | string | | ISO 4217 currency code. Length: min 3, max 3. |
| `tax_inclusive_display` | boolean | | Toggle tax-inclusive display for this price list. |

```json
{
  "rules": [
    {
      "source_price_list_slug": "base-list",
      "adjustment_percentage": 0.103333,
      "adjustment_direction": "plus",
      "currency_exchange_rate": 1.254324
    }
  ],
  "name": "Base Price List",
  "currency_code": "GBP",
  "tax_inclusive_display": true
}
```

### Responses

#### 200: The updated price list.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `slug` | string | | Slug. Length: min 1, max 64. |
| `name` | string | | Name. Length: min 1, max 128. |
| `currency_code` | string | | ISO 4217 currency code. Length: min 3, max 3. |
| `source` | "custom" \| "platform" \| "integration" | | Integration should be used by external parties, custom is provided to any price lists setup in the dashboard and platform is reserved for the eCommerce platform. Default: `custom`. |
| `tax_inclusive_display` | boolean | | When true, storefronts display prices on this price list inclusive of the per-SKU display_tax_rate, labelled as tax inclusive. This changes presentation only - prices are still stored and transacted net. SKUs on the list with no rate, or a rate of 0, display their net price and are still labelled tax inclusive. Default: `false`. |
| `rules` | object[] | | Length: max 5. |
| `rules[].source_price_list_slug` | string | | Source PriceList slug. Length: min 1, max 64. |
| `rules[].adjustment_percentage` | number | | Adjustment percent expressed as a decimal fraction between 0 and 1 - E.g. 15% should be set as 0.15. Min 0, max 1. |
| `rules[].adjustment_direction` | "plus" \| "minus" | | Adjustment direction (plus, minus) |
| `rules[].currency_exchange_rate` | number \| null | | Exchange rate between the currency of the source price list and the price list to which this rule belongs. If null, the rate will be determined automatically based on current market rates. Min 0.000001. |

```json
{
  "slug": "base-list",
  "name": "Base Price List",
  "currency_code": "GBP",
  "source": "custom",
  "tax_inclusive_display": false,
  "rules": [
    {
      "source_price_list_slug": "base-list",
      "adjustment_percentage": 0.103333,
      "adjustment_direction": "plus",
      "currency_exchange_rate": 1.254324
    }
  ]
}
```

#### 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"
}
```
