---
title: "Updates a discount's fields."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.sherpo.io/llms.txt
> Use this file to discover all available pages before exploring further.

Path: Sherpo merchant API › discount

`PATCH /v1/stores/{store}/discounts/{discount}`

## Authentication

- `bearer`, http, header `Authorization`, scopes: `discount:write`

## Path parameters

- `store` (`updateDiscount.path.store`; string, required) — The store's id.
- `discount` (`updateDiscount.path.discount`; string, required)
  - minLength 1

## Request body

_Optional._

- `name` (`updateDiscount.name`; any of, optional)
  - any of: `string`, `null`
- `priority` (`updateDiscount.priority`; integer, optional)
  - min -1000000; max 1000000
- `applies` (`updateDiscount.applies`; string, optional)
  - one of `"automatically"`, `"by_code"`, `"never"`
- `floor_amount` (`updateDiscount.floor_amount`; any of, optional) — The lowest each unit's price goes.
  - any of: `integer`, `null`
- `cap_amount` (`updateDiscount.cap_amount`; any of, optional) — At most this off each unit bought.
  - any of: `integer`, `null`
- `floor_percent` (`updateDiscount.floor_percent`; any of, optional)
  - any of: `integer`, `null`
- `supply_total` (`updateDiscount.supply_total`; any of, optional)
  - any of: `integer`, `null`
- `supply_per_customer` (`updateDiscount.supply_per_customer`; any of, optional)
  - any of: `integer`, `null`
- `starts_at` (`updateDiscount.starts_at`; any of, optional)
  - any of: `string`, `null`
- `ends_at` (`updateDiscount.ends_at`; any of, optional)
  - any of: `string`, `null`

## Example request

```json
{
  "name": "string",
  "priority": -1000000,
  "applies": "automatically",
  "floor_amount": 0,
  "cap_amount": 1,
  "floor_percent": 9999,
  "supply_total": 1,
  "supply_per_customer": 1,
  "starts_at": "string",
  "ends_at": "string"
}
```

## Code samples

### cURL

```bash
curl --request PATCH \
  --url 'https://api.sherpo.io/merchant/v1/stores/<store>/discounts/<discount>' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "string",
  "priority": -1000000,
  "applies": "automatically",
  "floor_amount": 0,
  "cap_amount": 1,
  "floor_percent": 9999,
  "supply_total": 1,
  "supply_per_customer": 1,
  "starts_at": "string",
  "ends_at": "string"
}
'
```

### TypeScript

