REST API
Orchestrator Routes That Power The CLI And Portal
Jungle Grid exposes a small set of orchestrator-backed REST surfaces for auth, jobs, nodes, account linking, billing, and provider operations.
API shape
- •Authentication for app flows uses browser/session routes under /auth and Bearer-protected resource routes under /v1.
- •Job submission and estimation are server-authoritative and return abstract workload-facing data rather than placement internals.
- •Per-job routing overrides are additive and optional; they constrain placement without requiring exact GPU selection.
- •Billing now exposes USD-only topups, balance/history routes, and the Paystack webhook route.
01
Auth and device flow
CLI authentication uses the device flow. The CLI registers a device code, the browser completes login as the currently signed-in account, and the CLI polls for the resulting token. Registration triggers an email OTP for address verification before the account is active.
- •Device completion is tied to the authenticated browser session, not arbitrary email entry.
- •Registration sends a 6-digit OTP to the registered email address (10-minute TTL).
- •POST /auth/otp/verify marks the account email-verified and triggers the welcome email.
- •POST /auth/otp/resend generates a fresh code if the original expired.
02
API keys are not CLI sessions
Bearer auth exists in two client-side forms. Browser and CLI flows use account JWT sessions. Direct REST and MCP automation can use scoped API keys with the jg_ prefix. Do not expect the jungle CLI to read JUNGLE_GRID_API_KEY; it does not.
- •Use Authorization: Bearer jg_... only when you are calling REST directly or running the MCP server.
- •Use ~/.jungle-grid/credentials.json when you are running jungle submit from the CLI.
- •A jobs:write key can submit and cancel jobs but cannot list jobs unless it also has jobs:read.
- •An unknown, revoked, expired, or IP-disallowed API key returns 401 or 403 before the route handler runs.
03
Integration guides
Use these examples when Jungle Grid is called from your own backend service. Keep JUNGLE_GRID_API_KEY on the server, forward only the fields your app allows, and return the orchestrator response to your client or worker.
- •Do not put JUNGLE_GRID_API_KEY in browser code, mobile apps, static sites, or public repositories.
- •Validate your own request body before forwarding it so users cannot submit arbitrary images or commands through your backend.
- •Use POST /v1/jobs/estimate before POST /v1/jobs when the user needs a cost or capacity preview.
- •Callback URLs must use HTTPS unless they target localhost; callback_auth_token is sent back as Authorization: Bearer <token>.
- •Callback requests include X-JungleGrid-Callback-Version, X-JungleGrid-Callback-Timestamp, X-JungleGrid-Job-ID, and X-JungleGrid-Job-Status headers.
04
Jobs and runtime surfaces
Jobs are created and queried through Bearer-protected /v1 routes. The estimate endpoint uses the same draft job fields as submit and returns likely placement, runtime range, cost range, queue wait range, and estimated start window before confirmation. Optional constraints can be supplied per job while keeping the API intent-first.
- •POST /v1/jobs queues a new workload for an authenticated account.
- •GET /v1/jobs lists the caller's own jobs; GET /v1/jobs/{job_id} returns the detail view.
- •GET /v1/jobs/{job_id}/runtime exposes runtime tails and exit information when available.
- •Estimate responses now include estimated_hourly_rate_usd, min/max hourly range, estimated_queue_wait_min_sec, estimated_queue_wait_max_sec, estimated_start_time_min, estimated_start_time_max, and constraints_relaxed when soft preferences were auto-relaxed.
- •POST /v1/jobs/{job_id}/share awards +$3 (300 credits) once per completed job.
05
Nodes, provider operations, and account linking
Public capacity discovery and provider-owned node operations are split. Providers also have an authenticated route for linking an additional business role to the same account.
- •GET /v1/nodes is public capacity discovery.
- •GET /v1/nodes/mine and POST /v1/nodes/register are provider-facing authenticated routes.
- •Registry credential routes let the portal and CLI save private image credentials explicitly.
06
Billing, topups, and payouts
Billing surfaces are built around credits and use Paystack-backed wallet funding in USD. User and provider views share balance and history routes, while provider payout routes are currently unavailable as Jungle Grid standardizes on USD.
- •Users start USD wallet topups and verify them through the topup routes.
- •Provider payout endpoints remain present but currently return a temporary-unavailable response.
- •The Paystack webhook route is the settlement hook for billing events.
07
Implementation notes for consumers
The web portal and CLI both treat the orchestrator as the source of truth. Resource APIs require Bearer tokens, and the portal's public browser pages delegate session choice before handing off to authenticated /v1 routes.