# 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.

`GET https://api.smallworld.sh/api/v1/executions/:executionId`

## Parameters

| Name | Location | Type | Required | Description |
| --- | --- | --- | --- | --- |
| executionId | path | UUID | Yes | The ID returned in execution.id. |

## Request examples

### curl

```curl
curl --fail-with-body -X GET 'https://api.smallworld.sh/api/v1/executions/01995e57-3027-7557-a233-009ea3dcd8fc' \
  -H "Authorization: Bearer $SMALLWORLD_API_KEY"
```

### typescript

```typescript
const 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();
```

### python

```python
response = requests.get(
    "https://api.smallworld.sh/api/v1/executions/01995e57-3027-7557-a233-009ea3dcd8fc",
    headers={"Authorization": f"Bearer {api_key}"},
    timeout=30,
)
response.raise_for_status()
result = response.json()
```

## Responses

Returns toolCalls, user, session, created flags, and execution. execution.status is requires_approval, running, completed, timed_out, or interrupted. stdout and stderr are null while the command runs; each is cut at 1 MiB, and truncated says whether either was cut. errorCode names a failure the platform settled, such as execution_result_not_saved, and is otherwise null. fileChanges lists the files the command created, modified, or deleted under /workspace; it is null while the command runs, when the request set fileChanges to none, when the command's file changes were discarded (errorCode execution_file_changes_discarded), and for executions recorded before file changes were saved. Mount files never appear in fileChanges: mountChanges lists, for each mount the command changed, its mountId and path, outcome (saved or discarded), reason (why its changes weren't saved, or null), toolCallId (the check of those changes, or null), and changes, each with operation (create, update, delete, move, or rename), kind (file or directory), path or from and to, files for a folder's contents, and replaces for a move or rename onto an existing entry; mountChanges is null when the command changed no mount and while it runs. exitCode and completedAt may be null. session.userId is your application's user ID. session.groupId is your ID for the group the session acts for, or null in a groupless session; it stays after the group is deleted. session.status is idle, running, or closed, and session.closedReason is group_membership_removed, group_deleted, or null. user.groupIds is the user's current membership, also on an execution read later. created records whether this request created the user and session; read responses set both to false. outputFiles lists the files explicitly selected by view, including immutable authenticated content paths, or null when output was not captured.

### 200 · Completed

The command finished. Check exitCode as well as stdout, stderr, and toolCalls; completed can have a nonzero exit code.

```json
{
  "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"
  }
}
```

### 200 · Running

The command is still running. Output is null; retain the IDs and read the execution again.

```json
{
  "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": "running",
    "closedReason": null,
    "stateVersion": 0,
    "createdAt": "2026-10-10T12:00:00.000Z",
    "updatedAt": "2026-10-10T12:00:00.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": "running",
    "stdout": null,
    "stderr": null,
    "truncated": false,
    "exitCode": null,
    "errorCode": null,
    "fileChanges": null,
    "outputFiles": null,
    "mountChanges": null,
    "createdAt": "2026-10-10T12:00:00.000Z",
    "completedAt": null
  }
}
```

### 200 · Requires approval

The command paused at a pending tool invocation. Decide that exact toolCall, then read this execution again.

```json
{
  "toolCalls": [
    {
      "id": "b5212df0-ea8b-4eb8-a7b1-057ff45b3044",
      "sessionId": "01995e57-0501-76b8-b797-5b24df5b307f",
      "executionId": "01995e57-3027-7557-a233-009ea3dcd8fc",
      "userId": "customer_123",
      "worldId": "01995e56-e2d4-7f19-b691-7bf9af6abdc8",
      "integration": "acme",
      "integrationName": "Acme",
      "account": null,
      "connectionSource": "none",
      "group": null,
      "toolName": "get_order",
      "toolDescription": "Read an order by its ID.",
      "toolLabel": "read",
      "arguments": {
        "orderId": "order_456"
      },
      "status": "pending",
      "result": null,
      "error": null,
      "errorCode": null,
      "reason": null,
      "providerApproval": null,
      "hooks": [],
      "createdAt": "2026-10-10T12:00:00.000Z",
      "expiresAt": "2026-10-10T12:15:00.000Z",
      "completedAt": null,
      "decidedAt": null
    }
  ],
  "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": "running",
    "closedReason": null,
    "stateVersion": 0,
    "createdAt": "2026-10-10T12:00:00.000Z",
    "updatedAt": "2026-10-10T12:00:00.000Z"
  },
  "created": {
    "user": false,
    "session": false
  },
  "execution": {
    "id": "01995e57-3027-7557-a233-009ea3dcd8fc",
    "sessionId": "01995e57-0501-76b8-b797-5b24df5b307f",
    "command": "acme get-order --json '{\"orderId\":\"order_456\"}'",
    "status": "requires_approval",
    "stdout": null,
    "stderr": null,
    "truncated": false,
    "exitCode": null,
    "errorCode": null,
    "fileChanges": null,
    "outputFiles": null,
    "mountChanges": null,
    "createdAt": "2026-10-10T12:00:00.000Z",
    "completedAt": null
  }
}
```

