> 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/line-item-custom-properties.md).

# Line Item 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](/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)

## Add Custom Properties to Line Item

### Parameters

* `lineId` (string)
* `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>/<lineId>/properties \
    -H 'Authorization: Bearer <ACCESS_TOKEN>'
    -H 'Content-Type: application/json' \
    -d '{
        "cultureCode": "<cultureCode>",
        "priceGroupId": "<priceGroupId>",
        "key": "<key>",
        "value": "<value>"
    }'
```

### Response

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

## Delete Custom Property from Line Item

### 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")
* `lineId` (string)

### Request

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

### Response

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

## Get Custom Properties for Line Item

### Parameters

* `lineId` (string)

### Request

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

### Response

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

## Update Custom Properties for Line Item

### Parameters

* `lineId` (string)
* `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>/lines/<lineId>/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; AccessToken was 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="/pages/OKRcu1Dp3gn5Y38w55HD" %}
[Error Handling](/readme/headless/error-handling.md)
{% endcontent-ref %}
