update_file
Overwrite an existing file in a Bridge Town project and commit the change. The path is project-relative (e.g. ‘README.md’, ‘model/revenue.py’, ‘data/seed.csv’, ‘assets/logo.png’). This tool is strict update-only: if the file does not exist it returns a not-found error instructing you to use create_file instead. Specify branch to commit to a non-default branch (e.g.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
project_name | Annotated[str, Field(description='Name of the Bridge Town project.')] | Yes | — | |
path | Annotated[str, Field(description='Project-relative path of the existing file to overwrite.')] | Yes | — | |
content | Annotated[str, Field(description="New file content as a UTF-8 string (when encoding='text') or base64-encoded bytes (when encoding='base64').")] | Yes | — | |
encoding | Annotated[Literal['text', 'base64'], Field(description="Encoding of the content field: 'text' for UTF-8 source (default); 'base64' for binary files. 'auto' is not allowed on writes.")] | No | 'text' | |
commit_message | Annotated[str, Field(description='Git commit message. If omitted, the server generates a default message.')] | No | '' | |
branch | `Annotated[str | None, Field(description=“Branch to operate on. Defaults to the project’s default branch when omitted or null.”)]` | No | None |
expected_sha | Annotated[str, Field(description='Expected blob SHA-1 (40 hex chars) for optimistic concurrency control. If the file has been modified since you last read it, the call fails with a conflict error. Read the file first to get its current sha.')] | No | '' |
Returns
Section titled “Returns”Returns a structured object. Top-level fields:
path(string)project(string)commit_sha(string)
See the response example below for the full payload shape.
Example
Section titled “Example”Tool Call
Section titled “Tool Call”{ "name": "update_file", "arguments": { "project_name": "forecasts", "path": "model/revenue.py", "content": "def run(inputs):\n return {\"revenue\": 1000}\n", "commit_message": "refactor: simplify revenue model", "expected_sha": "0123456789abcdef0123456789abcdef01234567" }}Response
Section titled “Response”{ "path": "model/revenue.py", "project": "forecasts", "commit_sha": "abc1234def5678901234567890abcdef12345678"}- Module:
Models - Requires authentication via API token or Auth0 JWT.