### 200 · Timed out

The command reached the workspace's active-time limit (60 seconds by default) or the one-hour execution limit, and stopped with exit code 124. Approval waits pause both limits; integration calls count only toward the one-hour limit. stderr ends with the reason. Output printed before the timeout may be missing.

```json
{
  "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": "sleep 120",
    "status": "timed_out",
    "stdout": "",
    "stderr": "Command timed out after 1 minute of active time, the limit for this workspace. Waiting for approvals and integration calls doesn't count toward it.\n",
    "truncated": false,
    "exitCode": 124,
    "errorCode": null,
    "fileChanges": [],
    "outputFiles": [],
    "mountChanges": null,
    "createdAt": "2026-10-10T12:00:00.000Z",
    "completedAt": "2026-10-10T12:00:01.000Z"
  }
}
```

### 200 · Interrupted

The command could not finish, such as after an API crash or shutdown while it ran, or its result couldn't be saved (errorCode execution_result_not_saved), or it behaved differently when it continued after a long approval wait (errorCode execution_replay_diverged). Its file changes were discarded. A command also ends interrupted when its session is closed because the user left the session's group or the group was deleted (errorCode session_closed). Inspect tool-call history before retrying external writes.

```json
{
  "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": "interrupted",
    "stdout": "",
    "stderr": "This command's result couldn't be saved, so its file changes were discarded. Check whether it had other effects before running it again.",
    "truncated": false,
    "exitCode": null,
    "errorCode": "execution_result_not_saved",
    "fileChanges": null,
    "outputFiles": null,
    "mountChanges": null,
    "createdAt": "2026-10-10T12:00:00.000Z",
    "completedAt": "2026-10-10T12:00:01.000Z"
  }
}
```

### 200 · Provider approval

The provider requested a choice for this pending call. Display the saved prompt and its choices to the acting user.

```json
{
  "toolCalls": [
    {
      "id": "b5212df0-ea8b-4eb8-a7b1-057ff45b3044",
      "sessionId": "01995e57-0501-76b8-b797-5b24df5b307f",
      "executionId": "01995e57-3027-7557-a233-009ea3dcd8fc",
      "userId": "customer_123",
      "worldId": "01995e56-e2d4-7f19-b691-7bf9af6abdc8",
      "integration": "gmail",
      "integrationName": "Gmail",
      "account": "support@example.com",
      "connectionSource": "group",
      "group": {
        "id": "team_42",
        "name": "Support team"
      },
      "toolName": "trash_thread",
      "toolDescription": "Move a conversation to Trash.",
      "toolLabel": "destructive",
      "arguments": {
        "threadId": "thread_456"
      },
      "status": "pending",
      "result": null,
      "error": null,
      "errorCode": null,
      "reason": null,
      "providerApproval": {
        "id": "69b8aa84-bcbd-4f8b-833c-f414760d9449",
        "message": "This operation requires your permission.",
        "question": "Allow this operation?",
        "choices": [
          {
            "value": "ALLOW_ONCE",
            "label": "Allow once"
          },
          {
            "value": "DENY_ONCE",
            "label": "Deny once"
          }
        ]
      },
      "hooks": [],
      "createdAt": "2026-10-10T12:00:00.000Z",
      "expiresAt": "2026-10-10T12:15:00.000Z",
      "completedAt": null,
      "decidedAt": null
    }
  ],
  "user": {
    "id": "customer_123",
    "email": null,
    "groupIds": [
      "team_42"
    ],
    "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": "team_42",
    "status": "running",
    "closedReason": null,
    "stateVersion": 0,
    "createdAt": "2026-10-10T12:00:00.000Z",
    "updatedAt": "2026-10-10T12:00:00.000Z"
  },
  "created": {
    "user": false,
    "session": false
  },
  "execution": {
    "id": "01995e57-3027-7557-a233-009ea3dcd8fc",
    "sessionId": "01995e57-0501-76b8-b797-5b24df5b307f",
    "command": "acme get-order --json '{\"orderId\":\"order_456\"}'",
    "status": "requires_approval",
    "stdout": null,
    "stderr": null,
    "truncated": false,
    "exitCode": null,
    "errorCode": null,
    "fileChanges": null,
    "outputFiles": null,
    "mountChanges": null,
    "createdAt": "2026-10-10T12:00:00.000Z",
    "completedAt": null
  }
}
```

