> For the complete documentation index, see [llms.txt](https://en.help.firstline.cc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://en.help.firstline.cc/developer/api/contact-order-item.md).

# Order items

{% hint style="success" %}
This API is available for versions v.2.62.11 and later after 2024-10-04.
{% endhint %}

## Best Practices

During the integration process, the order item (contact-order-item) must specify the product (Product) and the order (order) it belongs to. The integration steps are as follows:

1. Use the order number (order\_number) to find the corresponding order ID (contact\_order\_id).
2. Use the product number (sku) or other information to obtain the product ID (product\_id).
3. Use the order number (order\_number) and product ID (product\_id) to create or update the order item.

These steps ensure that each order item is correctly associated with the corresponding product and order, improving the accuracy and efficiency of data integration.

## Search

```javascript
GET https://{API_HOST}/api/v1/contact-order/{contact_order}/contact-order-item
```

```javascript
curl -X GET "https://{API_HOST}/api/v1/contact-order/1/contact-order-item" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Accept: application/json"
```

### Response

| PROPERTY | TYPE             | DESCRIPTION                 |
| -------- | ---------------- | --------------------------- |
| **data** | Array of objects | Sales order item data array |
| **meta** | Object           | Pagination data             |

```json
{
    "data": [
        {
            "id": 2,
            "quantity": 1,
            "total_price_before_discounts": "3100.00",
            "total_discount": "0.00",
            "total_price_after_discounts": "3100.00",
            "product_id": 3,
            "contact_order_id": 1,
            "product":
            {
                "id": 3,
                "name": "Women's Dunk Low Medium Olive",
                "sku": "DD1503-120",
                "price": 3100},
            "created_at": "2024-09-27 15:44:03",
            "updated_at": "2024-09-27 15:44:03"
        }
    ],
    "links": {},
    "meta": {}
}
```

## Retrieve a single record

```javascript
GET https://{API_HOST}/api/v1/contact-order/{contact_order}/contact-order-item/{contact_order_item}
```

```javascript
curl -X GET
    -H "Content-Type: application/json"
    https://{API_HOST}/api/v1/contact-order/1/contact-order-item/36
```

### URL Parameters

| PARAMETER | REQUIRED | DEFAULT | TYPE   | DESCRIPTION          |
| --------- | -------- | ------- | ------ | -------------------- |
| **id**    | true     | NULL    | Number | Order item system ID |

### Response

| PROPERTY | TYPE   | DESCRIPTION           |
| -------- | ------ | --------------------- |
| **data** | Object | Sales order item data |

```json
{
    "data": {
        "id": 2,
        "quantity": 1,
        "total_price_before_discounts": "3100.00",
        "total_discount": "0.00",
        "total_price_after_discounts": "3100.00",
        "product_id": 3,
        "contact_order_id": 1,
        "product":
        {
            "id": 3,
            "name": "Women's Dunk Low Medium Olive",
            "sku": "DD1503-120",
            "price": 3100},
        "created_at": "2024-09-27 15:44:03",
        "updated_at": "2024-09-27 15:44:03"
    }
}
```

## Add

```javascript
POST https://{API_HOST}/api/v1/contact-order/{contact_order}/contact-order-item
```

```javascript
curl -X POST "https://{API_HOST}/api/v1/contact-order/1/contact-order-item" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"product_id": 3, "quantity": 2 }'
```

### JSON Request Body

| PARAMETER                       | REQUIRED | DEFAULT | TYPE          | DESCRIPTION                                   |
| ------------------------------- | -------- | ------- | ------------- | --------------------------------------------- |
| product\_id                     | true     | NULL    | Integer       | Unique identifier of the related product      |
| quantity                        | true     | NULL    | Integer       | Quantity of product purchased                 |
| total\_price\_before\_discounts | false    | NULL    | Decimal(10,2) | Item total price before discounts are applied |
| total\_discount                 | false    | NULL    | Decimal(10,2) | Total discount amount applied to the item     |
| total\_price\_after\_discounts  | false    | NULL    | Decimal(10,2) | Final item price after discounts are applied  |

### Response

```json
{
    "data": {
        "id": 2,
        "quantity": 1,
        "total_price_before_discounts": "3100.00",
        "total_discount": "0.00",
        "total_price_after_discounts": "3100.00",
        "product_id": 3,
        "contact_order_id": 1,
        "product":
        {
            "id": 3,
            "name": "Women's Dunk Low Medium Olive",
            "sku": "DD1503-120",
            "price": 3100},
        "created_at": "2024-09-27 15:44:03",
        "updated_at": "2024-09-27 15:44:03"
    }
}
```

## Update

```javascript
PUT https://{API_HOST}/api/v1/contact-order/{contact_order}/contact-order-item/{contact_order_item}
```

```javascript
curl -X PUT "https://{API_HOST}/api/v1/contact-order/1/contact-order-item/36" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"product_id": 3, "quantity": 2 }'
```
