# POST /time-entries/invoice

**Resource:** [TIME_ENTRIES](./time-entries.md)  
**MCP tool:** `invoice_time_entries`  
**Scopes:** `time-entries:write`, `invoices:write`  
**Write operation:** yes

Make ONE draft invoice from an opportunity's time that is finished, billable and not invoiced yet, then mark that time as invoiced so it is never billed twice. Lines: group_by "person" (default) gives one line per person per labour product, "Labour: <name>" with the dates covered and the hours; "entry" gives one line per entry with its note and date. The price per hour is hourly_rate when sent, otherwise the price of the labour product on each entry; if any time has no price the whole call is refused and names the people whose time needs one. Narrow it with date_to (up to and including that workspace day) or user_id (one person). GST follows the workspace settings and the invoice goes to the opportunity's contact and company. The invoice is a draft: nothing is emailed and nothing is sent to your accounting platform; review it, then send it with send_invoice. When there is no time to bill it returns invoice: null with a message. Running timers are left alone: stop them first.

## Parameters

| Name | In | Type | Required | Description |
|------|----|------|----------|-------------|
| `opportunity_id` | body | string | yes | UUID of the opportunity whose time is being invoiced. The invoice goes to that opportunity's contact and company. |
| `date_to` | body | string | no | YYYY-MM-DD. Only bill time that started on or before this day, in the workspace's own time zone. Leave out to bill everything not invoiced yet. |
| `user_id` | body | string | no | Only bill this person's time: a user UUID, or the word "me" for the caller. |
| `hourly_rate` | body | number | no | One hourly rate for every line, before GST. Leave out to use the price of the labour product on each entry. |
| `group_by` | body | string | no | "person" (default): one line per person per labour product, with the dates covered. "entry": one line per entry, with its note and date. |
| `reference` | body | string | no | Reference shown on the invoice, for example a purchase order number. |
| `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/time-entries/invoice"   -H "Authorization: Bearer YOUR_API_KEY"   -H "Content-Type: application/json"   -d '{"opportunity_id":"...","date_to":"...","user_id":"..."}'
```

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