> For the complete documentation index, see [llms.txt](https://dev.ucommerce.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev.ucommerce.net/readme/headless/reference/promotion-codes.md).

# Promotion Codes

You can enable a mini cart view in the following requests to show changes to the cart immediately. Find out more in the [Views for Cart modifying operations](/readme/headless/reference/views-for-cart-modifying-operations.md)

### Prerequisites

* `access_token` from [Headless API Authentication](/readme/headless/headless-api-authentication.md)
* `cartId` from [Cart](/readme/headless/reference/cart.md#create-a-cart)
* `priceGroupId` from [Price Groups](/readme/headless/reference/price-groups.md) (string)
* `cultureCode`, e.g. `en-US` (string)

## Add Promotion Codes

### Request

```bash
curl -D- -X POST <base_url>/api/v1/carts/<cartId>/promotion-codes/<code> \
    -H 'Authorization: Bearer <ACCESS_TOKEN>'
    -H 'Content-Type: application/json' \
    -d '{
            "priceGroupId": "<priceGroupId>",
            "cultureCode": "<CultureCode>"
        }'
```

### Response

```json
{
    "promotionCodes": [
        {
            "code": "{promotionCode}",
        }
    ]
}
```

## Get Promotion Codes

### Request

```bash
curl -D- -X GET <base_url>/api/v1/carts/<cartId>/promotion-codes \
        -H 'Authorization: Bearer <ACCESS_TOKEN>'
        -H 'Content-Type: application/json' \
```

### Response

```json
{
    "promotionCodes": [
        {
            "code": "{promotionCode}",
        }
    ]
}
```

## Remove Promotion Codes

### Request

```bash
curl -D- -X DELETE <base_url>/api/v1/carts/<cartId>/promotion-codes/<code> \
    -H 'Authorization: Bearer <ACCESS_TOKEN>'
    -H 'Content-Type: application/json' \
    -d '{
            "priceGroupId": "<priceGroupId>",
            "cultureCode": "<cultureCode>"
        }'
```

### Response

```json
{
    "promotionCodes": [
    ]
}
```

## Error Handling

| Error            | Description                               |
| ---------------- | ----------------------------------------- |
| BadRequest (400) | PriceGroup does not exist.                |
| NotFound (404)   | Cart not found; Promotion Code not found. |

Error Response Example

```json
{
"errors":
    [
        {
            "error-description": "AccessToken not found, access denied.",
            "error": "BadRequest"
        }
    ]
}
```

## Related Articles

{% content-ref url="/pages/OKRcu1Dp3gn5Y38w55HD" %}
[Error Handling](/readme/headless/error-handling.md)
{% endcontent-ref %}
