> ## Documentation Index
> Fetch the complete documentation index at: https://api-reference.scale.com/llms.txt
> Use this file to discover all available pages before exploring further.

# DataCollectionV2 Tasks

> Create data collection tasks with TaskType.DataCollectionV2

Create a data collection task with `POST /v1/task/datacollectionv2`, authenticated with your Scale API key. The body is JSON, and `upload_type` determines which attachment fields are required and which are allowed. Any top-level field that is not part of the upload type's schema is rejected.

On success, the endpoint returns `200` with the task object and starts the task's processing pipeline.

## Upload types

| `upload_type` | Required attachments | Optional attachments |
| - | - | - |
| `video-annotation` | `video_attachment` (array of [video items](#video-item)) | `duration_seconds` |
| `sfs-annotation` | `sfs_attachment` (URL to a Sensor Fusion Scene) | None |

All URL fields accept `s3://`, `gs://`, and `https://` URLs.

### Video item

Each entry in `video_attachment` requires all of the following fields:

| Field | Type | Description |
| - | - | - |
| `url` | URL | Location of the video file. |
| `sensor_id` | string | Identifier of the camera that recorded the video. |
| `name` | string | Display name for the video. |

> [!NOTE]
>
> `sfs-annotation` tasks require the project to be configured with the right processing steps. If it is not, the request returns `400` with `Project is not set up for upload_type`. Ask your Scale contact to set this up.

## Request parameters

These fields are shared by both upload types, in addition to the attachment fields above.

**Body Params** `object`

**upload\_type** `string` *required*

One of `video-annotation` or `sfs-annotation`. See [Upload types](#upload-types).

**project** `string` *required*

The project name (not its ID). It must be a `datacollectionv2` project owned by the account of the API key.

**metadata** `object` *required*

Free-form metadata stored on the task. `metadata.id` is used as the recording ID for [deduplication](#duplicates-and-retries).

**instruction** `string`

Task instructions shown to annotators.

**annotation\_definitions** `array of objects`

Annotation definitions to use for labeling. Defaults to the project's taxonomy.

**hypothesis** `string`

URL of pre-labels to load into the task.

**calibration\_results** `string`

URL of a calibration file for the recording.

**unique\_id** `string`

Rejects a second task with the same ID in the project.

**batch\_id** `string`

Adds the task to an existing batch by ID. Takes precedence over `batch_name`.

**batch\_name** `string`

Adds the task to an existing batch by name. `batch` is accepted as an alias.

## Example

```python Python SDK theme={null}
import scaleapi
from scaleapi.tasks import TaskType

client = scaleapi.ScaleClient("YOUR_API_KEY_HERE")

payload = dict(
    project = "test_project",
    upload_type = "video-annotation",
    video_attachment = [
        {"url": "s3://bucket/left.mp4", "sensor_id": "left", "name": "left"},
    ],
    hypothesis = "s3://bucket/prelabels.sfs",  # optional
    metadata = {"id": "recording-0001"},
)

task = client.create_task(TaskType.DataCollectionV2, **payload)

# If the task's processing pipeline fails to start, the request still succeeds
# and the task comes back with an "error" status.
if task.status == "error":
    print(task.as_dict())
```

```bash cURL theme={null}
curl -X POST https://api.scale.com/v1/task/datacollectionv2 \
  -u "$SCALE_API_KEY:" \
  -H "Content-Type: application/json" \
  -d '{
    "upload_type": "video-annotation",
    "project": "test_project",
    "metadata": { "id": "recording-0001" },
    "video_attachment": [
      { "sensor_id": "left", "name": "left", "url": "s3://bucket/left.mp4" }
    ],
    "hypothesis": "s3://bucket/prelabels.sfs"
  }'
```

The response is the task object, in the same format as `GET /v1/task/:id`. Store its `task_id` and check its `status`.

## Errors

* **Invalid payload:** the payload is validated before the task is saved. A bad payload returns `400` and no task is created. When required fields are missing, the error lists them; otherwise it reports only the first problem.
* **Pipeline failure:** if the task's processing pipeline fails to start, the request still returns `200`, but the task's `status` is `error`.

## Duplicates and retries

* `metadata.id` (or `metadata.recordingId`) is the recording ID. A second request for the same recording in the same project returns the existing task instead of creating a new one.
* If a request for the same recording is still in progress, the call fails with `Another process is creating a task for this recording, please retry`. Retry after a short wait; a stuck request expires after 2 minutes.
