# POST /opportunities/:opportunity_id/progress-invoices/retention-release

**Resource:** [JOB_COSTING](./job-costing.md)  
**MCP tool:** `release_retention`  
**Scopes:** `invoices:write`  
**Write operation:** yes

Bill retention held on a job back to the customer (all of what is still held, or an amount for a release in stages), and create its invoice from an invoice design (template_id, else the workspace default), the same way as a progress invoice. The invoice is a draft unless status is "open".

## Parameters

| Name | In | Type | Required | Description |
|------|----|------|----------|-------------|
| `opportunity_id` | path | string | yes | UUID of the opportunity (the job), from list_opportunities. |
| `amount` | body | number | no | How much retention to release, in the same terms as the quote lines it was held from (the invoice design decides whether GST is inside the amount or added on top). Leave out to release everything still held (retention_outstanding in get_job_costing). Send part of it to release in stages, for example half at completion and half after the defects period. |
| `template_id` | body | string | no | Invoice design: the design the invoice is made from (an invoice design from list_invoice_templates that bills the full amount). It sets the page, the email, the due date and how GST is charged. Leave out for the workspace's default invoice design. |
| `status` | body | string | no | "draft" (default): the invoice is made but not issued, so it can be checked first. "open": issued now, ready to send and pay. |
| `due_date` | body | string | no | Due date on the invoice (YYYY-MM-DD). Used only when the invoice design sets no payment terms of its own. |
| `xero_integration_id` | body | string | no | Xero organisation - the connected Xero organisation this invoice is created in (its id from list_integrations, platform xero). Only needed when the workspace has more than one Xero organisation connected: left out, the invoice design’s Xero organisation is used, then the workspace default (Invoices > Settings), then the only connection; with several connected and none of those, nothing is made and you are asked to choose. |
| `send_to_xero` | body | boolean | no | Xero workspaces: also make the invoice in Xero, where it takes Xero's number and keeps its design and pay page. All or nothing: if Xero refuses it, nothing is made. Defaults to on when Xero is connected and the workspace setting invoices_to_xero (update_crm_settings) is on. false leaves it out of Xero for now; with that setting on it goes into Xero when it is sent. |
| `reference` | body | string | no | Reference on the invoice. Defaults to "Retention release". |
| `note` | body | string | no | A note kept with the release for the team (not printed). |
| `preview` | body | boolean | no | true: return the release (amount, invoice line, the design it will use and its GST) without creating anything. |
| `require_approval` | body | boolean | no | Optional. Set true to route this write into the approval queue for human review instead of executing it immediately (returns 202 + an approval_id). Works even when your key/token has permission to execute directly. |

## Request example

```bash
curl -X POST   "https://api.trustpager.com/functions/v1/api/v1/opportunities/:opportunity_id/progress-invoices/retention-release"   -H "Authorization: Bearer YOUR_API_KEY"   -H "Content-Type: application/json"   -d '{"amount":"...","template_id":"...","status":"..."}'
```

---
Base URL: `https://api.trustpager.com/functions/v1/api/v1` — Auth: `Authorization: Bearer YOUR_API_KEY`