# Get sell-through

> Units sold and revenue per culture line over a period, highest units first. Filter with from and to for the period and plant_id for one culture line.

Source: https://docs.xplantpro.com/docs/api/commerce/get-sell-through

`GET https://app.xplantpro.com/api/v1/commerce/sell-through`

- Required scope: `read:commerce`
- Credentials: workspace API key (`xpk_`)
- Idempotency-Key: ignored on this endpoint

Each group is one culture line in one currency. There is no combined total across currencies: groups in different currencies are separate figures and must not be added together. Revenue is exact decimal text, totalled from the recorded sales without floating-point rounding.

Pages by `offset`. Needs culture line pricing, which includes sell-through, in the workspace's plan; without it the answer is `FEATURE_NOT_INCLUDED`.

## Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `from` | string (date-time) | No | Only sales at or after this time, as an ISO 8601 timestamp. |
| `to` | string (date-time) | No | Only sales at or before this time, as an ISO 8601 timestamp. |
| `plant_id` | string (uuid) | No | Only this culture line's sales. A culture line is identified by its plant id. |
| `limit` | integer | No | Page size. Values above 200 are capped at 200. Default `50`. From 1 to 200. |
| `offset` | integer | No | Number of records to skip. Prefer `cursor` where a list offers it: an offset shifts when records are added ahead of it. Default `0`. At least 0. |

## Example

**curl**

```bash
curl "https://app.xplantpro.com/api/v1/commerce/sell-through?from=2026-09-01T00%3A00%3A00Z&to=2026-09-25T00%3A00%3A00Z" \
  -H "Authorization: Bearer $XPLANT_API_KEY"
```

**JavaScript**

```js
import { XPlantClient } from "@shmaplex/xplant-sdk";

const client = new XPlantClient({ apiKey: process.env.XPLANT_API_KEY });

const sellThrough = await client.commerce.getSellThrough({ from: "2026-09-01T00:00:00Z", to: "2026-09-25T00:00:00Z" });
```

**Python**

```python
import os
import requests

resp = requests.get(
    "https://app.xplantpro.com/api/v1/commerce/sell-through",
    headers={"Authorization": f"Bearer {os.environ['XPLANT_API_KEY']}"},
    params={
        "from": "2026-09-01T00:00:00Z",
        "to": "2026-09-25T00:00:00Z",
    },
    timeout=10,
)
body = resp.json()
if not body["ok"]:
    raise RuntimeError(f"{resp.status_code} {body['code']}: {body['error']}")
sellThrough = body["data"]
```

## Response

`200` with `{ "ok": true, "data": … }`. `data` is an array. Lists have no total: a page shorter than your `limit` is the last one. See [Pagination](https://docs.xplantpro.com/docs/pagination.md).

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `plant_id` | string \| null (uuid) | Yes | The culture line (a plant id). Null groups the sales of store products not yet matched to one. |
| `currency` | string \| null | Yes | The currency of every amount in this group. Null for lines that carried none. |
| `units` | integer | Yes | Total quantity sold. |
| `revenue` | object | Yes | — |
| `revenue.amount` | string | Yes | An exact decimal, as text — for example `"1250.00"`. Never a floating-point number; parse it with a decimal type. |
| `revenue.currency` | string \| null | Yes | ISO 4217 currency code, for example `USD`. Null only when the record carries no currency. Never add amounts in different currencies. |
| `order_line_count` | integer | Yes | — |
| `priced_line_count` | integer | Yes | Order lines that carried a unit price. Lines without one count toward `units` but not `revenue`. |
| `first_occurred_at` | string \| null | Yes | The earliest sale in the group. |
| `last_occurred_at` | string \| null | Yes | The latest sale in the group. |

```json title="Response"
{
  "ok": true,
  "data": [
    {
      "plant_id": "6d1b3f8a-4c2e-4a97-b5d0-8e7f2a1c9b43",
      "currency": "USD",
      "units": 42,
      "revenue": {
        "amount": "777.00",
        "currency": "USD"
      },
      "order_line_count": 17,
      "priced_line_count": 17,
      "first_occurred_at": "2026-07-02T10:11:00.000Z",
      "last_occurred_at": "2026-09-21T15:02:44.000Z"
    },
    {
      "plant_id": "6d1b3f8a-4c2e-4a97-b5d0-8e7f2a1c9b43",
      "currency": "EUR",
      "units": 6,
      "revenue": {
        "amount": "96.00",
        "currency": "EUR"
      },
      "order_line_count": 2,
      "priced_line_count": 2,
      "first_occurred_at": "2026-08-14T08:30:00.000Z",
      "last_occurred_at": "2026-09-03T12:45:10.000Z"
    }
  ]
}
```

| Response header | Meaning |
| --- | --- |
| `X-Request-Id` | Identifies this request. Include it when you contact support. |

## Errors

| Status | Code | When |
| --- | --- | --- |
| `401` | `UNAUTHORIZED` | The key is missing, malformed or revoked, or its owner is no longer a member of the workspace. |
| `402` | `PAID_PLAN_REQUIRED` | The workspace's plan does not include the API. The full API is included with xPlant+ Teams and Enterprise; on Hobby and Pro Lab, keys can connect devices only. |
| `402` | `FEATURE_NOT_INCLUDED` | Culture line pricing, which includes sell-through, is not included in your plan. |
| `403` | `FORBIDDEN` | The key lacks a scope this operation requires, or its owner's current role in the workspace cannot use it — a key never does more than its owner can in xPlant. `error` names the scope, and for a role, the role it needs. |
| `403` | `DEVICE_TOKEN_NOT_ACCEPTED` | A device token was sent; this operation needs a workspace API key. |
| `404` | `NOT_FOUND` | `plant_id` names no culture line in the key's workspace. |
| `422` | `VALIDATION_ERROR` | A query parameter is malformed, or `from` is later than `to`. `error` names it. |
| `429` | `RATE_LIMIT_EXCEEDED` | Too many requests for this key, device token or workspace. Wait `Retry-After` seconds. |
| `500` | `FEATURE_CHECK_FAILED` | Your plan could not be checked. Retry later. |
| `500` | `SELL_THROUGH_EVENT_QUERY_FAILED` | The sales could not be read. Retry later. |

Branch on `code`, never on the `error` text. See [Errors](https://docs.xplantpro.com/docs/errors.md).
