# Update a discount

Updates a discount. Fields you leave out keep their current values. Works with Shopify and WooCommerce accounts.

```http
PATCH https://api.pozy.ai/v1/commerce/discounts/{discountId}
```

- Area: Commerce / Commerce
- Auth: Authorization: Bearer pz_live_...

## Path parameters

- `discountId` (string, required)

## Request body

Content type: `application/json`

- `accountId`, string, required
- `title`, string
- `code`, string
- `percentage`, number: At most 100
- `amount`, string
- `appliesOnEachItem`, boolean
- `minimumSubtotal`, string: Can be null
- `minimumQuantity`, integer: At least 1. Can be null
- `usageLimit`, integer: At least 1. Can be null
- `oncePerCustomer`, boolean
- `startsAt`, string (date-time)
- `endsAt`, string (date-time): Can be null

## Example request

```bash
curl -X PATCH "https://api.pozy.ai/v1/commerce/discounts/6ebbd22404a5ebbadf66d175" \
  -H "Authorization: Bearer $POZY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "accountId": "696e0b682d0a31188e7a2ba9"
}'
```

```ts
const res = await fetch("https://api.pozy.ai/v1/commerce/discounts/6ebbd22404a5ebbadf66d175", {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.POZY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    accountId: "696e0b682d0a31188e7a2ba9"
  }),
});
const data = await res.json();
if (!res.ok) throw new Error(data?.error ?? `Request failed with status ${res.status}`);
console.log(data);
```

```python
import os
import requests

resp = requests.patch(
    "https://api.pozy.ai/v1/commerce/discounts/6ebbd22404a5ebbadf66d175",
    headers={"Authorization": f"Bearer {os.environ['POZY_API_KEY']}"},
    json={
        "accountId": "696e0b682d0a31188e7a2ba9",
    },
    timeout=30,
)
resp.raise_for_status()
print(resp.json())
```

## Response 200

- `discount`, object
  - `id`, string
  - `accountId`, string
  - `platform`, string: One of `shopify`
  - `title`, string
  - `method`, string: One of `code`, `automatic`
  - `type`, string: One of `percentage`, `fixed_amount`, `free_shipping`, `buy_x_get_y`, `app`
  - `codes`, array of string
  - `codeCount`, integer: Can be null
  - `value`, object
    - one of: Option 1
      - `type`, string: One of `percentage`
      - `percentage`, number
    - one of: Option 2
      - `type`, string: One of `fixed_amount`
      - `amount`, object
        - `amount`, string, required
        - `currency`, string, required
      - `appliesOnEachItem`, boolean
  - `appliesTo`, object: Can be null
    - `type`, string: One of `all`, `products`, `collections`
    - `productIds`, array of string
    - `variantIds`, array of string
    - `collectionIds`, array of string
  - `minimum`, object: Can be null
    - `type`, string: One of `subtotal`, `quantity`
    - `amount`, object
      - `amount`, string, required
      - `currency`, string, required
    - `quantity`, integer
  - `usageLimit`, integer: Can be null
  - `oncePerCustomer`, boolean
  - `usageCount`, integer
  - `startsAt`, string (date-time)
  - `endsAt`, string (date-time): Can be null
  - `status`, string: One of `active`, `scheduled`, `expired`
  - `platformStatus`, string
  - `summary`, string
  - `platformData`, object: Can be null

```json
{
  "discount": {
    "id": "6bfebd43ddc270f6d2c56fc5",
    "accountId": "696e0b682d0a31188e7a2ba9",
    "platform": "shopify",
    "title": "Launch day",
    "method": "code",
    "type": "percentage",
    "codes": [
      "string"
    ],
    "codeCount": 42,
    "value": {
      "type": "percentage",
      "percentage": 12.5
    },
    "appliesTo": {
      "type": "all",
      "productIds": [
        "string"
      ],
      "variantIds": [
        "string"
      ],
      "collectionIds": [
        "string"
      ]
    },
    "minimum": {
      "type": "subtotal",
      "amount": {
        "amount": "string",
        "currency": "USD"
      },
      "quantity": 1
    },
    "usageLimit": 1,
    "oncePerCustomer": true,
    "usageCount": 42,
    "startsAt": "2026-10-02T09:00:00.000Z",
    "endsAt": "2026-10-02T09:00:00.000Z",
    "status": "active",
    "platformStatus": "instagram",
    "summary": "string",
    "platformData": {}
  }
}
```
