> For the complete documentation index, see [llms.txt](https://docs.unitlab.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.unitlab.ai/api-sdk-cli/de/apis/annotations-and-workflow-api.md).

# API für Annotationen und Workflow

Unitlab-API für Annotationen und Workflow: per HTTP Stages und Aufgaben lesen, Aufgabenaktionen ausführen, Annotationen speichern und Labeldateien importieren.

Alle Routen liegen unter `https://api.unitlab.ai/api/sdk/`.

## Stages und Aufgaben <a href="#stages-and-tasks" id="stages-and-tasks"></a>

| Methode und Route                                  | Body                                                             | Berechtigung                            |
| -------------------------------------------------- | ---------------------------------------------------------------- | --------------------------------------- |
| `GET projects/{id}/workflow/stages/`               |                                                                  | Assign project members oder Manage data |
| `GET projects/{id}/workflow/stages/{stage}/tasks/` | Query: `include_unavailable=1`, `limit`, `offset`                | Wie oben                                |
| `GET workflow-tasks/{task}/`                       |                                                                  | View labeling interface                 |
| `POST workflow-tasks/{task}/claim/`                |                                                                  | View labeling interface, Create labels  |
| `POST workflow-tasks/{task}/assign/`               | `{"user_id"}`                                                    | Assign project members oder Manage data |
| `POST workflow-tasks/{task}/release/`              |                                                                  | Wie oben                                |
| `POST workflow-tasks/{task}/priority/`             | `{"priority": 5}`                                                | Wie oben                                |
| `POST workflow-tasks/{task}/move/`                 | `{"stage_id", "reason", "expected_stage_id", "idempotency_key"}` | Wie oben                                |
| `POST workflow-tasks/{task}/actions/`              | Siehe unten                                                      | Create labels, Manage data              |
| `GET workflow-tasks/{task}/timeline/`              |                                                                  | View labeling interface, Manage data    |
| `POST projects/{id}/workflow/tasks/assign/`        | `{"task_ids", "user_id"}`, bis zu 500                            | Assign project members oder Manage data |
| `POST projects/{id}/workflow/tasks/move/`          | `{"task_ids", "stage_id", "reason", "dry_run"}`, bis zu 500      | Wie oben                                |

`{stage}` ist die Stage-ID aus der Stage-Liste, etwa `annotate`.

### Aufgabenaktionen <a href="#task-actions" id="task-actions"></a>

```bash
curl -s -X POST "https://api.unitlab.ai/api/sdk/workflow-tasks/$TASK_ID/actions/" \
  -H "Authorization: Api-Key $UNITLAB_API_KEY" -H "Content-Type: application/json" \
  -d '{"action": "reject", "rejection_reason": "Box misses the gripper", "comment": "Frames 40 to 55",
       "expected_stage_id": "review", "idempotency_key": "7b0c6f1e-2f4e-4a51-9e0b-1f3d2c9a8e77"}'
```

| `action`   | Wirkung                                   |
| ---------- | ----------------------------------------- |
| `complete` | Über die Vorwärtskante einreichen         |
| `approve`  | Eine Review-Aufgabe genehmigen            |
| `reject`   | Über die Rückweisungskante zurückschicken |
| `skip`     | Über die Skip-Kante weitergeben           |

`expected_stage_id` lehnt die Aktion ab, wenn sich die Aufgabe seit Ihrem Lesen bewegt hat. Ein wiederholter `idempotency_key` wird nicht doppelt ausgeführt. Verwenden Sie pro beabsichtigter Aktion eine neue UUID und nutzen Sie sie nur zum Wiederholen derselben Aktion erneut.

## Aufgabenannotationen <a href="#task-annotations" id="task-annotations"></a>

| Methode und Route                                            | Body                                                                                                                                                 |
| ------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GET workflow-tasks/{task}/annotations/?only_keyframes=true` | Zeilen mit `document` (UUEF) oder `document_url` bei großen Dokumenten                                                                               |
| `PUT workflow-tasks/{task}/annotations/`                     | `{"datasource_id", "format": "uuef" \| "geojson" \| "model", "document"}`                                                                            |
| `POST workflow-tasks/{task}/annotations/uploads/`            | `{"datasource_id", "format", "size"}` für Dokumente über 64 MiB; das JSON per PUT an `upload_url` senden und dann mit `document_upload_id` speichern |
| `POST workflow-tasks/{task}/agent-result/`                   | `{"run_id", "status": "complete"}` oder `{"run_id", "status": "failed", "error"}`                                                                    |
| `POST workflow-tasks/{task}/model-result/`                   | `{"run_id", "status", "result" or "results", "model_version"}`                                                                                       |

Ein Speichern ersetzt das gesamte Element und funktioniert nur, solange sich die Aufgabe in einer Agent-Stage befindet. Regeln und LiDAR-Variante: [Aufgabenannotationen und Agent-Webhooks](https://docs.unitlab.ai/api-sdk-cli/de/sdks/task-annotations-and-agent-webhooks.md). Dokumentstrukturen: [Annotation-JSON-Referenz](https://docs.unitlab.ai/api-sdk-cli/de/apis/annotation-json-reference.md).

## Annotationsimporte <a href="#annotation-imports" id="annotation-imports"></a>

| Methode und Route                                        | Funktion                                             |
| -------------------------------------------------------- | ---------------------------------------------------- |
| `POST projects/{id}/annotation-imports/`                 | Eine Labeldatei hochladen und eine Vorschau erhalten |
| `POST projects/{id}/annotation-imports/{batch}/preview/` | Erneute Vorschau mit neuen Optionen                  |
| `POST projects/{id}/annotation-imports/{batch}/commit/`  | Speichern: `{"token", "decisions", "allow_partial"}` |
| `GET projects/{id}/annotation-imports/sources/`          | Gespeicherte Label-Quellen                           |
| `GET projects/{id}/annotation-imports/media/?search=`    | Medienkandidaten für Zuordnungen                     |

```bash
curl -s -X POST "https://api.unitlab.ai/api/sdk/projects/$PROJECT_ID/annotation-imports/" \
  -H "Authorization: Api-Key $UNITLAB_API_KEY" \
  -F "annotation_file=@detector-v3.json;type=application/json" \
  --form-string "source_name=detector-v3" \
  --form-string "track_profile=none" \
  --form-string 'options={}'
```

Die Antwort ist die Vorschau mit `batch_id`, `counts`, `issues`, `annotations` und einem `token`. Committen Sie mit diesem Token. Ein wiederholter Commit liefert den gespeicherten Bericht, ohne Labels zu duplizieren. Erfordert **Manage data** und **Create labels** sowie einen von einem Workspace-Mitglied erstellten Schlüssel. Formate und Optionen: [Annotationen importieren](https://docs.unitlab.ai/api-sdk-cli/de/sdks/annotation-imports.md).

## Benchmarks <a href="#benchmarks" id="benchmarks"></a>

```bash
curl -s -X POST "https://api.unitlab.ai/api/sdk/projects/$PROJECT_ID/benchmarks/" \
  -H "Authorization: Api-Key $UNITLAB_API_KEY" -H "Content-Type: application/json" \
  -d '{"datasource_ids": ["DATASOURCE_ID"], "when_ready": true}'
```

Senden Sie bis zu 100 IDs pro Anfrage. Die Antwort zählt `created`, `existing`, `deferred` und `skipped_by_reason`. Siehe [Benchmarks](https://docs.unitlab.ai/api-sdk-cli/de/sdks/benchmarks.md).

## Verwandte Themen <a href="#related" id="related"></a>

[SDK: Workflow-Stages und Aufgaben](https://docs.unitlab.ai/api-sdk-cli/de/sdks/workflow-stages-and-tasks.md) · [Fehler, Rate Limits und Paginierung](https://docs.unitlab.ai/api-sdk-cli/de/apis/errors-rate-limits-and-pagination.md)
