Async Tasks

How to poll long-running REST API operations that return a task ID, and read running, completed, or failed statuses.

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:

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

$ 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

{
    "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:

{
    "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

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