Learn
Your first run from code
Create an API key, start a session with one request, follow it live with curl, read its answer and send a follow-up into the same sandbox.
In this lesson you start an agent from a terminal with nothing but curl. The run needs no
repository, so you can skip GitHub for now. By the end you have one session that took two turns in
the same sandbox, and you know the four calls every integration is built from: create, stream, read
and follow up.
Get a key
1. Create the key
Any member of the org creates a key on the console's Developers page
(cloud.getrush.ai/console/developers): name it and
pick when it expires. A person creates keys; a key cannot create another
(createApiKey takes a signed-in session).
The secret, starting rk_live_, is shown once. Rush never shows it again. A key can expire in up to
a year, or never.
2. Keep it on your server
export RUSH_API_KEY=rk_live_...
export RUSH_ORG=acmeThe key acts as you, the member who created it, in its own org. Its runs use Rush's models, billed per token to you, so you need no model account of your own. Your account's first $1 of runs, models and compute, is on Rush; after that, and from the first cent on an account made without a Free plan, runs are paid from credits you buy under Billing, with auto-reload under Developers if you want it (Models).
Start a session
3. Send the request
A session needs an agent (claude, codex or opencode, or a saved agent's id) and an input, the task:
curl -X POST https://api.phoenix.so/o/$RUSH_ORG/sessions \
-H "Authorization: Bearer $RUSH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"agent": "claude",
"input": "Write a Python function that parses ISO 8601 durations, with tests. Run the tests and report the result.",
"request_id": "3f2b8c1e-6d4a-4e9b-9a7f-2c5d8e1b4a60"
}'4. Read the answer
The response is 202 with the session, before the sandbox is ready:
{
"execution_id": "7c1e9a4f-2b6d-4f83-a5c0-9e3d1b8f6a24",
"org_id": "acme",
"status": "queued",
"harness": "claude",
"created_at": "2026-10-09T00:56:44.205Z"
}Keep execution_id; every other call names it. The request_id, a UUID you make once per run, makes a retry safe:
the same request_id and body return the session it first started instead of starting a second one.
export SESSION_ID=7c1e9a4f-2b6d-4f83-a5c0-9e3d1b8f6a24Follow it live
5. Hold the event stream
curl -N https://api.phoenix.so/o/$RUSH_ORG/sessions/$SESSION_ID/events \
-H "Authorization: Bearer $RUSH_API_KEY"-N turns off curl's buffering so each frame prints as it arrives. Each frame is an event: line and
a JSON data: line. First come status events while the sandbox starts, then the agent's own
events: message, tool_use, tool_result, thinking and result. A session still queued sends one
status and the stream closes, so run the command again until it has started.
event: status
data: {"status":"allocating","id":"7c1e9a4f-2b6d-4f83-a5c0-9e3d1b8f6a24"}
event: done
data: {"status":"completed","output":"...","result":{"text":"All 9 tests pass.","structured":null,"schema_valid":null}}The stream closes after done. If your connection drops, reconnect with the Last-Event-ID header
set to the last id you saw and the stream resumes after it. The
streamSession reference lists every event.
Read the session
6. Read the result
curl https://api.phoenix.so/o/$RUSH_ORG/sessions/$SESSION_ID \
-H "Authorization: Bearer $RUSH_API_KEY"getSession returns the record. The fields to look at first:
| Field | What it holds |
|---|---|
status |
completed, or paused once the sandbox parks between turns |
result |
The agent's final answer for the last finished turn, in full |
artifacts |
Files the agent saved, each with a download url good for an hour |
turns_count, tool_calls_count |
How much work the run did |
total_cost_usd |
What the run cost so far |
A field with no value is left out of the response, never sent as null.
Send a follow-up
7. Continue in the same sandbox
A run started with a key is resumable: when the turn ends, the sandbox parks with its disk and memory and costs nothing while parked. A follow-up wakes it where it left off:
curl -X POST https://api.phoenix.so/o/$RUSH_ORG/sessions/$SESSION_ID/messages \
-H "Authorization: Bearer $RUSH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "Add support for week durations like P2W and rerun the tests."
}'The answer is 202 with the session and the turn the message opened. The agent still has the
file it wrote in the first turn.
8. Wait on the follow-up's turn
A follow-up sent while a turn is still running waits in line: its turn.status is queued, and it
runs when the current turn ends. The session's own status can read completed with the previous
answer in the meantime, so wait on the turn instead, with the turn.id from the 202 as $TURN_ID:
curl https://api.phoenix.so/o/$RUSH_ORG/p/_/sessions/$SESSION_ID/turns/$TURN_ID \
-H "Authorization: Bearer $RUSH_API_KEY"Poll until it leaves queued and running. It ends completed with this message's answer,
needs_review if the proof is missing or incomplete, or failed, with an error_code if it never
ran.
A parked sandbox is kept for 7 days after it last parked, and each new turn starts that clock again.
Next
- Act on the result with a webhook replaces the open stream with a
signed
POSTto your server. - Runs and sessions covers every status a session moves through.