# POST /chat-widgets/:widget_id/sessions/:session_id/links

**Resource:** [CHAT_WIDGETS](./chat-widgets.md)  
**MCP tool:** `link_chat_widget_session`  
**Scopes:** `chat-widgets:write`  
**Write operation:** yes

Link a live chat to a CRM contact and an opportunity, change them, or unlink them (null). A field you leave out stays as it is. Works on chats that have ended. Nothing is shown to the visitor. A Client Portal chat keeps the client of its portal as the contact; it can still be linked to an opportunity.

## Parameters

| Name | In | Type | Required | Description |
|------|----|------|----------|-------------|
| `widget_id` | path | string | yes | The chat widget id. |
| `session_id` | path | string | yes | The chat id. |
| `contact_id` | body | string | no | Contact - the CRM contact this chat is with. Matches the "Contact" section of the side panel in Inbox > Chat. Send a contact id to link or change it, or null to unlink. A Client Portal chat (portal_id set) always belongs to the client of its portal, so its contact cannot be changed. |
| `opportunity_id` | body | string | no | Opportunity - the opportunity this chat belongs to. Matches the "Opportunity" row of the side panel in Inbox > Chat. Send an opportunity id to link or change it, or null to unlink. |
| `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/chat-widgets/:widget_id/sessions/:session_id/links"   -H "Authorization: Bearer YOUR_API_KEY"   -H "Content-Type: application/json"   -d '{"contact_id":"...","opportunity_id":"...","require_approval":"..."}'
```

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