PATCH /api/fragments/:fragmentId
Update one or more files in a code fragment. ForgeAI writes each file to the E2B sandbox, merges the new contents with the existingfiles map, and persists the result to the database.
Path parameters
The ID of the CodeFragment to update. Minimum 3 characters.
Request body
A map of relative file paths to their new contents. Keys are paths relative to the project root (e.g.
"app/page.tsx"), values are the full file content strings.The ID of the project that owns this fragment. Minimum 3 characters.
Fallback E2B sandbox ID to use if the fragment does not have a
sandboxId stored in the database. Not required when the fragment already has a sandboxId.Behavior
- Looks up the existing fragment by
fragmentId. - Resolves the sandbox: uses the fragment’s stored
sandboxId, falling back tobody.sandboxId. - Writes each file in
body.filesto the E2B sandbox at the resolved project path. - Merges
body.filesinto the fragment’s existingfilesmap (new keys are added, existing keys are overwritten). - Persists the merged
filesmap to the database. - Returns the updated CodeFragment.
Response
Returns the updated CodeFragment object.Unique fragment identifier (UUID).
ID of the parent message.
Public URL of the live E2B sandbox.
E2B sandbox identifier.
Human-readable title for the fragment.
The complete, merged map of relative file paths to file contents after the update.
Screenshot of the sandbox, or
null.Structured design specification, or
null.ISO 8601 creation timestamp.
ISO 8601 last-updated timestamp.