Skip to main content

Create Cost Entries from Bill Lines

POST 

/api/bills/:bill/cost-entries

Create one cost entry per selected bill line, each tracking a chosen amount of that line for profitability analysis. This is the scope: "lines" mode of the endpoint; to track the whole remaining bill as a single entry, see "Create Cost Entry from Bill" (same URL, scope: "entire").

Required scope: purchase-orders:write

Grant this scope to your token under Settings → Developer → Personal Access Tokens.

Each allocation amount may be the full line total or a partial amount, but cannot exceed what is still untracked on that line (check with the lines-availability endpoints first). When more than one line is sent, each entry's description is the name with the line's description appended. Entries inherit the bill's supplier, currency, exchange rate, and invoice number, are dated with the bill's invoice date, and start in pending_allocation status.

Request fields:

  • scope (required) - lines for this mode.
  • name (required, max 255) - Base description for the cost entries.
  • cost_entry_type_id (optional) - ID of a cost entry type (see GET /api/cost-entry-types); applies to every entry created. Omit or send null to leave them untyped.
  • notes (optional, max 1000) - Free-form notes.
  • line_allocations (required in this mode, min 1) - Array of allocations:
    • line_allocations[].bill_line_id (required, integer) - ID of a line on this bill.
    • line_allocations[].amount (required, numeric, min 0.01) - Amount of that line to track.

Returns 422 when a line does not belong to the bill or an amount exceeds the line's untracked remainder.

Authentication: Requires Bearer token. Scope: purchase-orders (read/write).

Request

Responses

OK

Response Headers
    Content-Type