Resources
Invoices
Find, create, and edit invoices, including their sections and lines. Find the project first with GET /v1/opportunities, then work with the invoices on it.
What the API can do
You can search invoices, read one, create one (blank or copied from an estimate), and add, edit, and delete the sections and lines of a draft. A key acts as the workspace member who generated it, so that member needs invoices.view to read, invoices.create to create, and invoices.editfor every other write. Every write is recorded in the workspace's audit log against that member.
What the API cannot do
It never sends, voids, pays, archives, or deletes an invoice. Do those in Coastline.
It cannot change an invoice that has been sent. Every write to an invoice that is not a draft answers 409 conflict.
New sections and lines always go on the end. There is no way to reorder them through the API.
Drafts only
An invoice can be edited through the API while it is a draft with no payment applied. Anything else answers 409 conflict with one of three messages:
| Situation | Type | Description |
|---|---|---|
| sent, partial, paid, refunded or void | 409 | Only draft invoices can be edited through the API. This invoice is sent. |
| a payment is applied | 409 | This invoice has a payment applied and can no longer be edited. |
| archived | 409 | This invoice is archived and cannot be edited. |
Reads work in every status. The note about a payment applied is not the same as the status: a draft can carry a deposit, and that invoice has been live on the customer's pay page even though its status still reads draft.
Money and quantities
Amounts are in dollars. total is the stored grand total, subtotal and tax are computed from the lines, and balance_due is total - amount_paid. Invoice list rows carry total and balance_due too, because the total is stored rather than summed per request.
Copying an estimate? Read this
On an estimate a line's unit_cost is your cost, and its price is what the customer sees. On an invoice unit_costis the billed price itself. An invoice has no markup. If you carry lines across by hand, send the estimate's price as the invoice's unit_cost. Sending the estimate's unit_cost bills your cost to the customer.
Easier: pass estimate_id when you create the invoice and Coastline copies the sections and lines for you, flattening the markup correctly.
quantity is the final quantity. Invoice sections carry no margin, so margin is refused with its own message rather than ignored. The API does not accept or return waste_pct; apply waste before you send the quantity.
Dates
issue_date and due_dateare calendar dates in the workspace's timezone. Setting payment_terms to a Net term recomputes due_date from issue_date; setting due_date alone implies on_specific_date; moving issue_date under a scheduled term moves due_date with it.
/v1/invoicesFind an invoice
All filters are optional and combine. Results are newest first. Archived invoices are hidden unless you ask for them. The response carries has_more rather than a count.
| Query parameter | Type | Description |
|---|---|---|
| project_id | uuid | Only invoices on this project. |
| status | enum | One of: draft, sent, partial, paid, refunded, void. Overdue is not a status: it is a due date in the past with a balance remaining. |
| contact_id | uuid | Only invoices addressed to this contact. |
| q | string | Case-insensitive match on the invoice name. |
| updated_since | ISO timestamp | Only invoices changed at or after this time. |
| include_archived | boolean | Default false. true includes archived invoices. |
| limit | integer | Default 25, maximum 100. |
| offset | integer | Default 0. |
/v1/invoices/{id}Read an invoice
Returns the invoice with its sections in order and each section's lines in order, plus subtotal, tax, total, balance_due and a customer-facing reference such as INV-1042-3. tax_rate is a fraction: 0.0825 is 8.25%.
This works in every status, so you can confirm what a sent invoice says without changing it.
/v1/invoicesCreate an invoice
Creates a draft with one section named Invoice and no lines, or with the sections and lines of an estimate when you pass estimate_id. The tax rate comes from the estimate, then the project's location, then the workspace default; payment terms and the due date come from the workspace default; the contact and bill-to are copied from the project.
| Field | Type | Description |
|---|---|---|
| project_id | uuid | Required. The project the invoice belongs to. |
| name | string | Required, up to 200 characters. |
| estimate_id | uuid | Optional. Copies that estimate's sections and lines in, flattening its margin into the billed price. |
| id | uuid | Optional. Your own id for the invoice, so a retry is safe. See Safe retries. |
/v1/invoices/{id}Edit a draft's header
Send only the fields you want to change. Every field is optional, and at least one is required.
| Field | Type | Description |
|---|---|---|
| name | string | Up to 200 characters. |
| notes | string | Up to 10,000 characters. Null clears it. |
| tax_rate | number | A fraction from 0 to 1. Changing it moves the stored total. |
| issue_date | date | YYYY-MM-DD. |
| due_date | date | YYYY-MM-DD. Sending this alone sets payment_terms to on_specific_date. |
| payment_terms | enum | due_on_receipt, net_7, net_15, net_30, net_45, net_60, or on_specific_date. |
| contact_id | uuid | A contact in your workspace. Null clears it. |
| project_manager_id | uuid | A member of your workspace. Null clears it. |
| allow_card | boolean | Whether the pay page offers card. Takes effect when the invoice is sent. |
| allow_bank | boolean | Whether the pay page offers bank transfer. Takes effect when the invoice is sent. |
status is refused with a message saying those changes stay in Coastline. amount_paid, amount_total, invoice_number, account_id and every payment-processor field are unknown fields. The bill-to is copied from the project when the invoice is created and does not change afterwards.
/v1/invoices/{id}/sectionsAdd a section
Appends a section after the last one. A new section has no lines: unlike the builder, the API does not seed a blank one, so a section you add is empty until you add lines to it.
| Field | Type | Description |
|---|---|---|
| name | string | Up to 200 characters. Defaults to Invoice. |
| taxable | boolean | Defaults to true. |
| id | uuid | Optional. Your own id, so a retry is safe. |
/v1/invoices/{id}/sections/{sectionId}Rename a section
name and taxable only. marginis refused: invoice sections do not carry a margin, so send the price you want as each line's unit_cost.
/v1/invoices/{id}/sections/{sectionId}Delete a section
Deletes the section and every line in it. There is no way to delete the lines and keep the section. Coastline reads the section as it stands at that moment and deletes exactly what it found, so a line added while your request was in flight makes the delete answer 409 conflict instead of silently removing something you never saw.
/v1/invoices/{id}/itemsAdd lines
Add one line, or up to 200 in a single request. A batch is one write: it lands whole or not at all, so you never end up with half a section. Lines append after the section's last line.
| Field | Type | Description |
|---|---|---|
| section_id | uuid | Required. The section to add to. |
| items | array | Optional. 1 to 200 lines. Send either items or a single line, never both. |
| name | string | Required on each line, up to 500 characters. |
| description | string | Up to 5,000 characters. Null clears it. |
| quantity | number | The final quantity. Defaults to 1. |
| unit | string | Up to 20 characters, for example ea, hr, sf. Defaults to ea. |
| unit_cost | number | The billed price per unit. Defaults to 0. There is no markup on an invoice. |
| catalog_item_id | uuid | Optional link to an item in your catalog. The price still comes from unit_cost. |
| id | uuid | Optional on each line, so a retry is safe. Send an id on every line or on none. |
/v1/invoices/{id}/items/{itemId}Edit a line
Any of name, description, quantity, unit, unit_cost and catalog_item_id. Once you change a quantity, the line's calc is cleared, because the stored formula no longer explains the number.
You cannot move a line to another section or change its position. Delete it and add it where you want it.
/v1/invoices/{id}/items/{itemId}Delete a line
Removes one line. The rest of the section is untouched.
Safe retries
When a request times out you cannot tell whether it landed, and sending it again could create a second invoice. So every create takes an id you choose. Send the same id again and you get the first result back with 200 and nothing new is written. An id already used by something else answers 409 and does not say whose it is.
A retry that arrives while the first attempt is still finishing answers 409 with a message saying the invoice is still being created. Wait a moment and send it again.
Errors
| Status | Type | Description |
|---|---|---|
| 400 | validation_error | A malformed field, an unknown field, a status field, calc, waste_pct or a section margin, a batch of items mixed with single-line fields, an id on some lines but not others, or a date that is not YYYY-MM-DD. |
| 401 | unauthorized | The API key is missing or invalid. |
| 403 | forbidden | The key owner is missing the invoices.view, invoices.create or invoices.edit permission named in the message. |
| 404 | not_found | The invoice, section, line, project, estimate, contact, member or catalog item does not exist in your workspace. One in another workspace answers 404, never 403. |
| 409 | conflict | Not a draft, a payment applied, archived, an id already in use, a section that changed under a delete, or a total that would drop below the amount paid. |
| 500 | internal_error | Something went wrong on our end. Retry safe. |