Every endpoint your app calls, in one place: the two ways to start a run, the two that pair a machine, and the reads that answer what a user has and what they used.
https://api.soba.so/v1
One base, one credential. Your server sends the app key
(sk_soba_<id>.<secret>, not the token a paired machine holds):
Authorization: Bearer sk_soba_…
How a paired machine talks to Soba is a different surface entirely, and not one your
app ever sends to. This page is the half your app touches.
Running#
POST /v1/chat/completions#
The OpenAI-compatible endpoint. The request you already send, at a different host, with
user required. You own the loop; an agent such as Claude Code answers with the
conversation as text. Full treatment on The endpoint.
POST /v1/runs#
One request that comes back finished, with Soba owning the agent loop.
JSON
{
"user": "usr_123",
"model": "auto",
"prompt": "Summarise everything I saved this week",
"tools": [],
"route": { "prefer": ["user-hardware", "user-subscription"] }
}
Streams events as text/event-stream. The SDK is a
convenience over exactly this shape, not a different product. See
Runs and the SDK.
The run's id comes back in a Soba-Run-Id header, ahead of the first event,
because the three routes below are addressed by it.
Reading a run again#
"resumable": true in the body keeps the run going if your request goes away, and
numbers each frame with an SSE id:. Read it again, from the frame after after,
then live:
|
|
GET /v1/runs/:id/stream?after=N |
The frames after N, then live, as text/event-stream. A tool_call or approval_request that was already answered arrives with "answered": true; do not run it again. 404 for a run that is not yours or finished more than ten minutes ago, 409 for one not started resumable |
One reader at a time: a second GET takes the run over and ends the first stream.
A run nobody reads for fifteen minutes is stopped. "detached": true with no
webhook starts one nobody is reading yet, answered 202 with its id.
Answering a run#
A stream goes one way. A tool call, an approval and a cancellation all need a
return path, so each is a request of its own, keyed to the run:
|
|
POST /v1/runs/:id/tool_result |
{ callId, result, isError? }. Your app's answer to a tool_call frame |
POST /v1/runs/:id/approval |
{ approvalId, decision, reason? }. Anything that is not "allow" is a denial |
POST /v1/runs/:id/cancel |
Stop the run. Best effort: tokens already produced are already produced |
The SDK sends all three for you. They are written down because an app driving a run
over raw HTTP has to send them itself.
Neither run endpoint is idempotent
A retry that crosses a boundary you cannot observe starts a second run. See
Errors and retries.
Pairing a machine#
The device authorization grant. The first two are the only endpoints
a worker calls before it has a token, and they take no credential of their own: the
pk_soba_ connect key in the path names the app, and it is public by design.
|
|
POST /c/<pk>/v1/device/code |
Issue a device code and a user code; return the verification URI and a poll interval |
POST /c/<pk>/v1/device/token |
Polled until the user answers; returns the pairing token and where the machine should connect |
slow_down widens the poll interval permanently by five seconds, per RFC 8628.
Your server: minting a session#
One call, with your sk_soba_ key. Everything the browser then does is scoped to the
one user you named, for ten minutes.
|
|
POST /v1/end_users/session |
{ user, email? }. Returns { session, expires_in, url }; send them to url |
DELETE /v1/end_users/session?user=<id> |
End every live session for that user, e.g. when they sign out of your app |
Proving this key creates a person
Minting a session is how somebody first exists — it is the path for a user who connects
a machine before they ever send a run. So a request sent only to check that the key works
puts a real person in your Users list.
Name soba/echo as the user instead. It proves the key and the base URL, reports which
environment the key serves, and creates nothing:
Terminal
curl https://soba.so/v1/end_users/session \
-H "Authorization: Bearer $SOBA_KEY" \
-H "Content-Type: application/json" \
-d '{ "user": "soba/echo" }'
The browser: what a session may do#
All four take Authorization: Bearer est_… and act for exactly one end user.
|
|
GET /v1/connect |
The app's name and the pairing command, so the page can render itself |
GET /v1/device/lookup?code= |
What is asking to be paired: hostname, platform, arch, client |
POST /v1/device/approve |
{ user_code }. Binds the pairing token to this user |
POST /v1/device/deny |
{ user_code }. The worker is told access_denied rather than left polling |
GET /v1/machines |
This user's machines and their live state. What <ComputeStatus /> reads |
The approval is the attribution
POST /v1/device/approve is where the pairing token is bound to a person, and it is
bound to the one the session names, never to anything the machine claimed. A run
may only ever reach a worker owned by the user it is attributed to.
Reading#
The ledger is authoritative, and these are how you read it rather than inferring it
from webhooks.
|
|
GET /v1/users/:id |
What this user has: their plan, allowance, usage this period, and what they have connected |
GET /v1/users/:id/compute |
Each connected machine, its runtimes, cost classes and live state |
GET /v1/usage |
Usage rows, filterable by user, period and environment. What the dashboard reads |
GET /v1/plans |
The plans you configured, as your pricing page renders them |
GET /v1/usage returns the same integer micros everything else in Soba uses. No
floats, no currency strings, and costClass on every row so a total never has to
remember what it routed to.
Plans and payment#
Checkout, entitlement and the customer portal are driven through
<SobaPlans /> and <SobaCheckout />, or the hosted fallback page,
rather than assembled from raw endpoints. Both are thin over this API, and the reason
to prefer them is that they create every Checkout Session in your connected Stripe
account tagged with the user's id, which is what links a payment to the trial that led
to it. See Plans and billing and Stripe.
Management#
Soba itself, from code: your workspaces, their apps, and the apps' keys, the way the
Supabase and Railway management APIs work. These live on https://soba.so/v1, not
api.soba.so, and take one of two credentials, neither of which can start a run:
| Credential |
Made by |
Acts as |
pat_soba_… |
npx @soba-so/cli login, kept in ~/.soba/cli.json |
You, with exactly what you may do in each workspace, read fresh on every call |
wk_soba_… |
soba workspace-key |
One workspace, as an admin: for a server that makes an app per thing it builds. It cannot delete apps |
| Endpoint |
|
GET /v1/me |
Who the credential acts as. DELETE signs a terminal's token out |
GET /v1/workspaces |
Your workspaces, and whether you can create apps and manage keys in each |
POST /v1/workspaces/:id/keys |
Make a workspace key. A person's token, with app and key management there |
GET /v1/workspaces/:id/apps |
The workspace's apps, oldest first |
POST /v1/workspaces/:id/apps |
Make an app: { "name": "Study planner" }. Counts against the tier's app limit |
GET /v1/apps/:id |
One app |
PATCH /v1/apps/:id |
Rename it: { "name": "…" } |
DELETE /v1/apps/:id |
Delete it and everything in it. A person's token only; not a workspace's only app |
GET /v1/apps/:id/keys |
Its live keys, as previews |
POST /v1/apps/:id/keys |
Mint a secret key: { "environment": "development" }. Shown once. replace_idle: true replaces a never-used one instead of being refused |
DELETE /v1/apps/:id/keys/:keyId |
Revoke one |
GET /v1/apps/:id/plans |
Its live plans, oldest first. ?environment= for one catalogue |
POST /v1/apps/:id/plans |
Add a plan: { "environment": "production", "name": "Pro", "price": 20, "route_prefer": ["user-subscription", "frontier"] }. environment is required. { "environment", "template": "byo" } adds the free "Bring your own" plan where there are none |
GET /v1/apps/:id/plans/:planId |
One plan |
PATCH /v1/apps/:id/plans/:planId |
Change the fields sent; the rest stay |
DELETE /v1/apps/:id/plans/:planId |
Archive it: off sale, with the users on it and its history kept |
GET PATCH /v1/apps/:id/settings |
Connect popup, model picker, own AI and limits. environment is required; PATCH changes what you send |
GET POST /v1/apps/:id/providers |
The AI accounts the app pays for. { "service": "openai", "api_key": "…" }, or name and base_url. Keys are checked, sealed and never returned |
GET PATCH DELETE /v1/apps/:id/providers/:provider |
One provider. A new host in base_url needs api_key with it. DELETE …/key forgets only its key |
GET /v1/apps/:id/providers/:provider/available |
The models it says it serves |
PUT DELETE /v1/apps/:id/providers/:provider/models |
Add or change one ({ "model": "…", "tier": "fast" }), or remove ?model= |
PUT /v1/apps/:id/providers/order |
{ "providers": […] }, first tried first. GET …/services lists the known ones |
GET /v1/apps/:id/custom_models · PUT DELETE …/:alias |
Your own names over models from any provider |
GET POST /v1/apps/:id/rewards · PATCH DELETE …/:reward · POST …/:reward/give |
Rewards, by id or slug |
GET /v1/apps/:id/users · GET PATCH …/:user |
Users, by your id or ours. PATCH { "plan": id } gives a plan without billing for it |
GET /v1/apps/:id/machines, /runs, /activations, /overview |
What the dashboard shows |
POST /v1/apps/:id/stripe/sync |
Put the app's plans into your connected Stripe now |
GET /v1/workspaces/:id/members · PATCH DELETE …/:member |
The workspace's people. Writes take a person's token |
PATCH /v1/apps/:id/keys/:keyId |
{ "monthly_cap": 50 }: dollars a secret key may spend a month, or null |
PUT /v1/apps/:id/logo |
{ "data": "<base64>" } sets the icon; "use": "connect_popup" with an environment sets that popup's. PUT …/custom_models/:alias/logo and PUT /v1/workspaces/:id/logo too |
POST /v1/apps/:id/pairing |
A link that pairs your own machine. You approve it in the browser |
GET POST /v1/apps/:id/repricing |
People on a plan's old price. { "old_price", "decision": "keep" }, or "move" with confirm_subscribers |
POST /v1/apps/:id/stripe/check · …/plans/:planId/stripe/restore, …/accept |
Compare your plans with Stripe, and put back or leave a change made there |
POST /v1/apps/:id/plans/:planId/try_checkout · PUT …/seats |
A checkout link as a preview buyer; correct a seat count |
GET /v1/workspaces/:id/billing |
Whether it is live, its tier, what each tier costs, card and invoices |
POST /v1/workspaces/:id/billing/go_live, …/card |
Answers { "url" }, Stripe's page: go_live buys a first plan, card changes the card. A card is never sent to Soba. Production needs no plan. Read billing until live (on a plan) is true |
POST /v1/workspaces/:id/billing/tier, …/cancel |
An owner's. { "tier", "confirm_fee" } with the monthly fee; { "confirm": "<workspace name>" } |
GET DELETE /v1/workspaces/:id/stripe · POST …/connect |
Your own Stripe, per environment. Connect answers { "url" }, which you accept signed in as yourself |
POST /v1/workspaces/:id/transfer, …/delete |
An owner's. Both take confirm, the workspace's name |
GET /v1/workspaces/:id/keys · DELETE …/:key |
Workspace keys, by name |
POST /v1/workspaces/:id/invites · DELETE …/:invite · PATCH /v1/workspaces/:id/settings |
Invite somebody; name and icon |
From the SDK:
JavaScript
import { Soba, SobaManagement } from "@soba-so/sdk"
const soba = new SobaManagement({ accessToken: process.env.SOBA_ACCESS_TOKEN })
const [workspace] = await soba.workspaces.list()
const app = await soba.apps.create({ workspace: workspace.id, name: "Study planner" })
const { key } = await soba.apps.keys.create(app.id, { environment: "production" })
const runs = new Soba({ apiKey: key }) // the new app's own key, which runs things
Plans, with the same client:
JavaScript
const pro = await soba.apps.plans.create(app.id, {
environment: "production",
name: "Pro",
price: 20, // dollars a month
included_units: 500, // runs on AI you pay for; null is unlimited
route_prefer: ["user-subscription", "frontier"], // best first
})
await soba.apps.plans.update(app.id, pro.id, { price: 25 })
await soba.apps.plans.list(app.id, { environment: "production" })
await soba.apps.plans.archive(app.id, pro.id)
A production plan is on sale to your users at once. route_prefer is also the ceiling:
a class left out is never billed to you, and sending it on an update sets the ceiling
again (route_allow adds classes allowed but not ranked). The first free plan in an
environment becomes the one new users start on, and that plan cannot be given a price.
A field the API does not know, or of the wrong type, is refused rather than ignored.
And from a terminal:
Terminal
npx @soba-so/cli login # once per machine; then links this folder
npx @soba-so/cli apps # list
npx @soba-so/cli apps create "Study planner" --workspace Acme
npx @soba-so/cli link # pick an app; its keys go to .env.local
npx @soba-so/cli keys create --environment production
npx @soba-so/cli settings set connect_popup.theme=dark model_picker.menu=tabs --environment production
npx @soba-so/cli providers add openai --key-env OPENAI_API_KEY
npx @soba-so/cli plans create Pro --price 20 --route user-subscription,frontier --environment production
A terminal's token signs itself out after 90 days without use, and every use moves
that day back, so one you work in never expires. Revoke one sooner under Account →
Sign-In and Security, and a workspace key on the workspace's Settings page. Soba keeps only a hash of either, so store
what you mint.
SobaWorkspace and /v1/workspace/apps, from SDK 0.0.17, are deprecated. They still
work with a workspace key, and SobaManagement with the same key does everything they
do.
Errors#
Every endpoint returns the same envelope, and the status codes mean the same thing on
each. See Errors and retries.
JSON
{ "error": { "type": "no_compute", "message": "…", "code": "no_compute" } }