# Async Tasks

Some REST API endpoints start long-running work and return an async task instead of waiting for the work to finish. These endpoints return a `taskId` and a polling `url`:

```json
{
    "taskId": "abc123",
    "url": "https://api.roboflow.com/my-workspace/asynctasks/abc123"
}
```

Use the polling URL to check whether the task is still running, completed, or failed.

## Get Task Status

Send a `GET` request to `/:workspace/asynctasks/:id`. Replace `:workspace` with the Workspace that owns the task and `:id` with the returned `taskId`.

```bash
$ curl --location "https://api.roboflow.com/my-workspace/asynctasks/abc123?api_key=$ROBOFLOW_API_KEY"
```

The API key must have access to the same Workspace used in the request path. Tasks from other Workspaces return `404`.

## Response Fields

```
- taskId (string) - The async task ID.
- status (string) - The current task status. Common statuses are created, running, completed, and failed. Terminal statuses are completed and failed.
- progress (object or null) - Task progress when available, in the form `{ "current": <number>, "total": <number> }`.
- result (object) - Present when the task completed successfully.
- error (string) - Present when the task failed.
```

## Running Task

```json
{
    "taskId": "abc123",
    "status": "running",
    "progress": {
        "current": 42,
        "total": 100
    }
}
```

## Completed Task

The `result` object depends on the endpoint that created the task. For example, a completed Universe Project fork returns the forked Project details:

```json
{
    "taskId": "abc123",
    "status": "completed",
    "progress": {
        "current": 100,
        "total": 100
    },
    "result": {
        "forked": true,
        "datasetUrl": "football-players-detection-3zvbc-a1b2c",
        "id": "my-workspace/football-players-detection-3zvbc-a1b2c",
        "name": "Football Players Detection",
        "url": "https://app.roboflow.com/my-workspace/football-players-detection-3zvbc-a1b2c"
    }
}
```

## Failed Task

```json
{
    "taskId": "abc123",
    "status": "failed",
    "progress": {
        "current": 64,
        "total": 100
    },
    "error": "Task failed"
}
```

## Errors

```
- 404 - The async task does not exist or belongs to another Workspace.
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.roboflow.com/developer/rest-api/async-tasks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
