> ## Documentation Index
> Fetch the complete documentation index at: https://agents.concierca.ch/llms.txt
> Use this file to discover all available pages before exploring further.

# Order Line Items

> Per-position line items of orders (Shopify). Read-only; linked to orders via order_external_id.

## What it is

Per-position line items of [Orders](/for-agents/data-model/orders) (Shopify-sourced). One row per order position: product, SKU, quantity, and the price actually paid. Read-only in the app; linked to orders via `order_external_id`.

Line items are what the demand engine actually counts — units sold per variant come from summing `quantity` here, joined to [Products](/for-agents/data-model/products) via `product_variant_external_id` → `products.external_id`. Quantity is always summed, never row-counted, so multi-unit lines are handled correctly.

## How it gets data

Ingest-enabled — external systems push rows through the [Ingest API](/for-agents/ingest):

```http theme={null}
POST /api/ingest/order_line_items
Authorization: Bearer pk_...
Content-Type: application/json
```

* One JSON record per request; unknown fields are dropped.
* **Idempotent upsert** on `(tenant_id, external_id)` — `external_id` is the source line-item id.
* `tenant_id` / `workspace_id` come from the API key context, never from the body.
* A ready-made **Make.com flow template** is downloadable in Settings → Data Sources.

Minimal example payload:

```json theme={null}
{
  "external_id": "gid://shopify/LineItem/987654",
  "order_external_id": "gid://shopify/Order/5678901234",
  "sku": "6304",
  "product_name": "Claire 6304 — 16 cm",
  "quantity": 1,
  "final_unit_price": 249.90,
  "currency": "EUR",
  "product_variant_external_id": "gid://shopify/ProductVariant/445566",
  "shop_source": "my-shop"
}
```

<Note>
  Always send `product_variant_external_id` when the source provides it. `product_external_id` is the parent-product gid and is too coarse for demand math — one product gid covers several SKUs/sizes.
</Note>

## Fields

### Line identity

| Field               | Label    | Type | Writable | Description                                            |
| ------------------- | -------- | ---- | -------- | ------------------------------------------------------ |
| `external_id`       | Line ID  | text | ingest   | Source line-item id — the upsert key. Required         |
| `order_external_id` | Order ID | link | ingest   | Parent order — joins to `orders.external_id`. Required |
| `title`             | Title    | text | ingest   | Product title as the source stores it on the line      |
| `name`              | Name     | text | ingest   | Display name of the line (title + variant option)      |
| `product_name`      | Product  | text | ingest   | Product title shown in the app's table                 |
| `shop_source`       | Shop     | text | ingest   | Which shop/store this line originated from             |
| `metadata`          | Metadata | json | ingest   | Raw source fields that don't map to a column           |

### Quantity & pricing

| Field                   | Label       | Type     | Writable | Description                                                                     |
| ----------------------- | ----------- | -------- | -------- | ------------------------------------------------------------------------------- |
| `quantity`              | Qty         | number   | ingest   | Units on this line — the number the demand engine sums                          |
| `original_unit_price`   | List Price  | currency | ingest   | Undiscounted unit price                                                         |
| `discounted_unit_price` | Disc. Price | currency | ingest   | Unit price after line-level discounts                                           |
| `final_unit_price`      | Unit Price  | currency | ingest   | Price actually paid per unit, after all discounts — the revenue-relevant number |
| `price`                 | Price       | currency | ingest   | Line price as delivered by the source                                           |
| `currency`              | Currency    | text     | ingest   | ISO currency code                                                               |

### Product linkage

| Field                         | Label            | Type    | Writable | Description                                                                                                                                     |
| ----------------------------- | ---------------- | ------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `sku`                         | SKU              | text    | ingest   | Variant SKU at order time. Not unique across sizes — use the variant id for joins                                                               |
| `barcode`                     | Barcode          | text    | ingest   | Variant barcode (EAN/UPC)                                                                                                                       |
| `product_variant_external_id` | Variant ID       | text    | ingest   | Source variant id (Shopify ProductVariant gid, `lineItem.variant.id`). Joins to `products.external_id` — the precise identity demand math needs |
| `product_external_id`         | Product ID       | text    | ingest   | Shopify Product gid — the parent product. Too coarse for per-variant demand: one product gid covers several SKUs/sizes                          |
| `product_legacy_id`           | Product (legacy) | text    | ingest   | Shopify numeric product id, for joining with legacy exports                                                                                     |
| `product_total_inventory`     | Inventory        | number  | ingest   | Product-level inventory snapshot the source reported at sync time                                                                               |
| `product_tracks_inventory`    | Tracks Inv.      | boolean | ingest   | Whether the source tracks inventory for this product                                                                                            |

"ingest" = populated through the ingest endpoint; read-only in the app and over MCP row writes. `metadata` is accepted on ingest but not surfaced as a default table column.

<Note>
  Like every workspace table, line items also carry the system columns `id`, `tenant_id`, `workspace_id`, `created_at`, and `updated_at` — set automatically, never sent by integrations.
</Note>

## Query it

```json theme={null}
{
  "method": "tools/call",
  "params": {
    "name": "data_query",
    "arguments": {
      "view_slug": "order_line_items",
      "filters": { "sku": "6304" },
      "select_fields": ["product_name", "quantity", "final_unit_price", "order_external_id"],
      "limit": 50
    }
  }
}
```
