# POST /gifts/:gift_id/script/generate

**Resource:** [GIFTS](./gifts.md)  
**MCP tool:** `generate_gift_script`  
**Scopes:** `gifts:write`, `automations:write`  
**Write operation:** yes

Write (or rewrite) the Custom Script that makes a gift, from a plain-English description of the gift. The script gets the person (reader: first_name, business_name, industry, city, state, postcode, website, why_now), their answers to the gift's questions (answers) and the quiz score when there is one (quiz), and returns { title, text, html, url, image_url }. New code needs approval (approve_gift_script) before it makes real gifts; try it first with test_gift_script.

## Parameters

| Name | In | Type | Required | Description |
|------|----|------|----------|-------------|
| `gift_id` | path | string | yes | The gift whose script makes it (list_gifts). |
| `description` | body | string | yes | Plain-English description of what the script should do. |
| `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/gifts/:gift_id/script/generate"   -H "Authorization: Bearer YOUR_API_KEY"   -H "Content-Type: application/json"   -d '{"description":"...","require_approval":"..."}'
```

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