Run your first Qoder Cloud Agent in five steps.
Get your first Qoder Cloud Agent running in five steps: obtain a token, pick an environment, create an Agent, create a Session, and exchange messages. The whole flow uses only
Choose a PAT or SAT based on the calling identity. The remaining steps use the common
List the available environments and capture the ID:
Example response:
Define a general-purpose Agent with a shell tool:
Example response:
Creating a Session requires two parameters:
Example response:
Send a user message to the Session, then receive Agent responses live over SSE:
Example event stream output:
The whole flow combined into a single runnable script:
Q: I'm getting 401 Unauthorized.
A: Check that
curl — no SDK required.
Prerequisites
- A Qoder account
- A terminal (macOS, Linux, or WSL)
curl, plusjq(optional, for formatting JSON)
Windows users
Windows users
The commands in this guide use bash syntax. Windows users should use one of the following:
- Git Bash (recommended): included with Git for Windows
- WSL: install via
wsl --install
- Set environment variables:
$env:QODER_ACCESS_TOKEN="your-token"(notexport) - Use real curl: type
curl.exe(PowerShell aliasescurltoInvoke-WebRequest) - Install jq separately:
winget install jqlang.jq
Step 1: Obtain an access token
Choose a PAT or SAT based on the calling identity. The remaining steps use the common QODER_ACCESS_TOKEN environment variable.
Set the service endpoints first. The SAT exchange and business API requests must use endpoints in the same region:
Option 1: PAT (personal user)
- Sign in to the Qoder console.
- Open Settings → Personal Access Tokens.
- Click Create Token, then set a name and expiration.
- Copy the token and set it as an environment variable:
The PAT is shown only once at creation. Save it securely right away.
Option 2: SAT (Service Account Token)
- Sign in to the Qoder console as an organization administrator.
- Create or select a Service Account under organization management.
- Create an API Key from the Service Account details page. You do not select scopes when creating the key; specify the required scopes when exchanging it for an SAT.
- Copy the SA Key, then exchange it for an SAT:
Use the SA Key only to exchange for an SAT; do not send it directly to Cloud Agents APIs. An SAT is valid for at most 12 hours. For Forward APIs, follow the separate token flow in Authentication.
Step 2: Pick an Environment
List the available environments and capture the ID:
Step 3: Create an Agent
Define a general-purpose Agent with a shell tool:
Step 4: Create a Session
Creating a Session requires two parameters: agent (Agent ID or object) and environment_id (Environment ID).
Bind the Agent to the Environment to create a runtime instance:
The Session starts in
idle status. It will only begin processing once you send a message in the next step.Step 5: Send a Message and Stream Events
Send a user message to the Session, then receive Agent responses live over SSE:
- Every event (except
heartbeat) includes anid:line and the JSON payload containsid,type, andprocessed_atfields. heartbeatevents are sent approximately every 15 seconds to keep the connection alive.- The
contentfield inagent.messageuses the[{"type":"text","text":"..."}]array format. session.status_running/session.status_idlecarry no extra fields beyondid,type,processed_at, and (for idle)stop_reason.agent.thinkingsignals that the model is reasoning but contains nocontentortextfield.
End-to-End Script
The whole flow combined into a single runnable script:
FAQ
Q: I'm getting 401 Unauthorized.
A: Check that $QODER_ACCESS_TOKEN is set correctly and has not expired. PAT users should create a replacement token; Service Account users should exchange the SA Key for a new SAT.
Q: Creating an Agent returns 400 Bad Request.
A: Verify the request JSON. The model field must be a valid value (such as "ultimate"), and tools must be an array.
Q: The Session stays in idle and emits no events.
A: A newly created Session starts in idle status. You must send a user.message event (Step 5) to trigger Agent execution.
Q: My SSE stream disconnected.
A: The stream endpoint supports the Last-Event-ID header for reconnection replay. Pass the last event id you received; the stream resumes from the event after that ID. Event-type query filters are not currently supported.
Q: GET /api/v1/cloud/environments returns an empty array.
A: New accounts may not have a pre-provisioned environment. Follow the tip in Step 2 to create one manually.