# PATCH /api/v2/subscription-items/{subscription_item}

Update a subscription line

- MCP id: subscription-items.update
- Scope: api:write:customer_subscriptions
- Permission: customer_subscriptions::update
- Needs the billing feature on your organisation
- Rate cost: 1 unit, write bucket. A write costs the same whatever `view` you ask for.
- Cache-Control: private, no-store

Partially updates one line: absent keys are untouched.

Send `If-Match` with the `ETag` from your last read to detect a concurrent edit, which answers `412`. `vat_amount` and `total_amount` are recomputed by the server from quantity, `sales_price` and `vat_rate` and are never accepted. `customer_subscription_id` and `sort_order` are not accepted either: a line cannot be moved to another subscription, and there is no way to reorder lines through the API. Repointing subscribable away from a hosting product also clears the hosting site or server linked to the line in plnnrly; that link is not published by this API, so send subscribable only when you mean to change what is being sold. A deleted line answers `404` unless `trashed=with` is passed.

## Parameters
- subscription_item (integer, path): The SubscriptionItem's numeric id. Accepts a soft-deleted record.
- view (string, optional): Which field set to render.
- trashed (string, optional): Whether soft-deleted rows are included.
- X-Request-Id (header, optional): A correlation id of your own. It is recorded in our logs next to the server's request id but never returned: the response header always carries the server's id. A value that does not match the pattern is discarded silently, never rejected.
- If-Match (header, optional): The ETag a write is conditional on. A stale validator is 412 precondition-failed.

## Request body
- description (string or null, optional): 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 ≥ 1, optional): Number of units billed per period.
- purchase_price (decimal (2 dp) 0 to 99999999.99, optional): Cost price per unit, for margin bookkeeping only. It feeds neither generated amount below and appears on no invoice. At least 0. At most 99999999.99.
- sales_price (decimal (2 dp) 0 to 99999999.99, optional): Sales price per unit, excluding VAT. This is what actually bills: a renewal copies it into the generated invoice row's unit price. At least 0. At most 99999999.99.
- vat_rate (integer 0 to 100, optional): VAT percentage as a whole number: 21 means 21%.
- subscribable_type (string or null, optional): 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. Required when subscribable_id is present.
- subscribable_id (integer or null → SubscriptionProduct.id, optional): 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. Required when subscribable_type is present.
- exact_item_id (string or null ≤ 255, optional): 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, optional): Exact Online VAT code, by code rather than by id.
- exact_gl_account (string or null ≤ 255, optional): Exact Online general-ledger revenue account for this line.
- exact_cost_center (string or null ≤ 255, optional): Exact Online cost-centre code.

Unknown keys are refused with `422` validation-failed, naming the key.

## Response 200
- 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.

## Errors
- 403 forbidden-by-policy | insufficient-permission | insufficient-token-scope: Forbidden.
- 412 precondition-failed: Precondition failed.
- 415 unsupported-media-type: Unsupported media type.
- 422 unprocessable-relationship | validation-failed: Unprocessable content.
- 400 idempotency-key-required | invalid-cursor | invalid-query-parameter | malformed-request | unsupported-parameter: Bad request.
- 401 token-expired | unauthenticated: Unauthenticated.
- 404 endpoint-not-found | resource-not-found: Not found.
- 406 not-acceptable: Not acceptable.
- 429 rate-limit-exceeded: Too many requests.
- 500 internal-error: Server error.
- 503 tenant-unavailable: Service unavailable.

## Example
```bash
curl -X PATCH \
  'https://<your-url>/api/v2/subscription-items/1' \
  -H 'Authorization: Bearer <token>' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'If-Match: *' \
  -d '{
    "sales_price": "14.95"
  }'
```
