curl -X POST "https://app.runtm.com/api/v0/sessions/86e11104-.../git" \
-H "Authorization: Bearer runtm_xxx" \
-H "Content-Type: application/json" \
-d '{
"operation": "create_branch_and_pr",
"working_dir": "/home/user/project",
"pr_title": "Add /health endpoint",
"pr_body": "Adds a simple health check endpoint that returns 200."
}'
import requests
response = requests.post(
"https://app.runtm.com/api/v0/sessions/86e11104-.../git",
headers={"Authorization": "Bearer runtm_xxx"},
json={
"operation": "create_branch_and_pr",
"working_dir": "/home/user/project",
"pr_title": "Add /health endpoint",
"pr_body": "Adds a simple health check endpoint.",
},
)
result = response.json()
if result["success"]:
print(f"PR opened: {result['pr_url']}")
else:
print(f"Failed: {result['error']}")
{
"success": true,
"operation": "create_branch_and_pr",
"output": "Created branch agent/86e11104 and pushed",
"current_branch": "agent/86e11104",
"default_branch": "main",
"repo_full_name": "acme/billing",
"repo_url": "https://github.com/acme/billing",
"created_branch": "agent/86e11104",
"pr_url": "https://github.com/acme/billing/pull/42",
"pr_number": 42
}
Git Operation (v0)
Run a git operation inside the sandbox (commit, push, create PR, etc.)
POST
/
api
/
v0
/
sessions
/
{session_id}
/
git
curl -X POST "https://app.runtm.com/api/v0/sessions/86e11104-.../git" \
-H "Authorization: Bearer runtm_xxx" \
-H "Content-Type: application/json" \
-d '{
"operation": "create_branch_and_pr",
"working_dir": "/home/user/project",
"pr_title": "Add /health endpoint",
"pr_body": "Adds a simple health check endpoint that returns 200."
}'
import requests
response = requests.post(
"https://app.runtm.com/api/v0/sessions/86e11104-.../git",
headers={"Authorization": "Bearer runtm_xxx"},
json={
"operation": "create_branch_and_pr",
"working_dir": "/home/user/project",
"pr_title": "Add /health endpoint",
"pr_body": "Adds a simple health check endpoint.",
},
)
result = response.json()
if result["success"]:
print(f"PR opened: {result['pr_url']}")
else:
print(f"Failed: {result['error']}")
{
"success": true,
"operation": "create_branch_and_pr",
"output": "Created branch agent/86e11104 and pushed",
"current_branch": "agent/86e11104",
"default_branch": "main",
"repo_full_name": "acme/billing",
"repo_url": "https://github.com/acme/billing",
"created_branch": "agent/86e11104",
"pr_url": "https://github.com/acme/billing/pull/42",
"pr_number": 42
}
Executes a git operation inside the sandbox’s workspace - typically used by background agents to push their work and open a pull request after completing a task.
The session must be in
Status-specific fields populated when relevant:
running state.
Required scope: sessions:write
Path Parameters
string
required
The session ID.
Headers
string
required
Bearer token. Example:
Bearer runtm_xxxBody
string
required
One of:
status, commit, push, pull, sync, create_branch, switch_branch, list_branches, create_pr, create_branch_and_pr, init_repo.string
default:"/home/user"
Directory containing the git repository inside the sandbox.
string
Commit message - required when
operation is commit.string
Branch name - for
create_branch / switch_branch.string
Search filter for
list_branches.string
Pull request title - required for
create_pr and create_branch_and_pr.string
Pull request body.
string
Base branch for the PR. Defaults to the repository’s default branch.
string
Session ID to derive the branch name from when using
create_branch_and_pr.Response
boolean
Whether the operation succeeded.
string
The operation that was attempted.
string | null
Stdout/stderr from git.
string | null
Error message if
success is false.boolean
For
status: whether working_dir is a git repo.string
Current branch name.
string
Repo’s default branch.
boolean
Whether there are uncommitted changes.
integer
Commits ahead of upstream.
integer
Commits behind upstream.
string
GitHub
owner/repo (after init_repo or when remote is set).string
HTTPS URL of the GitHub repo.
string
URL of the created PR (after
create_pr / create_branch_and_pr).integer
PR number.
string
Branch that was created (for
create_branch_and_pr).array
List of branch names (for
list_branches).curl -X POST "https://app.runtm.com/api/v0/sessions/86e11104-.../git" \
-H "Authorization: Bearer runtm_xxx" \
-H "Content-Type: application/json" \
-d '{
"operation": "create_branch_and_pr",
"working_dir": "/home/user/project",
"pr_title": "Add /health endpoint",
"pr_body": "Adds a simple health check endpoint that returns 200."
}'
import requests
response = requests.post(
"https://app.runtm.com/api/v0/sessions/86e11104-.../git",
headers={"Authorization": "Bearer runtm_xxx"},
json={
"operation": "create_branch_and_pr",
"working_dir": "/home/user/project",
"pr_title": "Add /health endpoint",
"pr_body": "Adds a simple health check endpoint.",
},
)
result = response.json()
if result["success"]:
print(f"PR opened: {result['pr_url']}")
else:
print(f"Failed: {result['error']}")
{
"success": true,
"operation": "create_branch_and_pr",
"output": "Created branch agent/86e11104 and pushed",
"current_branch": "agent/86e11104",
"default_branch": "main",
"repo_full_name": "acme/billing",
"repo_url": "https://github.com/acme/billing",
"created_branch": "agent/86e11104",
"pr_url": "https://github.com/acme/billing/pull/42",
"pr_number": 42
}