Skip to main content
POST
Edit a file
Replaces oldText with newText in a file.
files/edit replaces oldText where it occurs exactly once. If it matches zero or more than one place, the call returns BAD_REQUEST — include more surrounding context so the match is unique. Use Write a file for new files or full rewrites.

Authorizations

Authorization
string
header
required

Enter your Zite API key. Format: Bearer <api_key>

Path Parameters

sessionId
string
required

The build session ID from Open a session.

Body

application/json
path
string
required

Path relative to the workspace root.

Example:

"apps/agent-console/src/api/listTickets.ts"

oldText
string
required

Text to replace. Must match exactly once in the file.

newText
string
required

Replacement text.

Response

The edited file

path
string
replaced
boolean