Project expenses
A project expense records that the cost of an expense transaction, or part
of it, is billed to a client under a project. The
transaction stays an ordinary expense in the ledger and in every report: the
link only adds what an invoice will later bill for. A
project expense exists only in business workspaces:
every operation below returns 409 WORKSPACE_NOT_BUSINESS in a personal
workspace, and changing one needs a plan that includes business tools (402
otherwise; reads stay open after a downgrade).
All paths are under /v1/workspaces/{workspaceID}. Project expense IDs start
with pexp_.
| Operation | Method and path | Scope |
|---|---|---|
list-project-expenses | GET /project-expenses | projects:read |
get-project-expense | GET /project-expenses/{expenseID} | projects:read |
get-project-expense-summary | GET /project-expenses/summary | projects:read |
create-project-expense | POST /project-expenses | projects:write |
update-project-expense | PATCH /project-expenses/{expenseID} | projects:write |
delete-project-expense | DELETE /project-expenses/{expenseID} | projects:write |
preview-expense-bill | POST /project-expenses/bill/preview | invoices:write |
bill-expenses | POST /project-expenses/bill | invoices:write |
The projects:write scope is not offered to connected apps (OAuth or MCP
clients); projects:read is. See Scopes. Linking an
expense needs the role editor, admin or owner; viewers can read.
The last two operations bill expenses onto a draft invoice; see
Billing expenses onto an invoice. Until an
expense is billed it reads as unbilled (or non_billable).
The project expense object
{
"id": "pexp_...",
"kind": "expense",
"projectId": "prj_...",
"transactionId": "txn_...",
"userId": "usr_...",
"date": "2026-11-03",
"description": "Paper Planet - Printer paper",
"amount": { "minor": 12345, "display": "$123.45" },
"markupBps": 1250,
"billableAmount": { "minor": 13888, "display": "$138.88" },
"billable": true,
"metadata": { "receipt": "r-1" },
"status": "unbilled",
"createdAt": "2026-11-03T10:00:00Z",
"updatedAt": "2026-11-03T10:00:00Z"
}
transactionIdandprojectIdare required when creating. The transaction must be an expense in the workspace: income, transfers and opening balances are refused with422projectExpenseTransactionNotExpense, and an unknown transaction is a plain404. The project must not be archived (409PROJECT_ARCHIVED).- One transaction has at most one link. A second one is
409PROJECT_EXPENSE_ALREADY_LINKED;details.projectExpenseIdnames the existing link. A receipt can't be split across two clients: bill part of it throughamountMinorand add the rest to an invoice by hand. amountMinor(request) andamount(response) are the cost to bill. It defaults to the transaction amount, can be lower (part of a receipt) and is never higher or zero (422invalidProjectExpenseAmount).markupBpsis a markup in basis points, 0 to 10,000 (100 is 1%;422invalidProjectExpenseMarkupoutside that).billableAmountisamountplus the markup, rounded half-up once to the smallest stored unit, which is what an invoice line bills. An invoice line sums its expenses exactly and rounds half-up once to the currency precision (see Billing expenses onto an invoice), so a line can differ from the sum ofbillableAmountby the rounding of a sub-cent amount.datedefaults to the transaction date.descriptionis a single line of at most 500 characters (422invalidProjectExpenseDescriptionfor a line break or more) and defaults to the payee name and the memo; it becomes the invoice line description.billabledefaults totrue.falsekeeps the expense on the project for cost tracking without billing it.statusis derived:billedwhen an invoice line bills it,written_offwhen an invoice's billing wrote it off,non_billablewhen it is not billable and neither of those, otherwiseunbilled.invoiceLineId,invoiceIdandwrittenOffInvoiceIdare present when they apply.userIdis the member who linked it. The transaction a link points at never changes: delete the link and add another.metadatacarries your own key/value pairs, like every other business record. See Metadata.
On update-project-expense fields left out are unchanged. A billed expense can't
be edited or deleted (409 PROJECT_EXPENSE_BILLED; details.invoiceId names
the invoice, and voiding it releases the expense). A request that carries only
metadata still works on a billed expense.
An expense that billing wrote off (status written_off) keeps its cost
fields until the write-off is restored: changing projectId, amountMinor,
markupBps or billable is refused with 409 PROJECT_EXPENSE_WRITTEN_OFF
(details.invoiceId names the invoice). date, description and metadata
stay editable, and deleting or voiding that invoice frees the other fields.
Listing and summary
list-project-expenses takes projectId, transactionId, userId, from
and to (inclusive YYYY-MM-DD), status (unbilled, billed,
written_off or non_billable), metadata[key]=value, page and pageSize
(default 100, max 1000). It returns { expenses, total, page, pageSize, totalAmount }, newest day first. totalAmount is the cost, before markup, of
every expense that matches the filter, not just the page.
get-project-expense-summary returns one row for each project that has
expenses (optionally one projectId), in project ID order: unbilledCount,
unbilledAmount (cost), unbilledBillableAmount (the same with markup, what
billing it would add to an invoice), billedCount, billedAmount (with markup,
as billed), nonBillableCount and nonBillableAmount.
What it does to the transaction
The transactions API guards a linked transaction so the link can never describe money that isn't there:
| Change to the transaction | Unbilled link | Billed link |
|---|---|---|
| Amount raised, or lowered to the cost or more | Nothing changes | Nothing changes |
| Amount lowered below the cost | The cost drops to the new amount, and project_expense.updated records it with clamped_to_transaction | 409 TRANSACTION_BILLED_ON_INVOICE |
Deleted (delete-transaction, bulk-delete-transactions) | The link is deleted with it and project_expense.deleted is published | 409 TRANSACTION_BILLED_ON_INVOICE; a bulk delete changes nothing |
| Converted to a transfer | 409 TRANSACTION_HAS_PROJECT_EXPENSE | 409 TRANSACTION_HAS_PROJECT_EXPENSE |
TRANSACTION_BILLED_ON_INVOICE names the transaction, the project expense and
the invoice in details. A project with expenses can't be deleted (409
PROJECT_IN_USE); delete the links or archive the project.
A refund is a separate income transaction and never adjusts a billed expense by itself. A project expense is billed at the amount entered, as is. Its invoice line takes the workspace's default tax rate like any other new line (and the invoice's tax is computed from the lines as usual), and Budget Thing gives no tax advice on it.
Billing expenses onto an invoice
preview-expense-bill and bill-expenses bill the cost of expenses of one
project to a draft invoice of that project, or to a new draft created in it,
the way Bill time with a preview
bills time. Both take the same body, need the invoices:write scope and the write role, and need a
plan that includes business tools to bill (402 otherwise); the preview changes
and locks nothing.
{
"invoiceId": "inv_...",
"expenses": [
{ "id": "pexp_..." },
{ "id": "pexp_...", "writeOff": true }
],
"lineMode": "detailed",
"descriptionOverrides": { "expense:pexp_...": "Printer paper" }
}
Give invoiceId or "newInvoice": true, not both. Every expense in one call
must belong to one project (422 PROJECT_EXPENSES_MULTIPLE_PROJECTS, the
project IDs in details.projectIds), and the draft must be in that project (422
PROJECT_EXPENSE_NOT_BILLABLE, details.reason other_project); a non-draft is
409 INVOICE_NOT_DRAFT. An invoice with no project (a client-only invoice) is
422 INVOICE_HAS_NO_PROJECT.
expenses(1 to 1000, each at most once). An expense that is already billed is409PROJECT_EXPENSE_BILLED(details.invoiceIdnames the invoice), one written off by another invoice is409PROJECT_EXPENSE_WRITTEN_OFF, and one withbillablefalseis422PROJECT_EXPENSE_NOT_BILLABLE(details.reasonnot_billable).writeOfftruedoesn't bill the expense: the invoice writes its whole cost off (statuswritten_off,writtenOffInvoiceId) and no line is created for it. Deleting or voiding the invoice restores it. A call that only writes off needsinvoiceId;newInvoicewould leave an empty draft, so it is422invalidBillExpenses.lineMode:summaryis one line and needssummaryDescription;groupedis one line per project (groupByproject, the only grouping, so one line, named for the project);detailedis one line per expense.- Line totals. An expense line has
sourceexpense, unititem, quantity 1 and a unit price equal to its total. The total isΣ amount × (10000 + markupBps) ÷ 10000over the line's expenses, summed exactly and rounded half-up once to the currency precision, so a summary line of two 0.05 expenses with 10% markup is 0.11, not 0.06 + 0.06. The invoice total is checked against the largest storable amount (422VALIDATION_FAILED,amountOutOfRange) and the line limit applies. - Descriptions are data only. The default is the expense's
description, or itsYYYY-MM-DDdate when empty (detailed), or the project name (grouped). SendsummaryDescriptionfor the summary line;descriptionOverridesreplaces any line's text by itskey, and keys that match no line are ignored. - Line keys:
summary,project:<id>(grouped) andexpense:<id>(detailed).
The preview returns lines (each with key, kind expense, description,
projectExpenseIds and total), billedCount, writtenOffCount, linesTotal
(what the new lines add) and invoiceTotal (the invoice's own lines plus the new
ones, with tax; no invoiceId when a new draft would be created). bill-expenses
does the same atomically and answers 201 with invoice (all lines), lines
(the ones just added), created, billedCount and writtenOffCount. Nothing is
created when any check fails. A billed expense gets invoiceLineId and
invoiceId; the change is recorded in the security log as
invoice.expenses_billed (amounts and counts, no text), and invoice.updated
webhooks fire as for any draft change.
Release. Deleting the invoice line, deleting the draft, or voiding the issued
invoice releases the expenses exactly like billed time: invoiceLineId clears,
write-offs restore, and the expense can be edited and billed again. An expense an
invoice bills can't be edited or deleted, and its transaction can't be deleted or
lowered below the cost (see above). The price and quantity of an expense line
follow its expenses (422 invoiceExpenseLineLocked); its discount, wording,
tax rate and position can change.
Locking. The bill locks the draft invoice first, then the project, then the
transactions, then the expenses, each in ID order, the same order the
transactions service and these endpoints use, so a bill and an edit of the linked
transaction can't deadlock. Concurrent bills of the same expense leave exactly one
winner; the others get 409 PROJECT_EXPENSE_BILLED. Everything is re-read after
the locks, so a bill sees a cost that a concurrent transaction edit lowered.
Unbilled expenses also appear in the time by project report.
Webhooks
project_expense.created, project_expense.updated and
project_expense.deleted are public webhook events
in the Projects domain; they need projects:read. They carry identifiers, the
date, the cost in the stored scale (amount_minor), the markup, the billable
flag and the metadata, never the description. project_expense.updated
carries changes for project_id, date, amount_minor, markup_bps and
billable, and clamped_to_transaction: true when a lowered transaction amount
lowered the cost; project_expense.deleted carries with_transaction: true
when the link went with its transaction.
Backup, export and clones
Project expenses are part of workspace backups, which can only be restored into
a business workspace, and restore linked to the restored project, transaction
and invoice line. Workspace clones copy them. The data export lists
them as projectExpenses in data.json and as project-expenses.csv, with the
cost in the workspace's minor unit and no member IDs. Purging a workspace
deletes them with it.
Errors
| Status | Code | Meaning |
|---|---|---|
404 | PROJECT_EXPENSE_NOT_FOUND | No project expense with that ID in the workspace. |
409 | PROJECT_EXPENSE_BILLED | An invoice bills the expense; it can't be edited or deleted. |
409 | PROJECT_EXPENSE_WRITTEN_OFF | An invoice's billing wrote the expense off; delete or void that invoice to bill it again. Editing projectId, amountMinor, markupBps or billable is refused the same way. |
409 | PROJECT_EXPENSE_ALREADY_LINKED | The transaction already has a link. |
409 | TRANSACTION_BILLED_ON_INVOICE | A billed link keeps the transaction from being deleted or lowered below the cost. |
409 | TRANSACTION_HAS_PROJECT_EXPENSE | A linked transaction can't become a transfer. |
409 | PROJECT_ARCHIVED | The project is archived. |
409 | WORKSPACE_NOT_BUSINESS | The workspace is a personal workspace. |
422 | PROJECT_EXPENSE_NOT_BILLABLE | The expense can't be billed: it is flagged not billable, or belongs to another project than the invoice's (details.reason). |
422 | PROJECT_EXPENSES_MULTIPLE_PROJECTS | A bill names expenses of more than one project. |
422 | VALIDATION_FAILED | A cost, markup, description, date or transaction kind the API refuses (invalidProjectExpenseAmount and the others above). |