### 200 · Selected file

The command selected an unchanged invoice page for display. Fetch contentPath with the same API key to read the saved PNG.

```json
{
  "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": "view --as image --pages 2 invoice.pdf",
    "status": "completed",
    "stdout": "",
    "stderr": "",
    "truncated": false,
    "exitCode": 0,
    "errorCode": null,
    "fileChanges": [],
    "outputFiles": [
      {
        "id": "909e0ae1-f9c7-4a58-af88-c3e23e13707f",
        "kind": "image",
        "filename": "invoice-page-2.png",
        "mimeType": "image/png",
        "sizeBytes": 62742,
        "source": {
          "path": "/workspace/invoice.pdf",
          "page": 2
        },
        "width": 1224,
        "height": 1584,
        "contentPath": "/api/v1/executions/01995e57-3027-7557-a233-009ea3dcd8fc/outputs/909e0ae1-f9c7-4a58-af88-c3e23e13707f/content"
      }
    ],
    "mountChanges": null,
    "createdAt": "2026-10-10T12:00:00.000Z",
    "completedAt": "2026-10-10T12:00:01.000Z"
  }
}
```

### 200 · File changes

The request uploaded memory.md without persistInSession. fileChanges returns its final content to save in your application, a report the command generated, and a session file it deleted, sorted by path. memory.md is not kept in the session.

```json
{
  "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": "printf '\\nPrefers concise answers.\\n' >> memory.md && printf 'month,total\\n2026-09,42\\n' > report.csv && rm draft.md",
    "status": "completed",
    "stdout": "",
    "stderr": "",
    "truncated": false,
    "exitCode": 0,
    "errorCode": null,
    "fileChanges": [
      {
        "path": "/workspace/draft.md",
        "operation": "deleted",
        "uploaded": false
      },
      {
        "path": "/workspace/memory.md",
        "operation": "modified",
        "uploaded": true,
        "encoding": "utf8",
        "content": "Works on Smallworld.\n\nPrefers concise answers.\n"
      },
      {
        "path": "/workspace/report.csv",
        "operation": "created",
        "uploaded": false,
        "encoding": "utf8",
        "content": "month,total\n2026-09,42\n"
      }
    ],
    "outputFiles": [],
    "mountChanges": null,
    "createdAt": "2026-10-10T12:00:00.000Z",
    "completedAt": "2026-10-10T12:00:01.000Z"
  }
}
```

### 200 · Files discarded

The command's file changes couldn't be kept, here because /workspace can't hold symbolic links. The session keeps its previous files and none of the uploads, retained or not; fileChanges is null and errorCode is execution_file_changes_discarded.

```json
{
  "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": "ln -s notes.md latest.md",
    "status": "completed",
    "stdout": "",
    "stderr": "This command's file changes were discarded because /workspace can't keep symbolic links (/workspace/latest.md).\n",
    "truncated": false,
    "exitCode": 1,
    "errorCode": "execution_file_changes_discarded",
    "fileChanges": null,
    "outputFiles": null,
    "mountChanges": null,
    "createdAt": "2026-10-10T12:00:00.000Z",
    "completedAt": "2026-10-10T12:00:01.000Z"
  }
}
```

### 200 · Mount changes

