> ## Documentation Index
> Fetch the complete documentation index at: https://open.manus.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Task Lifecycle

> Poll task status, handle confirmations, and process results

<sup>Questions or issues? Contact us at [api-support@manus.ai](mailto:api-support@manus.ai).</sup>

After creating a task with [task.create](https://open.manus.ai/docs/v2/task.create.md), the agent runs asynchronously. Use [task.listMessages](https://open.manus.ai/docs/v2/task.listMessages.md) to poll for events and track progress. Also read [task.detail](https://open.manus.ai/docs/v2/task.detail.md) before treating a stopped Agent run as complete, because background work can continue independently. For push delivery, set up [Webhooks](https://open.manus.ai/docs/v2/webhooks-overview.md).

```bash theme={null}
curl 'https://api.manus.ai/v2/task.listMessages?task_id=YOUR_TASK_ID&order=desc&limit=10' \
  -H 'x-manus-api-key: YOUR_API_KEY'
```

## Task status

Look for `status_update` events in the response. The `agent_status` field tells you what to do next:

| agent\_status | Meaning | Action |
| - | - | - |
| `running` | Agent is working | Keep polling |
| `stopped` | The main Agent stopped | Read the results |
| `waiting` | Needs user confirmation or input | Handle based on event type (see below) |
| `error` | Task failed | Read `error_message` for details |

`stopped` is not always final. When [task.detail](https://open.manus.ai/docs/v2/task.detail.md) reports `has_running_background_jobs: true`, a background process may wake the task again later, add messages, and change the results. Keep polling if you want them. A later message, schedule, or trigger can also start the same Task again.

## Handling `waiting` status

Read `status_detail.waiting_for_event_type`. It falls into one of three cases:

| Event type | Respond with |
| - | - |
| `messageAskUser`, `cascadeAskUser` — the agent asks a question | [task.sendMessage](https://open.manus.ai/docs/v2/task.sendMessage.md). See [Answer an agent question](#answer-an-agent-question). Do **not** use `task.confirmAction`. |
| An action confirmation (see [Confirmation Events](https://open.manus.ai/docs/v2/task-lifecycle/confirmation-events.md)) | [task.confirmAction](https://open.manus.ai/docs/v2/task.confirmAction.md) after reviewing the target event. See [Confirm an action](#confirm-an-action). |
| Any other type, or `status_detail` / `waiting_for_event_id` missing | Fallback: [resume without a decision](#resume-without-a-decision), or direct a person to decide in Manus. |

Sending any ordinary message while an action confirmation is pending skips that action; the agent continues from your message. No schema-specific input is needed.

### Answer an agent question

A free-text question is answered with plain text. When the agent supplies choices, the corresponding `assistant_message` includes a `question_expectation` object:

```json theme={null}
{
  "id": "ask_abc123",
  "type": "assistant_message",
  "assistant_message": {
    "content": "Which formats should I export?",
    "question_expectation": {
      "options": ["PDF", "DOCX"],
      "selection_mode": "multiple",
      "response_method": "send_message"
    }
  }
}
```

| Field | Meaning |
| - | - |
| `options` | Display text of the choices. Not option IDs, and not an enforced answer schema. Non-empty when present in `task.listMessages`. |
| `selection_mode` | `single` or `multiple`. Render the matching choice control, and still allow a free-text answer. |
| `response_method` | Currently fixed to `send_message`. Never `task.confirmAction`. |
| `event_id` | Webhooks only. Identifies the question event; differs from the webhook envelope `event_id`, which identifies the notification. Not a reply parameter. In `task.listMessages`, use the enclosing message's `id`. |

To answer:

1. Collect the user's selection or free text.
2. Send a non-empty answer as ordinary `message.content` through [task.sendMessage](https://open.manus.ai/docs/v2/task.sendMessage.md). For multiple choices, combine the selected text into one readable message. There is no required delimiter, option-ID array, or structured submission format.
3. Do not submit an empty answer when nothing is selected; ask the user for text instead.

Example answer:

```json theme={null}
{
  "task_id": "task_abc123",
  "message": { "content": "Please export both PDF and DOCX." }
}
```

### Confirm an action

When an action needs confirmation, the waiting `status_detail` gives its target event ID and the expected input schema:

```json theme={null}
{
    "type": "status_update",
    "status_update": {
        "agent_status": "waiting",
        "status_detail": {
            "waiting_for_event_id": "R0ayNknItM38cc6a2DbB4W",
            "waiting_for_event_type": "gmailSendAction",
            "waiting_description": "Send email to user@example.com",
            "confirm_input_schema": {
                "type": "object",
                "properties": {
                    "accept": { "type": "boolean" },
                    "save_draft": { "type": "boolean" }
                },
                "required": ["accept"]
            }
        }
    }
}
```

The waiting event tells you how to respond. The event identified by `waiting_for_event_id` tells you what the user is approving. If that event is not in the current response window, fetch it explicitly:

```bash theme={null}
curl 'https://api.manus.ai/v2/task.listMessages?task_id=YOUR_TASK_ID&verbose=true&start_event_id=R0ayNknItM38cc6a2DbB4W' \
  -H 'x-manus-api-key: YOUR_API_KEY'
```

The referenced Gmail event contains the structured tool input:

```json theme={null}
{
  "id": "R0ayNknItM38cc6a2DbB4W",
  "type": "tool_used",
  "tool_used": {
    "tool": "gmail",
    "action_id": "X0SCXV59huUdjxubJrOYyx",
    "status": "success",
    "brief": "Manus is preparing Gmail message",
    "description": "Preparing Gmail messages",
    "message": {
      "action": "Preparing Gmail messages"
    },
    "params": {
      "messages": [{
        "to": ["user@example.com"],
        "cc": [],
        "bcc": [],
        "subject": "Project update",
        "content": "The complete email body",
        "attachments": []
      }]
    }
  }
}
```

Use `R0ayNknItM38cc6a2DbB4W` as `task.confirmAction.event_id`. `X0SCXV59huUdjxubJrOYyx` is the tool action ID, not the event ID.

What the target event exposes depends on `waiting_for_event_type`. Most confirmations come from a tool call, so the target is a `tool_used` event with the original structured `params`; result-driven confirmations also expose a structured `result`. Some confirmations expose their text only in `waiting_description`, and a few expose only the event type and `confirm_input_schema`. Each entry in [Confirmation Events](https://open.manus.ai/docs/v2/task-lifecycle/confirmation-events.md) gives the source for its type. When the target gives you nothing you can act on, use the [fallback](#resume-without-a-decision).

Fetching the target event:

* `tool_used` events normally require `verbose=true`.
* A waiting status does not force its target event into the current page. Use `verbose=true` with `start_event_id=waiting_for_event_id` when the target is outside the current response window.
* When an entry's **Context** is **None**, `start_event_id` returns no target event. Decide from `waiting_for_event_type` and `confirm_input_schema`.

#### Using `task.confirmAction`

```bash theme={null}
curl -X POST 'https://api.manus.ai/v2/task.confirmAction' \
  -H 'x-manus-api-key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "task_id": "YOUR_TASK_ID",
    "event_id": "R0ayNknItM38cc6a2DbB4W",
    "input": { "accept": true }
  }'
```

The `input` format varies by `waiting_for_event_type`. Build it according to `confirm_input_schema`; fields outside the schema are ignored. Use the referenced tool params and result to explain the operation and populate schema fields when applicable. `confirmed: false` means the event did not consume the input and the task is still waiting.

> [card] [Confirmation Events](https://open.manus.ai/docs/v2/task-lifecycle/confirmation-events.md)
>
> Every event type that accepts `task.confirmAction`, with its input schema, accepted inputs, and target event. Use it to build your own confirmation UI.

### Resume without a decision

This is the fallback when `status_detail` or `waiting_for_event_id` is missing, the event type is not one you handle, or the target event gives you nothing to act on. Either direct a person to open the task in Manus, or send this message so the agent picks sensible defaults for the pending step and keeps going:

```json theme={null}
{
  "task_id": "task_abc123",
  "message": { "content": "Continue and use your best judgment." }
}
```

Any wording that tells the agent to proceed works. For most action confirmations this skips the pending action; the agent decides how to proceed from your message.

## Using My Browser

You can let the agent use your local browser. When the agent needs a browser during execution, it will trigger a `needConnectMyBrowser` waiting event. Use [browser.onlineList](https://open.manus.ai/docs/v2/browser.onlineList.md) to get available clients, then select one via [task.confirmAction](https://open.manus.ai/docs/v2/task.confirmAction.md):

```bash theme={null}
# 1. Get online browser clients
curl 'https://api.manus.ai/v2/browser.onlineList' \
  -H 'x-manus-api-key: YOUR_API_KEY'

# 2. When needConnectMyBrowser event is received, select a browser
curl -X POST 'https://api.manus.ai/v2/task.confirmAction' \
  -H 'x-manus-api-key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "task_id": "YOUR_TASK_ID",
    "event_id": "evt_abc123",
    "input": { "action": "select", "client_id": "0e9ad711-8471-4fcc-a9de-8309f0f12c87" }
  }'
```

> [!WARNING]
>
> If `browser.onlineList` returns an empty list, no browser clients are online. Install and enable the [Manus Browser Extension](https://manus.im) first.

## Complete flow

```
1. POST /v2/task.create          → Create task (optionally with structured_output_schema)
2. GET  /v2/task.listMessages    → Poll for events
   ├─ agent_status=running       → Keep polling
   ├─ agent_status=waiting       → Check waiting_for_event_type
   │   ├─ messageAskUser / cascadeAskUser → POST /v2/task.sendMessage
   │   ├─ Action confirmation         → POST /v2/task.confirmAction
   │   └─ Other / missing detail     → Fallback: resume without a decision, or open in Manus
   ├─ agent_status=stopped       → Read results
   │   ├─ structured_output_result → Extracted JSON (if schema was provided)
   │   └─ task.detail.has_running_background_jobs=true → Background work may wake the task again; keep polling
   └─ agent_status=error         → Task failed, read error details
```

> [!TIP]
>
> **Structured Output:** If you need the result in a specific JSON format, pass `structured_output_schema` when creating the task. See the [Structured Output](https://open.manus.ai/docs/v2/structured-output.md) guide.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.