Get an execution
Read execution state, output, and the exact tool calls made by the command. While the command runs, the request is held until it finishes or needs an approval, for at most 30 seconds; an execution that waits for an approval answers at once.
/api/v1/executions/:executionIdconst response = await fetch("https://api.smallworld.sh/api/v1/executions/01995e57-3027-7557-a233-009ea3dcd8fc", {
method: "GET",
headers: { Authorization: `Bearer ${apiKey}` },
});
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
const result = await response.json();
Use your server-side apiKey. Replace the example IDs.
Path parameters#
executionIdUUIDrequiredThe ID returned in execution.id.
Responses#
| Status | Your next step |
|---|---|
completed | Read stdout and stderr. An exitCode of 0 means success. Save the fileChanges you track. |
running | Read the execution again right away: the read is held until the command finishes or needs an approval. Keep the same execution ID. |
requires_approval | Ask the user to approve or deny each pending toolCall, then read the execution again. Uploaded files stay in place meanwhile; fileChanges arrives with the final result. |
timed_out | The command reached its time limit and exited with 124. Shorten the work or raise the limit in Settings → Terminal. |
interrupted | The command stopped before finishing. Inspect output and tool calls before deciding whether to run another command. |
Send the next command only after this execution finishes. One execution can pause for approval more than once.
If a response is lost, read the execution when you have its ID. If you never received an ID, do not resend automatically: the command may have run.
The command finished. Check exitCode as well as stdout, stderr, and toolCalls; completed can have a nonzero exit code.
{
"toolCalls": [],
"user": {
"id": "customer_123",
"email": null,
"groupIds": [],
"createdAt": "2026-10-10T12:00:00.000Z",
"updatedAt": "2026-10-10T12:00:00.000Z"
},
"session": {
"id": "01995e57-0501-76b8-b797-5b24df5b307f",
"worldId": "01995e56-e2d4-7f19-b691-7bf9af6abdc8",
"userId": "customer_123",
"groupId": null,
"status": "idle",
"closedReason": null,
"stateVersion": 1,
"createdAt": "2026-10-10T12:00:00.000Z",
"updatedAt": "2026-10-10T12:00:01.000Z"
},
"created": {
"user": false,
"session": false
},
"execution": {
"id": "01995e57-3027-7557-a233-009ea3dcd8fc",
"sessionId": "01995e57-0501-76b8-b797-5b24df5b307f",
"command": "echo 'Hello from Smallworld'",
"status": "completed",
"stdout": "Hello from Smallworld\n",
"stderr": "",
"truncated": false,
"exitCode": 0,
"errorCode": null,
"fileChanges": [],
"outputFiles": [],
"mountChanges": null,
"createdAt": "2026-10-10T12:00:00.000Z",
"completedAt": "2026-10-10T12:00:01.000Z"
}
}
More about this endpoint
An HTTP 200 does not guarantee a successful command. Check execution.status, exitCode, stdout, and stderr.
When the user leaves the session's group, other than by a move, or the group is deleted, the session is closed for good: session.status is closed and session.closedReason says why. A running command is stopped at once and ends interrupted with errorCode session_closed. A command waiting for approval ends the same way, and its pending tool call ends interrupted with errorCode session_closed. Executions, tool calls, and outputs stay readable.
Poll GET /executions/:executionId while the command is running or requires_approval. For each pending toolCall, render providerApproval.choices when providerApproval is present and submit the selected value through /tool-approvals/:id/provider/:approvalId. Otherwise use /tool-approvals/:id/approve or /deny.
A tool call marked unknown may have reached its remote service. Check the remote result before retrying a write.
Changes to a mount are checked once per mount at the end of the command. When they need approval, the execution is requires_approval and toolCalls includes the pending check, with integration mounts and the mount's ID as toolName; decide it like any tool call.
When a mount's changes aren't saved, stderr gets a notice such as Changes to /workspace/docs were not saved: a person rejected them. and an exit code of 0 becomes 1. The session's /workspace files and other mounts are still saved.
A denied tool call becomes a tool error. Bash or JavaScript can handle it and continue, so inspect both execution output and toolCalls.
fileChanges is read from the saved result: every read returns the same changes, also after later commands change the session's files. Uploaded files stay in place while the execution waits for approval.
An API restart or shutdown interrupts commands that are running and discards their file changes: the session keeps its previous files and fileChanges is null. Completed tool results remain in history; an interrupted in-flight provider call may be unknown. A command waiting for an approval keeps waiting across a graceful restart or deploy, and also across a crash once it has waited five minutes; it continues when the call is decided.