The command edited a file in the group's mount at /workspace/docs, whose update setting is ask. Someone approved the check in toolCalls, so mountChanges reports the mount's changes as saved. Mount files never appear in fileChanges; read their content through the mounts API.

```json
{
  "toolCalls": [
    {
      "id": "c3e1a9f2-4b7d-4e8a-9f10-2a3b4c5d6e7f",
      "sessionId": "01995e57-0501-76b8-b797-5b24df5b307f",
      "executionId": "01995e57-3027-7557-a233-009ea3dcd8fc",
      "userId": "customer_123",
      "worldId": "01995e56-e2d4-7f19-b691-7bf9af6abdc8",
      "integration": "mounts",
      "integrationName": "Mounts",
      "account": null,
      "connectionSource": "none",
      "group": {
        "id": "team_42",
        "name": "Support team"
      },
      "toolName": "0199a1c4-5b6e-7a10-9c2d-3e4f5a6b7c8d",
      "toolDescription": "/workspace/docs — Product documentation. Answers to customer questions go in faq.md.",
      "toolLabel": "write",
      "arguments": {
        "path": "/workspace/docs",
        "changes": [
          {
            "operation": "update",
            "kind": "file",
            "path": "/workspace/docs/faq.md",
            "size": 37,
            "diff": "--- /workspace/docs/faq.md\n+++ /workspace/docs/faq.md\n@@ -1,3 +1,3 @@\n # FAQ\n \n-Refunds take 5 business days.\n+Refunds take 3 business days.\n"
          }
        ]
      },
      "status": "completed",
      "result": {
        "saved": true
      },
      "error": null,
      "errorCode": null,
      "reason": null,
      "providerApproval": null,
      "hooks": [],
      "createdAt": "2026-10-10T12:00:00.000Z",
      "expiresAt": "2026-10-10T12:15:00.000Z",
      "completedAt": "2026-10-10T12:00:01.000Z",
      "decidedAt": "2026-10-10T12:00:01.000Z"
    }
  ],
  "user": {
    "id": "customer_123",
    "email": null,
    "groupIds": [
      "team_42"
    ],
    "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": "team_42",
    "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": "sed -i 's/5 business days/3 business days/' /workspace/docs/faq.md",
    "status": "completed",
    "stdout": "",
    "stderr": "",
    "truncated": false,
    "exitCode": 0,
    "errorCode": null,
    "fileChanges": [],
    "outputFiles": [],
    "mountChanges": [
      {
        "mountId": "0199a1c4-5b6e-7a10-9c2d-3e4f5a6b7c8d",
        "path": "/workspace/docs",
        "outcome": "saved",
        "reason": null,
        "toolCallId": "c3e1a9f2-4b7d-4e8a-9f10-2a3b4c5d6e7f",
        "changes": [
          {
            "operation": "update",
            "kind": "file",
            "path": "/workspace/docs/faq.md"
          }
        ]
      }
    ],
    "createdAt": "2026-10-10T12:00:00.000Z",
    "completedAt": "2026-10-10T12:00:01.000Z"
  }
}
```

### 200 · Mount changes discarded

Someone rejected the mount's changes. They weren't saved, stderr says why, and the exit code became 1. The session's /workspace files and other mounts are saved as usual.

