Skip to main content

API reference

4RGE is served by several backend services. The two that expose application APIs are the agents API (agent runs and automations) and the platform / control-plane API (desktop, mobile, model control, prompt control, and provisioning).

Base URLs

ServiceProductionLocal dev
Agents APIhttps://agents-api.4rged.aihttp://localhost:3008
Platform APIhttps://api.4rged.aihttp://localhost:3007

Authentication

API requests are authenticated with your 4RGE session (the same Supabase-backed auth used by the apps) and are scoped to an organization. Pass the session access token as a Bearer token:

curl "https://agents-api.4rged.ai/api/health" \
  -H "Authorization: Bearer <session-access-token>"

Requests resolve the caller's effective access and the target organization before doing any work — there is no separate unauthenticated or global token surface for application APIs.

RequirementDetail
HeaderAuthorization: Bearer <access_token>
Org scopeorganizationId query param or body field on most routes
Role checksSome routes require agent manager or platform operator roles
Not a public REST API

These are platform service APIs used by 4RGE apps. Request and response shapes can evolve without a versioned public contract. Integrate via the desktop app, CLI, or documented operator flows unless you have an explicit partnership agreement.

Agents API

Handles agent runs, automations, GitHub integration, and operational summaries.

Agent runs

MethodRoutePurpose
GET/api/agent-runsList runs for an organization
POST/api/agent-runsCreate a new cloud agent run
GET/api/agent-runs/{runId}Fetch run details and title
POST/api/agent-runs/{runId}/startStart or resume a run
GET/api/agent-runs/{runId}/streamStream run events (SSE)
GET/api/agent-runs/{runId}/eventsList run events
POST/api/agent-runs/{runId}/cancelCancel an in-flight run
GET/api/agent-runs/{runId}/messagesFetch conversation messages

Create a run

curl -X POST "https://agents-api.4rged.ai/api/agent-runs" \
  -H "Authorization: Bearer <session-access-token>" \
  -H "Content-Type: application/json" \
  -d '{
    "organizationId": "org_abc123",
    "repositoryId": "42",
    "prompt": "Add unit tests for the auth middleware",
    "agentKind": "cloud",
    "source": "cloud_ui"
  }'

Success returns 201 with the run record, job enqueue info, and usage reservation. A 402 response indicates the run was denied by budget or contract policy.

Run sources and denial responses

The source field on create accepts cloud_ui, github_app, bitbucket_app, or api — the agents-api handler defaults UI creates to cloud_ui. Budget or contract blocks return HTTP 402 with a usageReservation object from reserveAgentRunUsage before any job is enqueued; fix org budget policy or ask an operator to adjust contract capacity rather than retrying identical requests.

Fetch a run

curl "https://agents-api.4rged.ai/api/agent-runs/run_xyz?organizationId=org_abc123" \
  -H "Authorization: Bearer <session-access-token>"

Git operations

MethodRoutePurpose
GET/api/agent-runs/{runId}/git/diffWorking tree diff
GET/api/agent-runs/{runId}/git/commitsCommits on the run branch
POST/api/agent-runs/{runId}/git/reviewSubmit a review action
POST/api/agent-runs/{runId}/github/pull-requestOpen a pull request
curl "https://agents-api.4rged.ai/api/agent-runs/run_xyz/git/diff?organizationId=org_abc123" \
  -H "Authorization: Bearer <session-access-token>"

Terminal and desktop

MethodRoutePurpose
GET/POST/api/agent-runs/{runId}/terminalTerminal session management
POST/api/agent-runs/{runId}/terminal/execExecute a command in the sandbox
GET/api/agent-runs/{runId}/desktopDesktop session state
POST/api/agent-runs/{runId}/desktop/controlControl desktop capture

Automations

MethodRoutePurpose
GET/api/automationsList automations
POST/api/automationsCreate an automation

See Automations for trigger payload examples.

GitHub integration

MethodRoutePurpose
GET/api/github/app/statusInstallation health
GET/api/github/app/installBegin app install flow
GET/api/github/repositoriesList connected repos
GET/api/github/repositories/{id}/branchesList branches
POST/api/github/webhookGitHub webhook receiver (signed)

Operations

MethodRoutePurpose
GET/api/operations/summary24-hour org operations summary
GET/api/healthService health check

Run-related endpoints enforce usage reservations against your budget and contract.

Platform / control-plane API

Backs the desktop and mobile surfaces and admin/provisioning flows.

Desktop and runtime

Route groupPurpose
/api/desktop/effective-policyEffective org policy for desktop
/api/desktop/modelsAvailable models for desktop
/api/desktop/sessionsDesktop session management
/api/desktop/usage-eventsUsage event ingestion
/api/runtime/desktop-auth/startBegin desktop device auth
/api/runtime/desktop-auth/completeComplete desktop device auth
/api/runtime/cli-auth/startBegin CLI device auth
/api/runtime/inference/streamStreaming inference

Fetch effective policy

curl "https://api.4rged.ai/api/desktop/effective-policy?organizationId=org_abc123" \
  -H "Authorization: Bearer <session-access-token>"

Mobile

Route groupPurpose
/api/mobile/homeMobile home surface data
/api/mobile/agent-runsList agent runs for mobile
/api/mobile/agent-runs/{runId}Single run for mobile
/api/mobile/agent-setupAgent setup configuration

Model and prompt control

Route groupPurpose
/api/model-control/policiesModel policy definitions
/api/model-control/versionsModel version snapshots
/api/model-control/publishPublish model catalog
/api/prompt-control/versionsPrompt version snapshots
/api/prompt-control/publishPublish prompt bundle

Provisioning (platform operators)

Route groupPurpose
/api/provisioning/customersCustomer records
/api/provisioning/contractsContract directory and capacity updates
/api/provisioning/organizations/{id}Organization detail
/api/provisioning/auditPlatform audit log
/api/provisioning/support-sessionsTime-bound support access
curl "https://api.4rged.ai/api/provisioning/contracts" \
  -H "Authorization: Bearer <platform-operator-session>"

Organization admin

Route groupPurpose
/api/org/peopleOrg member management
/api/org/teamsTeam management
/api/org/budgetsBudget policies
/api/org/projectsProject management

Health

MethodRoutePurpose
GET/api/healthService health check
GET/api/systems/health/summaryPlatform systems summary