Docs · API

The HTTP surface.

Switchyard exposes one authenticated JSON API for Git-aware collaboration: identity, repositories, Work, Attempts, Pull Requests, editor drafts, workflows, the Integration Queue, policy, organisations and realtime events.

Conventions first

ConcernContract
Browser authenticationRegistration/login establish an HttpOnly session cookie. Mutating browser requests are authorized as the signed-in Switchyard principal.
Repository identityPublic-facing repository APIs use owner/repo. The backing Cloudflare Artifacts repository name remains an implementation/storage identity.
JSON errorsApplication failures return structured JSON with an error value; concurrency failures use explicit conflict states rather than silent overwrite.
Optimistic concurrencyDrafts use revisions; repository writes use expected Git state. Stale writes are surfaced to the caller.
RealtimeNormalized domain events are available over authenticated Server-Sent Events.

Endpoint map

AreaRepresentative endpointsWhat they are for
Auth & accountPOST /api/auth/register, /login, /logout · GET /api/auth/meApplication identity and browser sessions.
Users & settingsGET /api/users/{username} · PATCH /api/settings/profile · avatar/password/session endpointsProfiles, large avatars, account metadata, password/session management.
Owners & organisationsGET /api/owners/{slug} · /api/orgs… · members, teams, invitations, policies, auditGit-host ownership, organisation profiles and server-enforced membership/access.
RepositoriesGET /api/repositories · /api/repositories/{owner}/{repo} · /tree · /content · /refsCanonical owner/repo browsing. Legacy flat-name /api/repos… routes remain for compatibility.
History & compare/commits · /commits/{sha} · /compareOrdinary Git history, commit detail and ref comparisons.
Repository settingsGET/PATCH …/settings · collaborators · protected refsMetadata, access and integration policy.
WorkGET/POST /api/work · GET/PATCH /api/work/{id} · comments · provenanceHuman-first issues/tasks. Attempts are an optional execution layer beneath Work.
AttemptsPOST /api/work/{id}/attempts · /api/attempts/{id}/run|review|preview|resolveIsolated candidate branches, Agent execution, review and conflict repair.
Pull RequestsGET /api/prs · GET /api/prs/{id} · check/enqueue/integrateReviewable integration proposals and their queue state.
EditorPOST /api/drafts · GET /api/drafts/… · /agent-propose · /commit · POST /api/diffRecoverable drafts, interactive Agent proposals, diffing and explicit commit.
Workflows/api/workflows… · /api/workflow_runs…Create/run workflows; inspect, cancel, approve or retry durable runs.
Queue & attentionGET /api/queue · POST /api/queue/{id}/requeue · GET /api/attention · escalationsCanonical scheduling, blocked work and human decision packets.
EventsPOST /api/events/ingest · GET /api/events · GET /api/events/streamNormalized Git/domain event ingestion and SSE delivery.
Agents & credentialsGET /api/roles · GET/POST /api/credentials · rotate/deleteRole configuration and provider credential lifecycle. Provider secrets never imply repository authority.

Example: browse a repository

# after authenticating in the browser/session
curl -b cookies.txt \
  http://127.0.0.1:8080/api/repositories/switchyard-labs/switchyard/overview

curl -b cookies.txt \
  'http://127.0.0.1:8080/api/repositories/switchyard-labs/switchyard/tree?ref=main'

The overview response is deliberately product-shaped: ownership, visibility, default branch and clone information are resolved there so the UI does not need to reconstruct repository identity from low-level Artifacts records.

Concurrency semantics you should design around

OperationCaller suppliesOn stale state
Draft saveexpected_revision409 draft_stale; newer draft content remains intact.
Draft commitDraft base_sha409 stale_base; the draft remains recoverable and the user reconciles.
Git/ref mutationExpected prior SHANormal non-force Git push rejects stale movement; Switchyard reconciles instead of overwriting.
Integration QueueValidated PR + current canonical stateItem is re-previewed/re-queued or blocked with an explicit reason.

Example: create Work and an Attempt

work=$(curl -s -b cookies.txt \
  -H 'Content-Type: application/json' \
  -d '{"title":"Tighten repository browser errors","kind":"fix"}' \
  http://127.0.0.1:8080/api/work)

# Attempts are optional: ordinary human Work can remain just an issue/task.
# When execution is needed, create an isolated candidate branch underneath it.
API principleThe API exposes familiar Git-host concepts where they are truthful, and Switchyard-specific concepts only where they add genuinely new coordination semantics.