# PUT /apps/:app_id/files

**Resource:** [Apps](./apps.md)  
**MCP tool:** `write_app_files`  
**Scopes:** `apps:write`  
**Write operation:** yes

Write an app's files yourself: send whole files (manifest.json, tables.json, src/main.tsx, views under src/views/) and they go through the same check and build as an Evie change, then become the app's draft (a restore point in its history; nothing goes live until publish_app). Read get_app_kit_reference first for the rules and every block's props. To change an app, read_app_files, send only the files you change with base_version_id; for a new app send every file with replace true. Refused (422) with problems listing every reason when a file breaks a rule or the app does not build, and nothing is saved: fix them all and send again. Answers the new version, changes in plain words, access_notes (data and buttons the app now uses: say them to the person) and tables_added. Use change_app instead when the person describes a change in words and wants Evie to make it. Workspace admins only.

## Parameters

| Name | In | Type | Required | Description |
|------|----|------|----------|-------------|
| `app_id` | path | string | yes | The app's id. |
| `files` | body | object | yes | The files to write, as { "path": "the whole file" }. Paths: manifest.json, tables.json, src/main.tsx, src/sample.ts, and .tsx or .ts files under src/views/, src/components/ or src/lib/. null deletes a file. Each file is sent whole, never a part of one. At most 80 files, 120 KB each. |
| `replace` | body | boolean | no | true: the files sent are the whole app and every other file goes (use it for a new app). Default false: the files sent are laid over the app's current files. |
| `base_version_id` | body | string | no | The version_id read_app_files answered. When the app changed since then the write is refused (409), so nobody's change is lost. Leave it out for a new app. |
| `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/apps/:app_id/files"   -H "Authorization: Bearer YOUR_API_KEY"   -H "Content-Type: application/json"   -d '{"files":"...","replace":"...","base_version_id":"..."}'
```

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