Skip to content

Set the revenue account, class and service period of an invoice line

PATCH
/invoices/{id}/line-items/{lineItemId}/accounting
Code sample: Shell / cURL
curl --request PATCH \
--url https://example.com/api/v1/invoices/example/line-items/example/accounting \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "exception": true, "periodEnd": "2026-04-15", "periodStart": "2026-04-15", "revenueAccountId": "example", "teamId": "example" }'

Sets the revenue account, the class (the team the accountants book the line under) and the service period (periodStart, periodEnd) of one line. The account and class change on an invoice in any status; the period on any but CANCELLED (409), and a change of only the period needs no active revenue account. It never changes the line’s quantity, rate or amount, or the invoice totals. A null clears a field and an omitted field is kept; a class sent as teamId is recorded as MANUAL; a period end before its start answers 400. The fields the workspace locks on a service line (lockedLineFields in the invoice settings; the description by default) keep what the service filled: changing one answers 409 FIELD_LOCKED unless the body carries exception: true, which applies the change, records the field in editedFields and writes it to the audit entry. The change is written to the invoice history under the caller. A workspace with no active revenue account answers 400 for an account or class, and an invoice recorded from another system has no lines to edit and answers 409. Requires the invoices.manage permission and the invoice to be in the caller’s invoice scope. Staff only: Customer tokens never reach it.

id
required

Resource identifier (CUID2).

string
>= 1 characters

Resource identifier (CUID2).

lineItemId
required

Line item identifier (CUID2).

string
>= 1 characters

Line item identifier (CUID2).

Media typeapplication/json
object
exception

Send true to change a field the workspace locks on a service line (see lockedLineFields in the invoice settings): the change is then applied, the field is recorded as edited by hand and the audit entry carries it. Without it, changing a locked field is refused with 409 FIELD_LOCKED. A locked description is left as the service set it. Custom lines are never locked.

boolean
periodEnd

Last day of the service period the line bills (YYYY-MM-DD), on or after periodStart. Null clears it; omit it to keep it. The client sees it.

Any of:
string format: date
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))$/
periodStart

First day of the service period the line bills (YYYY-MM-DD). Null clears it; omit it to keep it. The client sees it on the invoice, its PDF and public page.

Any of:
string format: date
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))$/
revenueAccountId

Revenue account of the line, from the workspace catalog (GET /revenue-accounts). Null clears it; omit it to keep it. Staff only: never shown to the client.

Any of:
string
>= 1 characters
teamId

The team whose accounting class the line carries (GET /teams). Null clears it; omit it to keep it. A class set here is recorded as MANUAL, so automatic resolution never changes it. Staff only: never shown to the client.

Any of:
string
>= 1 characters

Example generated

{
"exception": true,
"periodEnd": "2026-04-15",
"periodStart": "2026-04-15",
"revenueAccountId": "example",
"teamId": "example"
}

The updated line item.

Media typeapplication/json
object
data
required

A single line on an invoice. serviceId, service, revenueAccountId, revenueAccount, teamId, team, classSource and editedFields are staff-only: Customer MCP tokens, the portal, the public link and the PDF never carry them. Those surfaces carry listRate only when it is above rate.

object
amount
required

Quantity times rate less discountPercent, rounded to the cent. The invoice subtotal is the sum of these net amounts.

number
classSource
required

How the class was set: RESOLVED from the service rule and the company’s team, or MANUAL when a person picked it. Null while the class is unset. Staff only.

Any of:
string
Allowed values: RESOLVED MANUAL
description
required
string
discountPercent
required

Percentage taken off quantity times rate on this line; null for none. Never set on an invoice with an invoice-wide discount.

number | null
editedFields
required

The locked fields of a service line (account, class, period, description) that were changed by hand with exception: true. Empty for a line nobody changed and for a Custom line. Staff only.

Array<string>
id
required
string
invoiceId
required
string
kindId
required

Invoice line item kind; null for free-form items.

string | null
listRate
required

The service’s standard hourly rate when the line was created. A client document shows it struck through only when it is above rate; null for a line with no standard rate.

number | null
note
required

A note the client sees under the description.

string | null
orderId
required
string | null
periodEnd
required

Last day of the service period the line bills (YYYY-MM-DD); null when none.

Any of:
string format: date
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))$/
periodStart
required

First day of the service period the line bills (YYYY-MM-DD); null when none.

Any of:
string format: date
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))$/
position
required

Zero-based sort position on the invoice.

integer
>= -9007199254740991 <= 9007199254740991
quantity
required
number
rate
required
number
revenueAccount
required

The line’s revenue account. Staff only; null while unset.

Any of:
object
code
required
string
id
required
string
name
required
string
revenueAccountId
required

Revenue account of the line. Staff only; null while unset.

string | null
service
required

The service the line was built from; null for a Custom line.

Any of:
object
id
required
string
name
required
string
serviceId
required

The service the line was built from; null for a Custom line.

string | null
team
required

The line’s class team. Staff only; null while unset.

Any of:
object
accountingClassName
required

The class name accounting reads; null when the team has none.

string | null
id
required
string
name
required
string
teamId
required

The team whose accounting class the line carries. Staff only; null while unset.

string | null

Example

{
"data": {
"classSource": "RESOLVED"
}
}

The body is invalid, or the caller’s role holds invoices.accounting_required and the line would be saved with an amount but without a revenue account (and a class, when the workspace requires one).

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Unauthorized.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Forbidden.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

The invoice or line item does not exist or is outside the caller’s scope, the line does not belong to that invoice, or the revenue account or team does not exist.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

The invoice was recorded from another system and has no lines, the period was changed on a CANCELLED invoice, or a locked account, class or service period of a service line was changed without exception: true (FIELD_LOCKED).

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Rate limit exceeded. Wait for Retry-After before retrying.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}
RateLimit-Limit
string
/^\d+$/

Maximum requests in the current quota window.

RateLimit-Policy
string

Quota policy in requests and window seconds, for example 60;w=60.

RateLimit-Remaining
string
/^\d+$/

Requests left in this quota window (zero when blocked).

RateLimit-Reset
string
/^\d+$/

Seconds until the current quota window resets, when available from the rate-limit store.

Retry-After
string
/^\d+$/

Seconds until another request may be attempted.