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

# Get task result

> Retrieve the current status and result of a Ninja task.

Retrieves the current status and result of a task. Supports long-polling when the task is `in_progress`.

## Request parameters

<ParamField query="taskId" type="string" required>
  UUID of the task returned from the [create endpoint](/ninja/create-task).
</ParamField>

<ParamField query="wait" type="string" default="0">
  Set to `1` to enable long-polling. When the task is `in_progress`, the request blocks until the task completes or the request times out. For tasks in any other status (`pending`, `completed`,
  `failed`, etc), this parameter has no effect and the request returns immediately.

  | Value | Description                                                   |
  | ----- | ------------------------------------------------------------- |
  | `0`   | Return immediately with the current status. **(default)**     |
  | `1`   | Long-poll until the task completes (only when `in_progress`). |
</ParamField>

## Response fields

<ResponseField name="taskId" type="string" required>
  UUID of the task.
</ResponseField>

<ResponseField name="status" type="string" required>
  Current task status. One of: `pending`, `in_progress`, `completed`, `failed`, `cancelled`, `paused`, `stopped`, `impossible`, `out_of_credits`. See [task statuses](/ninja/ninja-api#task-statuses).
</ResponseField>

<ResponseField name="result" type="object | string | null" required>
  The task result. Present when `status` is `completed`. If a `resultSchema` was provided at creation, this is a JSON object conforming to that schema; otherwise it is a plain text string. `null` for
  all other statuses.
</ResponseField>

<ResponseField name="error" type="string | null" required>
  Error message when `status` is `failed`. `null` for all other statuses.
</ResponseField>

<RequestExample>
  ```bash Poll immediately theme={null}
  curl "https://ninja.new/v0/api/task/result?taskId=550e8400-e29b-41d4-a716-446655440000" \
    -H "Authorization: Bearer nsk_your_api_key"
  ```

  ```bash Long-poll (waits when in_progress) theme={null}
  curl "https://ninja.new/v0/api/task/result?taskId=550e8400-e29b-41d4-a716-446655440000&wait=1" \
    -H "Authorization: Bearer nsk_your_api_key"
  ```
</RequestExample>

<ResponseExample>
  ```json Completed (plain text) theme={null}
  {
    "taskId": "550e8400-e29b-41d4-a716-446655440000",
    "status": "completed",
    "result": "Shopify's top 3 competitors are BigCommerce, WooCommerce, and Wix.",
    "error": null
  }
  ```

  ```json Completed (structured output) theme={null}
  {
    "taskId": "550e8400-e29b-41d4-a716-446655440000",
    "status": "completed",
    "result": {
      "competitors": [
        { "name": "BigCommerce", "estimatedAnnualRevenue": "$300M" },
        { "name": "WooCommerce", "estimatedAnnualRevenue": "$500M" },
        { "name": "Wix", "estimatedAnnualRevenue": "$1.6B" }
      ]
    },
    "error": null
  }
  ```

  ```json Pending theme={null}
  {
    "taskId": "550e8400-e29b-41d4-a716-446655440000",
    "status": "pending",
    "result": null,
    "error": null
  }
  ```
</ResponseExample>
