# SubscriptionItem

One line on a customer subscription: what is being sold, how many, at what purchase and sales price, and at what VAT percentage. These lines are what a renewal turns into sales-invoice rows, and a subscription with no lines cannot be invoiced.

## Used by
- GET /api/v2/customer-subscriptions/{customer_subscription}/items: List a subscription's lines (SubscriptionItemList)
- POST /api/v2/customer-subscriptions/{customer_subscription}/items: Add a line to a subscription (SubscriptionItem)
- GET /api/v2/subscription-items/{subscription_item}: Read a subscription line (SubscriptionItem)
- PATCH /api/v2/subscription-items/{subscription_item}: Update a subscription line (SubscriptionItem)

## SubscriptionItem fields
- id (integer, required): Unique identifier.
- customer_subscription_id (integer, required, server-assigned): The subscription this line belongs to. Taken from the path on create and never writable afterwards: a line cannot be moved to another subscription.
- customer_subscription (Ref or CustomerSubscriptionSummary, required): The subscription this line belongs to.
- subscribable_type (string or null, required): The kind of record `subscribable` points at; it says which branch of `subscribable` applies.
- subscribable_id (integer or null, required): The id of the record `subscribable` points at.
- subscribable (Ref or SubscriptionProductSummary or null, required): What this line sells. Rendered as {"id": N} until named in `?include=subscribable`, which additionally requires the read permission and token scope of the `subscription_products` prefix. Lines that bill a hosting domain or a server carry a `subscribable_type` this API publishes no shape for, and keep the {"id": N} form however they are requested; identify those from `subscribable_type` and `subscribable_id` yourself. Null on both halves is a free-text line priced by hand.
- description (string or null, required, multiline): The line text, as printed on the invoice a renewal generates. May contain placeholders such as {{$domain}}; the API publishes the raw stored text and those are resolved only at invoice time.
- quantity (integer, required): Number of units billed per period.
- purchase_price (decimal (2 dp) ≥ 0, required): Cost price per unit, for margin bookkeeping only. It feeds neither generated amount below and appears on no invoice.
- sales_price (decimal (2 dp) ≥ 0, required): Sales price per unit, excluding VAT. This is what actually bills: a renewal copies it into the generated invoice row's unit price.
- vat_rate (integer, required): VAT percentage as a whole number: 21 means 21%.
- vat_amount (decimal (2 dp), required, server-assigned): VAT on this line, computed by the server: quantity x `sales_price` x `vat_rate` / 100. Read-only.
- total_amount (decimal (2 dp), required, server-assigned): Line total including VAT (quantity x `sales_price` plus the VAT above), computed by the server. Note this is the opposite convention from `SalesInvoiceRow.total_amount`, which excludes VAT: adding VAT to this value double-counts it. Read-only.
- sort_order (integer, required, server-assigned): Position of the line within its subscription, and the default sort key. Assigned on create; there is no way to reorder lines through the API. Only the ordering is meaningful: values are not unique across subscriptions.
- exact_item_id (string or null ≤ 255, required): Exact Online article identifier this line bills against. Optional: a renewal falls back to the subscription product's own Exact values and then to the organisation's Exact defaults, so leaving it empty does not break the sync.
- exact_vat_code (string or null ≤ 255, required): Exact Online VAT code, by code rather than by id.
- exact_gl_account (string or null ≤ 255, required): Exact Online general-ledger revenue account for this line.
- exact_cost_center (string or null ≤ 255, required): Exact Online cost-centre code.
- created_at (timestamp (YYYY-MM-DDThh:mm:ssZ), required): Creation timestamp.
- updated_at (timestamp (YYYY-MM-DDThh:mm:ssZ), required): Last-write timestamp; use for incremental sync. This is also the `ETag` revision: a subscription line has no `version` field.
- deleted_at (timestamp (YYYY-MM-DDThh:mm:ssZ) or null, required): Soft-delete timestamp, `null` while live.
- links (SubscriptionItemLinks, required)
  - self (url, required): The canonical URI of this record.

## Variants

### SubscriptionItemList

What a collection returns, and what `?view=summary` returns on a single record.

22 fields.
Identical to the detail object above.

### SubscriptionItemSummary

The embedded form: what you get when another resource carries this one and you did not `include` it.

2 fields.
Omits: customer_subscription_id, customer_subscription, subscribable_type, subscribable_id, subscribable, quantity, purchase_price, sales_price, vat_rate, vat_amount, total_amount, sort_order, exact_item_id, exact_vat_code, exact_gl_account, exact_cost_center, created_at, updated_at, deleted_at, links

### SubscriptionItemLinks

The `links` object on this resource.

Keys: self

## Polymorphic fields
- subscribable: discriminated on `subscribable_type`

## Columns deliberately not published
- resource_id: The other half of that pair, withheld with it.
- resource_type: The hosting site or server a line is sold for has no published shape in this API, so it is not exposed.

## Example
```json
{
  "id": 1,
  "customer_subscription_id": 1,
  "customer_subscription": {
    "id": 1
  },
  "subscribable_type": "subscription_product",
  "subscribable_id": 1,
  "subscribable": null,
  "description": "Webhosting {{$domain}}",
  "quantity": 1,
  "purchase_price": "4.50",
  "sales_price": "12.50",
  "vat_rate": 1,
  "vat_amount": "1250.00",
  "total_amount": "1250.00",
  "sort_order": 1,
  "exact_item_id": "…",
  "exact_vat_code": "…",
  "exact_gl_account": "…",
  "exact_cost_center": "…",
  "created_at": "2026-03-04T09:15:00Z",
  "updated_at": "2026-03-04T09:15:00Z",
  "deleted_at": "2026-03-04T09:15:00Z",
  "links": {
    "self": "https://<your-url>/api/v2/work-items/1"
  }
}
```
