GET /scripts/{script_id}/repo/branches
Repository branches. Authentication: Scope:scripts.read
Path parameters: script_id
Response: { name, head_sha, is_default, created_by, updated_at }[]
cURL
POST /scripts/{script_id}/repo/branches
Creates a branch from a commit (default: main’s head). Authentication: Scope:scripts.write
Path parameters: script_id
Body: { name, from? }
Response: { name, head_sha }
cURL
GET /scripts/{script_id}/repo/tree
File list for a ref. Authentication: Scope:scripts.read
Path parameters: script_id
URL parameters: ref? (branch or sha)
Response: { ref, sha, files: { path, hash, size }[] }
cURL
GET /scripts/{script_id}/repo/files/{path*}
File contents. ?raw=1 returns plain text. Authentication: Scope:scripts.read
Path parameters: script_id, path*
URL parameters: ref?, raw?
Response: { ref, sha, path, hash, content }
cURL
GET /scripts/{script_id}/repo/commits
History (first parent), optionally filtered by file. Authentication: Scope:scripts.read
Path parameters: script_id
URL parameters: ref?, path?, limit? (1-100, default 30)
Response: Commit[]
cURL
GET /scripts/{script_id}/repo/commits/{sha}
A commit with the list of changed files. Authentication: Scope:scripts.read
Path parameters: script_id, sha
Response: Commit & { files: { path, status }[] }
cURL
POST /scripts/{script_id}/repo/commits
Writes files in a commit. content:null deletes. expected_head prevents overwriting others’ work (409 HEAD_MOVED). On the default branch, publishes the backend; changing supabase/ requires functions.deploy. Authentication: Scope:scripts.write
Use
expected_head with the head_sha read from GET /repo/branches. If the branch has changed in the meantime, the server responds with 409 HEAD_MOVED and nothing is written. On the main branch, changing supabase/ also requires functions.deploy, and the backend is published immediately (the summary is in deploy). Limit: 30 commits per minute per person and script; up to 100 files per commit.script_id
Body: { branch?, expected_head, message, description?, changes: { path, content|null }[] }
Response: { commit, branch, deploy? }
cURL

