REST API
A small job API. The CLI is a client for it; anything that speaks HTTP can drive anybranch the same way.
Every request carries Authorization: Bearer $ANYBRANCH_TOKEN. The API is a command executor: you submit a CLI command as a JSON array, poll the job, and read its output.
Endpoints
| Method & path | Purpose |
|---|---|
GET /v1/health | Liveness; returns { "version": "…" }. |
POST /v1/commands | Submit a command (JSON array of args). Returns 202 { "id", "state":"queued" }. |
GET /v1/jobs/{id} | Poll a job: { state, exit_code, stdout, stderr }. |
Example
# submit `list --format json`
$ curl -sX POST $ANYBRANCH_SERVER/v1/commands \
-H "Authorization: Bearer $ANYBRANCH_TOKEN" -H 'Content-Type: application/json' \
-d '["list","--format","json"]'
{ "id": "job_…", "state": "queued" }
$ curl -s $ANYBRANCH_SERVER/v1/jobs/job_… -H "Authorization: Bearer $ANYBRANCH_TOKEN"Allowed commands over the API are the branch and source lifecycle: preflight, clone, sync, import, create, info, url, switch, list, status, repair, reconcile, reset, settings, lock, unlock, start, stop, rm.
Why one endpoint, not dozens: a multi-tenant managed service needs many resource routes (projects, connectors, branches, operations, api-keys, orgs). anybranch is a single self-hosted server with no tenancy, so it exposes one generic job endpoint instead — every capability, without the multi-tenant surface.