Sync files to a draft
sync_filesEdits an app's draft: writes files into a temporary running copy of the app and returns dev_url, WITHOUT a commit or a build. Use it on managed apps with draft runtimes: static, vite, react, vue, svelte, sveltekit, remix, nextjs, astro, nuxt, angular, gatsby, fastapi, flask, django, node, and configured sanic presets. Go, rust and spring-boot require the server rollout flag; dockerfile has no draft runtime. Start can return starting: retry sync_files to check readiness. Startup notes arrive once in note, even after a slow start. data chooses copy (default) or empty on a new draft; a running draft keeps its choice. Where enabled and available, Copy seeds the database and app files at start and reads the bucket live; Empty starts without that data. Writes stay in the draft. The reply reports modes, timestamps and unavailable-copy notes. A change in the draft is not live and not saved: tell the user so, and give dev_url as a preview. New drafts inherit default_public, including drafts with data; the owner can switch public/private on the draft row. Google-login apps stay behind their login and cannot be made public. get_app_status reports the draft public flag. dev_url is private unless the draft is public; do not suggest sharing it unless the owner made it public (plus expires_at and notice when the app is a temporary 72h project). When the user is happy with the result, publish_draft makes everything the draft holds live in ONE commit (deploy_files once with the final files does the same); a commit per small edit fills the timeline and is slow. The result gives unsaved_files, the number of files that exist only in the draft, and next_step. A draft is temporary: it stops after 30 minutes without a sync, and the platform can stop it earlier. When it stops by itself, the files it received are kept for 24 hours; the next sync_files starts a new draft, brings them back and says so in note, so do not resend everything. The owner can stop a draft from the dashboard, which discards its unsaved files; note then says so. The draft does not change deploy_url or canonical_host, and it keeps running after a publish. Each file accepts an optional sha256 (hex) to verify against; on any mismatch the whole call fails before anything is applied, naming the offending file(s), and the response echoes each file's actual sha256 in files[]. Requires a read-write token.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"project_id": "<project_id>"
},
"name": "sync_files"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | No | used only when starting a draft: copy (default) copies managed Postgres and app files at storage_mount_path once at startup (files up to 500 MiB and 50000 entries), and reads the live bucket with separate draft uploads and deletes; empty starts with an empty database, bucket and app-files directory. Omit to inherit the stopped draft's choice on restore. Neither changes production; draft data never publishes | |
| files | No | files to create or overwrite in the draft (path + full content) | |
| project_id | Yes | the managed project id (from list_projects) | |
| delete_paths | No | paths to remove from the draft |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| note | No | ||
| error | No | startup failure, including the dependency install log tail when npm or pip fails | |
| files | No | ||
| state | Yes | ||
| notice | No | ||
| synced | Yes | ||
| deleted | Yes | ||
| dev_url | Yes | ||
| database | No | resolved managed draft database: copy, empty, or none; absent while the first seed is pending | |
| dev_error | No | compiler diagnostics, missing build manifest, app crash log tail, dependency install failure, or draft database is full (read-only); follow next_step and check this field is gone before claiming the preview is right | |
| next_step | No | what makes the draft's changes live, or what to do when the dev server is down | |
| restarted | Yes | ||
| data_as_of | No | start of the production database snapshot (RFC 3339, UTC); only present for a copied database | |
| dev_server | No | presets with a dev server: running, starting, restarting, building, build failed (possibly serving the previous build), install_failed, or 'not running: <reason>' | |
| expires_at | No | ||
| files_mode | No | resolved app-files mode: none, copy, or empty | |
| files_note | No | app-files copy result, limits, or empty fallback | |
| base_commit | No | set only when the owner started this draft from an older commit: its full sha. The draft's files come from that commit, not from the newest code | |
| files_as_of | No | UTC time the production app-files copy began; absent for none or empty | |
| unsaved_files | Yes | how many files (changed or deleted) exist only in the draft: they are not live and not saved as a commit | |
| dev_config_error | No | log lines when edited dev-server config or Python/Node source failed to load. The watcher can remain running while the app is down or serving old code; fix the file before saying the preview works |