Skip to main content
Client App BuilderVersion: v3

Write, patch or delete one file in the app's sandbox.

POST/ai-builder-api/cli/projects/{projectId}/sandbox/edit

Writes, patches or deletes one file in the app's sandbox. A small change to a text file is a patch: exact replacements, without resending the file. After a set of edits, save them with POST .../sandbox/checkpoint, then start a run with externalAgent: true to check, build and deploy them. A React Native app (react_native_app_kernel_v1) writes only under apps/mobile/app-extensions/ and apps/mobile/application-assets/; its routes.ts is generated, so register its screens with POST .../sandbox/extension-routes instead of writing that file.

Authorizations

Authorizationstringheaderrequired

Bearer authentication header of the form Bearer <token>, where <token> is your access token.

Scope:clientportal-ai.write
Auth methods:OAuthPrivate Integration
Token type:Sub-Account Token

Request​

Headers

Versionstringrequired

The API version.

Available optionsv3
Example:v3

Path Parameters

projectIdstringrequired

Project identifier.

Possible values: Value must match regular expression ^prj_[A-Za-z0-9_-]+$

Example:prj_01HXQ8Z6J9K2

Body

pathstringrequired

File to write or delete, relative to the workspace root.

Example:apps/clientportal-custom-app/pages/welcome.vue
actionstring

update writes content (the default); delete removes the file; patch applies edits to a text file that exists, so a small change does not resend the file.

Available optionsupdatedeletepatch
Example:update
contentstring

The file's full new content, encoded as encoding says. Not sent with patch.

Example:<template><h1>Welcome</h1></template>
encodingstring

How content is encoded; utf-8 by default.

Available optionsutf-8base64
Example:utf-8
editsobject[]

patch only: replacements applied in order, each to the text the one before it produced. Each oldText must occur exactly once in the file, or nothing is written (422 patch_text_not_found / patch_text_ambiguous): include enough surrounding text to make it unique.

Possible values: >= 1, <= 50

Response

File written in the dev sandbox.

okbooleanrequired

The file was written or deleted.

Available optionstrue
Example:true
pathstringrequired

The file, relative to the workspace root.

Example:apps/clientportal-custom-app/pages/welcome.vue