HTTP API
Covers: the HTTP API's address and key, its resources and routes, an instance's routes, a Task's fields and the errors.
For: developers who call poema cloud from a language with no SDK, such as Node, Go or Rust, and agents that use curl.
The CLI, the Python SDK and poema-mcp are clients of this API: anything they do, a request here does too. An
instance is a Task in the API. The Quickstart's HTTP tab makes a first one.
Address and key
Every route is under $POEMA_URL/v1alpha1/namespaces/NAMESPACE/, where NAMESPACE is your organization's namespace:
the word after poema_ns_ in your key, poema_ns_XXXXXXXX_..., shown with your keys in Settings, Account. Send the key as
X-API-Key on every request. Bodies are JSON.
export POEMA_URL=https://api.client-test.poema.dev export POEMA_API_KEY=poema_ns_...
export POEMA_NAMESPACE=YOUR_NAMESPACE
API="$POEMA_URL/v1alpha1/namespaces/$POEMA_NAMESPACE"
curl -fsS "$API/tasks" -H "X-API-Key: $POEMA_API_KEY"
Resources
The kinds are tasks, workspaces, gateways and models (Concepts):
PUT $API/KIND/NAMEcreates or replaces one. Its body is the manifest thatpoema applysends:{"apiVersion": "poema.dev/v1alpha1", "kind": "Task", "metadata": {"name": "NAME"}, "spec": {...}}.GET $API/KINDlists them, as{"items": [...]}, andGET $API/KIND/NAMEreads one.DELETE $API/KIND/NAMEdeletes one. For an instance it answers at once with202; with?wait=trueit answers once the instance is gone.
A list answers 100 at most; when nextPageToken is set, ask again with ?pageToken= that value.
Secrets hold the keys a Model names, and are write-only:
PUT $API/secrets/NAMEwith{"data": {"api-key": "..."}}creates or replaces one. Send the value from a file or a variable, never typed on a command line.GET $API/secretslists their names and keys, never their values, andDELETE $API/secrets/NAMEdeletes one.
An instance's routes
GET $API/tasks/NAME/logsis its command's output:?tail=Nits last N lines,?follow=trueits lines as they come, for as long as it runs.GET $API/tasks/NAME/eventsis its recent activity, as{"items": [...]}.GET $API/tasks/NAME/watchstreams the instance, a line of JSON at each change of its status.POST $API/tasks/NAME/suspendandPOST $API/tasks/NAME/resume, with the body{}, suspend it and resume it. Both answer at once: read the instance untilstatus.phaseisSuspendedorRunning.POST $API/tasks/NAME/timeoutwith{"timeoutSeconds": N}suspends it N seconds from now, at most your plan's session length; 0 sets that length.POST $API/tasks/NAME/forkwith{"names": ["try-a", "try-b"]}forks a suspended instance into one new instance a name, each on a copy of its/workspace;"memory": truecopies its memory too, and"suspend": truekeeps each fork suspended. An instance that is not suspended answers409 Conflict.
Quota and usage
GET $API/quotais your plan's limits next to what is in use.GET $API/usage?from=YYYY-MM-DD&to=YYYY-MM-DDis your organization's use between two days: model tokens and their cost, and compute in vCPU-hours, in total, by model and by day.
A Task's fields
metadata.name names it and metadata.labels labels it. Its spec:
command, the one field it needs: a list, such as["sh", "-c", "echo hello"].image: poema's base image unless given (Deploy from git lists the others).env: a list of{"name": ..., "value": ...}. Values are plain text that your keys read: a model's key goes in a Model.workspaces: a list of{"name": ...}, andgatewayandmodel, each{"name": ...}. Without a gateway it has no network.debug:truefor Access from your machine, which commands, files, terminals and SSH need.resources:{"requests": {"cpu": "2", "memory": "2Gi"}}; without it, 1 vCPU and 256 MiB.timeoutSeconds: it ends that many seconds after it starts, at most your plan's session length.onTimeoutissuspend, the default, ordelete.onExit:suspendordeletewhen its command exits. Without it, the instance stays up after its command ends.
Its status.phase is Pending, Running, Suspended, Failed, or Terminating while it is deleted.
Its status.conditions say why.
Errors
Every error is JSON, {"error": {"code": "Invalid", "message": "..."}}, with the matching status: Invalid 400,
Unauthorized 401, Forbidden 403, NotFound 404, Conflict 409 and Unavailable 503, which a retry may cure.
Read the message: it says what to change.
Last checked: unreleased checkout.