# POST /automations/:automation_id/actions/:action_id/custom-script/generate

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

Generate (or regenerate) a Custom Script action's code from a plain-English description.

## Parameters

| Name | In | Type | Required | Description |
|------|----|------|----------|-------------|
| `automation_id` | path | string | yes |  |
| `action_id` | path | string | yes |  |
| `description` | 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 POST   "https://api.trustpager.com/functions/v1/api/v1/automations/:automation_id/actions/:action_id/custom-script/generate"   -H "Authorization: Bearer YOUR_API_KEY"   -H "Content-Type: application/json"   -d '{"description":"..."}'
```

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