```json
{
  "toolCalls": [
    {
      "id": "c3e1a9f2-4b7d-4e8a-9f10-2a3b4c5d6e7f",
      "sessionId": "01995e57-0501-76b8-b797-5b24df5b307f",
      "executionId": "01995e57-3027-7557-a233-009ea3dcd8fc",
      "userId": "customer_123",
      "worldId": "01995e56-e2d4-7f19-b691-7bf9af6abdc8",
      "integration": "mounts",
      "integrationName": "Mounts",
      "account": null,
      "connectionSource": "none",
      "group": {
        "id": "team_42",
        "name": "Support team"
      },
      "toolName": "0199a1c4-5b6e-7a10-9c2d-3e4f5a6b7c8d",
      "toolDescription": "/workspace/docs — Product documentation. Answers to customer questions go in faq.md.",
      "toolLabel": "write",
      "arguments": {
        "path": "/workspace/docs",
        "changes": [
          {
            "operation": "update",
            "kind": "file",
            "path": "/workspace/docs/faq.md",
            "size": 37,
            "diff": "--- /workspace/docs/faq.md\n+++ /workspace/docs/faq.md\n@@ -1,3 +1,3 @@\n # FAQ\n \n-Refunds take 5 business days.\n+Refunds take 3 business days.\n"
          }
        ]
      },
      "status": "denied",
      "result": null,
      "error": "Tool call denied",
      "errorCode": null,
      "reason": null,
      "providerApproval": null,
      "hooks": [],
      "createdAt": "2026-10-10T12:00:00.000Z",
      "expiresAt": "2026-10-10T12:15:00.000Z",
      "completedAt": "2026-10-10T12:00:01.000Z",
      "decidedAt": "2026-10-10T12:00:01.000Z"
    }
  ],
  "user": {
    "id": "customer_123",
    "email": null,
    "groupIds": [
      "team_42"
    ],
    "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": "team_42",
    "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": "sed -i 's/5 business days/3 business days/' /workspace/docs/faq.md",
    "status": "completed",
    "stdout": "",
    "stderr": "Changes to /workspace/docs were not saved: a person rejected them.\n",
    "truncated": false,
    "exitCode": 1,
    "errorCode": null,
    "fileChanges": [],
    "outputFiles": [],
    "mountChanges": [
      {
        "mountId": "0199a1c4-5b6e-7a10-9c2d-3e4f5a6b7c8d",
        "path": "/workspace/docs",
        "outcome": "discarded",
        "reason": "a person rejected them",
        "toolCallId": "c3e1a9f2-4b7d-4e8a-9f10-2a3b4c5d6e7f",
        "changes": [
          {
            "operation": "update",
            "kind": "file",
            "path": "/workspace/docs/faq.md"
          }
        ]
      }
    ],
    "createdAt": "2026-10-10T12:00:00.000Z",
    "completedAt": "2026-10-10T12:00:01.000Z"
  }
}
```

### 200 · Session closed

The user was removed from the session's group while the command ran. The command was stopped at once, and the session is closed for good: session.status is closed, closedReason is group_membership_removed, and groupIds no longer lists the group. Start a new session for further commands.

```json
{
  "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": "team_42",
    "status": "closed",
    "closedReason": "group_membership_removed",
    "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": "sleep 30",
    "status": "interrupted",
    "stdout": "",
    "stderr": "This session is closed because the user left its group or the group was deleted. Start a new session.",
    "truncated": false,
    "exitCode": null,
    "errorCode": "session_closed",
    "fileChanges": null,
    "outputFiles": null,
    "mountChanges": null,
    "createdAt": "2026-10-10T12:00:00.000Z",
    "completedAt": "2026-10-10T12:00:01.000Z"
  }
}
```

### 400

invalid_request: A parameter is invalid; the message names the problem. Unknown query parameters are rejected.

#### invalid_request

A parameter is invalid; the message names the problem. Unknown query parameters are rejected.

```json
{
  "statusCode": 400,
  "code": "invalid_request",
  "message": "Unknown query parameter: color"
}
```

### 401

authentication_required: The Authorization header is missing or empty. invalid_api_key: The API key is invalid or revoked, or the header doesn't use the Bearer scheme.

#### authentication_required

The Authorization header is missing or empty.

```json
{
  "statusCode": 401,
  "code": "authentication_required",
  "message": "Authentication is required"
}
```

#### invalid_api_key

The API key is invalid or revoked, or the header doesn't use the Bearer scheme.

```json
{
  "statusCode": 401,
  "code": "invalid_api_key",
  "message": "The API key is invalid or revoked"
}
```

### 403

ip_not_allowed: The request came from an address outside the workspace's IP allowlist.

#### ip_not_allowed

The request came from an address outside the workspace's IP allowlist.

```json
{
  "statusCode": 403,
  "code": "ip_not_allowed",
  "message": "The source IP address is not allowed by this account's security settings"
}
```

### 404

execution_not_found: The execution does not exist in your workspace.

#### execution_not_found

The execution does not exist in your workspace.

```json
{
  "statusCode": 404,
  "code": "execution_not_found",
  "message": "Execution not found"
}
```

### 500

internal_error: An unexpected server error.

#### internal_error

An unexpected server error.

```json
{
  "statusCode": 500,
  "code": "internal_error",
  "message": "Internal server error"
}
```

## Notes

- 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.