```typescript
const url = 'https://api.sherpo.io/merchant/v1/stores/<store>/discounts/<discount>';
const options = {
  method: 'PATCH',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({
    name: 'string',
    priority: -1000000,
    applies: 'automatically',
    floor_amount: 0,
    cap_amount: 1,
    floor_percent: 9999,
    supply_total: 1,
    supply_per_customer: 1,
    starts_at: 'string',
    ends_at: 'string'
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.sherpo.io/merchant/v1/stores/<store>/discounts/<discount>"

payload = {
    "name": "string",
    "priority": -1000000,
    "applies": "automatically",
    "floor_amount": 0,
    "cap_amount": 1,
    "floor_percent": 9999,
    "supply_total": 1,
    "supply_per_customer": 1,
    "starts_at": "string",
    "ends_at": "string"
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

Updates a discount's fields.

#### Example

```json
{
  "name": "string",
  "status": "string",
  "id": "string",
  "priority": 0,
  "created_at": "string",
  "currency": "string",
  "code": "string",
  "applies": "string",
  "amount_off": 0,
  "percent_off": 0,
  "floor_amount": 0,
  "cap_amount": 0,
  "floor_percent": 0,
  "supply_total": 0,
  "supply_consumed": 0,
  "supply_per_customer": 0,
  "starts_at": "string",
  "ends_at": "string",
  "archived_at": "string",
  "customers": [
    "string"
  ],
  "usage": {
    "customers": 0,
    "uses": 0
  },
  "scopes": [
    {
      "id": "string",
      "kind": "string",
      "product_id": "string",
      "tier_id": "string",
      "price_id": "string"
    }
  ],
  "affiliates_ended": {
    "total": 0
  },
  "affiliate_earnings": [
    {
      "currency": "string",
      "exponent": 0,
      "earned": 0,
      "unpaid": 0,
      "paid": 0,
      "commissions": 0,
      "unpaid_commissions": 0
    }
  ],
  "exponent": 0,
  "affiliates": [
    {
      "earnings": [
        {
          "currency": "string",
          "exponent": 0,
          "earned": 0,
          "unpaid": 0,
          "paid": 0,
          "commissions": 0,
          "unpaid_commissions": 0
        }
      ],
      "user_id": "string",
      "amount_earned": 0,
      "percent_earned": 0,
      "token_id": "string",
      "changed_token_id": "string",
      "prior_amount_earned": 0,
      "prior_percent_earned": 0,
      "ended_at": "string",
      "updated_at": "string",
      "user": {
        "id": "string",
        "name": "string",
        "email": "string",
        "avatar": "string"
      }
    }
  ]
}
```

- `name` (`updateDiscount.response.200.name`; any of, required)
  - any of: `string`, `null`
- `status` (`updateDiscount.response.200.status`; string, required)
- `id` (`updateDiscount.response.200.id`; string, required)
- `priority` (`updateDiscount.response.200.priority`; number, required)
- `created_at` (`updateDiscount.response.200.created_at`; any of, required)
  - any of: `string`, `null`
- `currency` (`updateDiscount.response.200.currency`; any of, required)
  - any of: `string`, `null`
- `code` (`updateDiscount.response.200.code`; any of, required)
  - any of: `string`, `null`
- `applies` (`updateDiscount.response.200.applies`; string, required)
- `amount_off` (`updateDiscount.response.200.amount_off`; number, required)
- `percent_off` (`updateDiscount.response.200.percent_off`; number, required)
- `floor_amount` (`updateDiscount.response.200.floor_amount`; any of, required)
  - any of: `number`, `null`
- `cap_amount` (`updateDiscount.response.200.cap_amount`; any of, required)
  - any of: `number`, `null`
- `floor_percent` (`updateDiscount.response.200.floor_percent`; any of, required)
  - any of: `number`, `null`
- `supply_total` (`updateDiscount.response.200.supply_total`; any of, required)
  - any of: `number`, `null`
- `supply_consumed` (`updateDiscount.response.200.supply_consumed`; number, required)
- `supply_per_customer` (`updateDiscount.response.200.supply_per_customer`; any of, required)
  - any of: `number`, `null`
- `starts_at` (`updateDiscount.response.200.starts_at`; any of, required)
  - any of: `string`, `null`
- `ends_at` (`updateDiscount.response.200.ends_at`; any of, required)
  - any of: `string`, `null`
- `archived_at` (`updateDiscount.response.200.archived_at`; any of, required)
  - any of: `string`, `null`
- `customers` (`updateDiscount.response.200.customers`; array<string>, required)
- `usage` (`updateDiscount.response.200.usage`; object, required)
  - `customers` (`updateDiscount.response.200.usage.customers`; number, required)
  - `uses` (`updateDiscount.response.200.usage.uses`; number, required)
- `scopes` (`updateDiscount.response.200.scopes`; array<object>, required)
  - `id` (`updateDiscount.response.200.scopes.id`; string, required)
  - `kind` (`updateDiscount.response.200.scopes.kind`; string, required)
  - `product_id` (`updateDiscount.response.200.scopes.product_id`; any of, required)
    - any of: `string`, `null`
  - `tier_id` (`updateDiscount.response.200.scopes.tier_id`; any of, required)
    - any of: `string`, `null`
  - `price_id` (`updateDiscount.response.200.scopes.price_id`; any of, required)
    - any of: `string`, `null`
- `affiliates_ended` (`updateDiscount.response.200.affiliates_ended`; object, required)
  - `total` (`updateDiscount.response.200.affiliates_ended.total`; number, required)
- `affiliate_earnings` (`updateDiscount.response.200.affiliate_earnings`; any of, required)
  - any of: `array<object>`, `null`
- `exponent` (`updateDiscount.response.200.exponent`; any of, required)
  - any of: `number`, `null`
- `affiliates` (`updateDiscount.response.200.affiliates`; array<object>, required)
  - `earnings` (`updateDiscount.response.200.affiliates.earnings`; any of, required)
    - any of: `array<object>`, `null`
  - `user_id` (`updateDiscount.response.200.affiliates.user_id`; string, required)
  - `amount_earned` (`updateDiscount.response.200.affiliates.amount_earned`; number, required)
  - `percent_earned` (`updateDiscount.response.200.affiliates.percent_earned`; number, required)
  - `token_id` (`updateDiscount.response.200.affiliates.token_id`; any of, required)
    - any of: `string`, `null`
  - `changed_token_id` (`updateDiscount.response.200.affiliates.changed_token_id`; any of, required)
    - any of: `string`, `null`
  - `prior_amount_earned` (`updateDiscount.response.200.affiliates.prior_amount_earned`; any of, required)
    - any of: `number`, `null`
  - `prior_percent_earned` (`updateDiscount.response.200.affiliates.prior_percent_earned`; any of, required)
    - any of: `number`, `null`
  - `ended_at` (`updateDiscount.response.200.affiliates.ended_at`; any of, required)
    - any of: `string`, `null`
  - `updated_at` (`updateDiscount.response.200.affiliates.updated_at`; any of, required)
    - any of: `string`, `null`
  - `user` (`updateDiscount.response.200.affiliates.user`; any of, required)
    - any of: `object`, `null`

### default

A problem; see https://api.sherpo.io/merchant/docs/errors.

#### Example

```json
{
  "type": "http://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "string",
  "context": {},
  "reached_core": true,
  "core_answer": "string"
}
```

- `type` (`updateDiscount.response.default.type`; string, required)
  - format `uri`
- `title` (`updateDiscount.response.default.title`; string, required)
- `status` (`updateDiscount.response.default.status`; integer, required)
- `detail` (`updateDiscount.response.default.detail`; string, required)
- `code` (`updateDiscount.response.default.code`; string, optional)
- `context` (`updateDiscount.response.default.context`; object, optional)
- `reached_core` (`updateDiscount.response.default.reached_core`; boolean, optional)
- `core_answer` (`updateDiscount.response.default.core_answer`; string, optional)


Source: https://docs.sherpo.io/merchant-api/reference/update-discount/index.md
