# INVOICE_TEMPLATES

invoice-templates endpoints.

**Base URL:** `https://api.trustpager.com/functions/v1/api/v1`

## Endpoints

### POST /invoice-templates

Create a designed invoice page. Pass name, optionally a description, a starting_design (the builder's own starting layouts, default clean) and a partial config to switch sections on or off, set their text, order the cards, place the payment card and set brand colours. The page is saved exactly as the Invoice Builder would save it. Then use set_invoice_page, or template_id on create_invoice or send_invoice, to put it on an invoice.

**Scopes:** `invoices:write` — [full detail](./invoice-templates/post-invoice-templates.md)

### DELETE /invoice-templates/:template_id

Delete a designed invoice page. Invoices that use it keep working and go back to the standard invoice page (the count is returned as invoices_back_on_standard_page). Destructive.

**Scopes:** `invoices:delete` — [full detail](./invoice-templates/delete-invoice-templates-template-id.md)

### GET /invoice-templates/:template_id

Fetch one designed invoice page: its full config plus a plain-word guide (guide) to every section (name, what it is for, on or off, whether it is locked on) and each field in it (key, label, current text), the order of the cards, the payment card and the brand. Read this before update_invoice_template so you know every section and field key you can set.

**Scopes:** `invoices:read` — [full detail](./invoice-templates/get-invoice-templates-template-id.md)

### GET /invoice-templates

List the designed invoice pages built in the Invoice Builder (the Designs tab under Invoices): id, name, description, updated_at and how many invoices use each (invoices_using). Use get_invoice_template to see what a design holds.

**Scopes:** `invoices:read` — [full detail](./invoice-templates/get-invoice-templates.md)

### POST /invoice-templates/setup-default

Set up the workspace's own invoice: the design every invoice uses unless another is picked (Settings > Invoices > Default design), the same as the "Set up your new invoice" button in the app. If a default design is already set it is kept; if the workspace has designs but no default, its first design becomes the default; otherwise a new design called "Invoice" is made from the "Clean invoice" starting design, in the workspace's brand, and becomes the default. Safe to call again. Returns template_id, how (kept, existing or created) and builder_url, the Invoice Builder page where the owner edits it. Invoices made without a design picked (automations, the API, recurring invoices, repeat visits) use it from then on.

**Scopes:** `invoices:write` — [full detail](./invoice-templates/post-invoice-templates-setup-default.md)

### PATCH /invoice-templates/:template_id

Edit a designed invoice page. Pass only what you want to change: name, description, and/or a partial config (switch sections on or off, set section text by field key, reorder cards, move the payment card between side and bottom, set brand colours as hex). Everything not mentioned keeps its setting. The Headline and "Your invoice" sections are always on. An unknown section or field key is rejected with the list of valid keys; call get_invoice_template to see them. Invoices already using the design change with it. A Deposit + Balance design (billing.portion "deposit") has a second stage, the final balance invoice: send stage "balance" with sections, proposal or email to edit it, or reset_final_balance true to put it back to its defaults.

**Scopes:** `invoices:write` — [full detail](./invoice-templates/patch-invoice-templates-template-id.md)
