> 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/fr/apis/annotations-and-workflow-api.md).

# API des annotations et du workflow

Lisez les étapes et tâches de workflow, exécutez des actions, lisez et enregistrez des annotations, importez des labels et marquez des benchmarks en HTTP.

Toutes les routes se trouvent sous `https://api.unitlab.ai/api/sdk/`.

## Étapes et tâches <a href="#stages-and-tasks" id="stages-and-tasks"></a>

| Méthode et route                                   | Corps                                                            | Permission                             |
| -------------------------------------------------- | ---------------------------------------------------------------- | -------------------------------------- |
| `GET projects/{id}/workflow/stages/`               |                                                                  | Assign project members ou Manage data  |
| `GET projects/{id}/workflow/stages/{stage}/tasks/` | Requête : `include_unavailable=1`, `limit`, `offset`             | Identique                              |
| `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 ou Manage data  |
| `POST workflow-tasks/{task}/release/`              |                                                                  | Identique                              |
| `POST workflow-tasks/{task}/priority/`             | `{"priority": 5}`                                                | Identique                              |
| `POST workflow-tasks/{task}/move/`                 | `{"stage_id", "reason", "expected_stage_id", "idempotency_key"}` | Identique                              |
| `POST workflow-tasks/{task}/actions/`              | Voir ci-dessous                                                  | Create labels, Manage data             |
| `GET workflow-tasks/{task}/timeline/`              |                                                                  | View labeling interface, Manage data   |
| `POST projects/{id}/workflow/tasks/assign/`        | `{"task_ids", "user_id"}`, jusqu'à 500                           | Assign project members ou Manage data  |
| `POST projects/{id}/workflow/tasks/move/`          | `{"task_ids", "stage_id", "reason", "dry_run"}`, jusqu'à 500     | Identique                              |

`{stage}` est l'ID de l'étape issu de la liste des étapes, par exemple `annotate`.

### Actions sur les tâches <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`   | Effet                              |
| ---------- | ---------------------------------- |
| `complete` | Soumet par la transition suivante  |
| `approve`  | Approuve une tâche de revue        |
| `reject`   | Renvoie par la transition de rejet |
| `skip`     | Envoie par la transition de saut   |

`expected_stage_id` refuse l'action si la tâche a changé d'étape depuis votre lecture. Une `idempotency_key` répétée n'est pas exécutée deux fois. Utilisez un nouvel UUID par action voulue, et ne le réutilisez que pour relancer cette même action.

## Annotations des tâches <a href="#task-annotations" id="task-annotations"></a>

| Méthode et route                                             | Corps                                                                                                                                                             |
| ------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GET workflow-tasks/{task}/annotations/?only_keyframes=true` | Lignes avec `document` (UUEF), ou `document_url` pour un document volumineux                                                                                      |
| `PUT workflow-tasks/{task}/annotations/`                     | `{"datasource_id", "format": "uuef" \| "geojson" \| "model", "document"}`                                                                                         |
| `POST workflow-tasks/{task}/annotations/uploads/`            | `{"datasource_id", "format", "size"}` pour les documents de plus de 64 Mio ; envoyez le JSON en PUT vers `upload_url`, puis enregistrez avec `document_upload_id` |
| `POST workflow-tasks/{task}/agent-result/`                   | `{"run_id", "status": "complete"}` ou `{"run_id", "status": "failed", "error"}`                                                                                   |
| `POST workflow-tasks/{task}/model-result/`                   | `{"run_id", "status", "result" or "results", "model_version"}`                                                                                                    |

Un enregistrement remplace l'élément entier et ne fonctionne que lorsque la tâche se trouve dans une étape Agent. Règles et variante LiDAR : [Annotations de tâches et webhooks Agent](https://docs.unitlab.ai/api-sdk-cli/fr/sdks/task-annotations-and-agent-webhooks.md). Structure des documents : [Référence du JSON d'annotation](https://docs.unitlab.ai/api-sdk-cli/fr/apis/annotation-json-reference.md).

## Imports d'annotations <a href="#annotation-imports" id="annotation-imports"></a>

| Méthode et route                                         | Rôle                                                    |
| -------------------------------------------------------- | ------------------------------------------------------- |
| `POST projects/{id}/annotation-imports/`                 | Uploader un fichier de labels et obtenir un aperçu      |
| `POST projects/{id}/annotation-imports/{batch}/preview/` | Refaire l'aperçu avec de nouvelles options              |
| `POST projects/{id}/annotation-imports/{batch}/commit/`  | Enregistrer : `{"token", "decisions", "allow_partial"}` |
| `GET projects/{id}/annotation-imports/sources/`          | Sources de labels enregistrées                          |
| `GET projects/{id}/annotation-imports/media/?search=`    | Médias candidats pour les correspondances               |

```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={}'
```

La réponse est l'aperçu, avec `batch_id`, `counts`, `issues`, `annotations` et un `token`. Faites le commit avec ce token. Répéter un commit renvoie le rapport enregistré sans dupliquer les labels. Exige **Manage data** et **Create labels**, ainsi qu'une clé créée par un membre de l'espace de travail. Formats et options : [Imports d'annotations](https://docs.unitlab.ai/api-sdk-cli/fr/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}'
```

Envoyez jusqu'à 100 ID par requête. La réponse compte `created`, `existing`, `deferred` et `skipped_by_reason`. Voir [Benchmarks](https://docs.unitlab.ai/api-sdk-cli/fr/sdks/benchmarks.md).

## Voir aussi <a href="#related" id="related"></a>

[SDK : étapes et tâches de workflow](https://docs.unitlab.ai/api-sdk-cli/fr/sdks/workflow-stages-and-tasks.md) · [Erreurs, limites de débit et pagination](https://docs.unitlab.ai/api-sdk-cli/fr/apis/errors-rate-limits-and-pagination.md)
