Skip to content

create_file

Create a new file in a Bridge Town project and commit it. The path is project-relative (e.g. ‘README.md’, ‘model/revenue.py’, ‘data/seed.csv’, ‘assets/logo.png’). Specify branch to commit to a non-default branch (e.g. a scenario branch). Omitting branch, passing an empty string, or passing null all resolve to the project’s default branch. Passing the branch name explicitly is equivalent. encoding must be ‘text’ for UTF-8 source files or ‘base64’ for binary files; encoding=‘auto’ is not allowed on writes. If commit_message is omitted the server generates a default of the form ‘feat: add {filename} (Bridge Town)’. Supply a descriptive commit_message for clearer project history. Requires at least Editor access to the project. Returns: path (str) — committed file path; project (str) — project name; commit_sha (str) — git commit SHA of the change.

NameTypeRequiredDefaultDescription
project_namestrYes
pathstrYes
contentstrYes
encodingstrNo'text'
commit_messagestrNo''
branch`strNone`NoNone

Returns a structured object. Top-level fields:

  • path (string)
  • project (string)
  • commit_sha (string)

See the response example below for the full payload shape.

{
"name": "create_file",
"arguments": {
"project_name": "forecasts",
"path": "model/revenue.py",
"content": "import pandas as pd\n\ndef run(inputs):\n df = pd.DataFrame({\"month\": [1, 2, 3], \"revenue\": [100, 110, 121]})\n return {\"revenue\": df.to_dict(orient=\"records\")}\n",
"commit_message": "feat: add revenue model"
}
}
{
"path": "model/revenue.py",
"project": "forecasts",
"commit_sha": "abc1234def5678901234567890abcdef12345678"
}
  • Module: Models
  • Requires authentication via API token or Auth0 JWT.