# Cart Custom Properties

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](https://dev.ucommerce.net/readme/headless/reference/views-for-cart-modifying-operations "mention")

## Prerequisites

* `access_token` from [headless-api-authentication](https://dev.ucommerce.net/readme/headless/headless-api-authentication "mention")
* `cartId` from [#create-a-cart](https://dev.ucommerce.net/readme/headless/cart#create-a-cart "mention")
* `cultureCode`, e.g. `en-US` (string)
* `priceGroupId` from the cart or from [price-groups](https://dev.ucommerce.net/readme/headless/reference/price-groups "mention")

## Add Custom Properties to Cart

### Parameters

* `key` the unique key of the property (string)
* `value` the value of the property (string)

### Request

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

### Response

<pre class="language-json"><code class="lang-json">{
<strong>    "miniCart": null,
</strong>    "success": true
}
</code></pre>

## Delete Custom Property from Cart

### Parameters

* `propertyId` from [#add-custom-properties-to-cart](#add-custom-properties-to-cart "mention") or [#get-custom-properties-for-cart](#get-custom-properties-for-cart "mention")

### Request

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

### Response

```json
{
    "miniCart": null,
    "success": true
}
```

## Get Custom Properties for Cart

### Request

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

### Response

```json
{
    "customProperties":
        [
            {
                "id" : "{id}",
                "key" : "{key}",
                "value" : "{value}",
            }
        ]
}
```

## Update Custom Properties for Cart

### Parameters

* `propertyId` from [#add-custom-properties-to-cart](#add-custom-properties-to-cart "mention") or [#get-custom-properties-for-cart](#get-custom-properties-for-cart "mention")
* `value` new value for the property (string)

### Request

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

### Response

```json
{
    "miniCart": null,
    "success": true
}
```

## Error Handling

| Error              | Description                                                                             |
| ------------------ | --------------------------------------------------------------------------------------- |
| BadRequest (400)   | Execution of the pipeline fails; Price group is not found; AccessToken is not attached. |
| Unauthorized (401) | The token is expired.                                                                   |
| Forbidden (403)    | The token does not have access to this endpoint.                                        |
| NotFound (404)     | Cart or Property not found.                                                             |
| Conflict (409)     | Property already exists on the order.                                                   |

Error Response Example

```json
{
"errors":
    [
        {
            "error-description": "Property not found.",
            "error": "NotFound"
        }
    ]
}
```

## Related Articles

{% content-ref url="../error-handling" %}
[error-handling](https://dev.ucommerce.net/readme/headless/error-handling)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dev.ucommerce.net/readme/headless/reference/cart-custom-properties.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
