# PUT /custom-scripts/:script_id/tp-key

**Resource:** [Custom Scripts](./custom-scripts.md)  
**MCP tool:** `attach_custom_script_tp_key`  
**Scopes:** `custom-scripts:write`  
**Write operation:** yes

Attach a TrustPager API key (tp_live_…) to a Custom Script so its code can call the TrustPager API via tp.*. The key's own scopes decide what the script may do - mint it in Settings → API with exactly the scopes needed. Write-only; the value is never returned. Redeploy (Test) the script to apply.

## Parameters

| Name | In | Type | Required | Description |
|------|----|------|----------|-------------|
| `script_id` | path | string | yes |  |
| `api_key` | body | string | yes |  |
| `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 PUT   "https://api.trustpager.com/functions/v1/api/v1/custom-scripts/:script_id/tp-key"   -H "Authorization: Bearer YOUR_API_KEY"   -H "Content-Type: application/json"   -d '{"api_key":"..."}'
```

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