Billing and catalogue API: retainers, services and packages
Retainers, draft invoice edits, services and packages over the API and MCP: the routes, their scopes, the replace-set rules and the currency rule.
These routes cover what you bill and what you sell. Every MCP tool calls exactly one REST route, under the same scope check and member permissions. Every path below is under /api/v1/workspaces/{slug} and follows the usual rules: bearer credential, the workspace in the path, problem-details errors. A record that belongs to another workspace is always 404 not_found, and a currency other than the workspace's is 409 currency_mismatch.
Replace-sets
Two writes here REPLACE a set instead of merging into it. Send everything you want to keep.
- PATCH …/invoices/{id} (invoices:write, tool update_invoice) edits a draft invoice. When lineItems is present it is the whole list: a line with its id is updated, a line without one is added, and any existing line you leave out is deleted. Totals are recomputed from the result. A sent invoice is 409 conflict.
- PATCH …/packages/{id} (services:write, tool update_package): items, when sent, replaces the package's lines. Leave it out to keep them.
Retainers
A retainer is an allowance a client buys each period (or once). Creating one opens its first period in the same step, and every read carries the open period and the remaining balance.
- GET …/retainers (invoices:read, tool list_retainers): newest first, up to 200, not paginated. Filter by status (active or inactive) or client_id.
- GET …/retainers/{id} (invoices:read, tool get_retainer): one retainer with its open period and balance.
- POST …/retainers (invoices:write, tool create_retainer): clientId, name, amountCents, currency (the workspace's), cadence (none, monthly or quarterly) and startsOn; optionally carryover (expire or rollover), rolloverCapCents and endsOn. A one-off block (cadence: none) requires endsOn, the end of its single period. Dates are dates: the time of day is dropped.
- PATCH …/retainers/{id} (invoices:write, tool update_retainer): only the fields present are written, and null clears the cap or the end date. A new fee applies from the NEXT period; the open period keeps the allowance it opened with. The currency cannot change.
- POST …/retainers/{id}/deactivate (invoices:write, tool deactivate_retainer) switches a retainer off and keeps its periods and invoices. It is idempotent: deactivating an inactive retainer answers 200.
None of these five operations closes a period.
Services and packages
- GET …/services (tool list_services) lists the services.
- POST …/services (services:write, tool create_service): name, pricingType (hourly or fixed) and rateCents in the workspace currency; optionally description, categoryId and active.
- PATCH …/services/{id} (services:write, tool update_service): null clears description or categoryId. Changing rateCents or pricingType closes the current rate in the history and opens a new one; invoices already issued keep the rate they were issued at. active: false archives the service and true restores it.
- POST …/packages (services:write, tool create_package) bundles services at one price: name, priceCents and items, one { serviceId, quantity } per service (at least one, each service once). A service of another workspace is 404 and nothing is created.
- PATCH …/packages/{id} (services:write, tool update_package): null clears description, active: false archives it, and items replaces the package's lines.
Neither a service nor a package can be deleted; archive it with active: false.
To send a drafted invoice, see Send invoices and quotes through the API. For the screens behind these routes, read the guides Retainers and Services and rates.