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

# 어노테이션과 워크플로 API

Unitlab HTTP API로 워크플로 단계와 작업을 조회하고, 작업 동작을 실행하고, 어노테이션을 읽고 저장하고, 라벨 파일을 가져오고 벤치마크를 지정하는 방법입니다.

모든 라우트는 `https://api.unitlab.ai/api/sdk/` 아래에 있습니다.

## 단계와 작업 <a href="#stages-and-tasks" id="stages-and-tasks"></a>

| 메서드와 라우트                                           | 본문                                                               | 권한                                     |
| -------------------------------------------------- | ---------------------------------------------------------------- | -------------------------------------- |
| `GET projects/{id}/workflow/stages/`               |                                                                  | Assign project members 또는 Manage data  |
| `GET projects/{id}/workflow/stages/{stage}/tasks/` | 쿼리: `include_unavailable=1`, `limit`, `offset`                   | 위와 동일                                  |
| `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 또는 Manage data  |
| `POST workflow-tasks/{task}/release/`              |                                                                  | 위와 동일                                  |
| `POST workflow-tasks/{task}/priority/`             | `{"priority": 5}`                                                | 위와 동일                                  |
| `POST workflow-tasks/{task}/move/`                 | `{"stage_id", "reason", "expected_stage_id", "idempotency_key"}` | 위와 동일                                  |
| `POST workflow-tasks/{task}/actions/`              | 아래 참조                                                            | Create labels, Manage data             |
| `GET workflow-tasks/{task}/timeline/`              |                                                                  | View labeling interface, Manage data   |
| `POST projects/{id}/workflow/tasks/assign/`        | `{"task_ids", "user_id"}`, 최대 500개                               | Assign project members 또는 Manage data  |
| `POST projects/{id}/workflow/tasks/move/`          | `{"task_ids", "stage_id", "reason", "dry_run"}`, 최대 500개         | 위와 동일                                  |

`{stage}`는 단계 목록의 단계 ID(예: `annotate`)입니다.

### 작업 동작 <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`   | 효과            |
| ---------- | ------------- |
| `complete` | 순방향 경로로 제출    |
| `approve`  | Review 작업 승인  |
| `reject`   | 반려 경로로 되돌려 보냄 |
| `skip`     | 건너뛰기 경로로 보냄   |

`expected_stage_id`를 지정하면 작업을 읽은 뒤 작업이 다른 단계로 이동한 경우 동작이 거부됩니다. 같은 `idempotency_key`로 반복한 요청은 두 번 실행되지 않습니다. 의도한 동작마다 새 UUID를 사용하고, 같은 동작을 재시도할 때만 재사용하세요.

## 작업 어노테이션 <a href="#task-annotations" id="task-annotations"></a>

| 메서드와 라우트                                                     | 본문                                                                                                        |
| ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------- |
| `GET workflow-tasks/{task}/annotations/?only_keyframes=true` | `document`(UUEF)를 담은 행. 큰 문서는 `document_url`                                                              |
| `PUT workflow-tasks/{task}/annotations/`                     | `{"datasource_id", "format": "uuef" \| "geojson" \| "model", "document"}`                                 |
| `POST workflow-tasks/{task}/annotations/uploads/`            | 64 MiB를 넘는 문서용 `{"datasource_id", "format", "size"}`. JSON을 `upload_url`에 PUT한 뒤 `document_upload_id`로 저장 |
| `POST workflow-tasks/{task}/agent-result/`                   | `{"run_id", "status": "complete"}` 또는 `{"run_id", "status": "failed", "error"}`                           |
| `POST workflow-tasks/{task}/model-result/`                   | `{"run_id", "status", "result" or "results", "model_version"}`                                            |

저장은 항목 전체를 교체하며, 작업이 Agent 단계에 있을 때만 동작합니다. 규칙과 LiDAR 변형: [작업 어노테이션과 Agent 웹훅](https://docs.unitlab.ai/api-sdk-cli/ko/sdks/task-annotations-and-agent-webhooks.md). 문서 형태: [어노테이션 JSON 레퍼런스](https://docs.unitlab.ai/api-sdk-cli/ko/apis/annotation-json-reference.md).

## 어노테이션 가져오기 <a href="#annotation-imports" id="annotation-imports"></a>

| 메서드와 라우트                                                 | 하는 일                                          |
| -------------------------------------------------------- | --------------------------------------------- |
| `POST projects/{id}/annotation-imports/`                 | 라벨 파일을 업로드하고 미리보기 받기                          |
| `POST projects/{id}/annotation-imports/{batch}/preview/` | 새 옵션으로 다시 미리보기                                |
| `POST projects/{id}/annotation-imports/{batch}/commit/`  | 저장: `{"token", "decisions", "allow_partial"}` |
| `GET projects/{id}/annotation-imports/sources/`          | 저장된 라벨 소스                                     |
| `GET projects/{id}/annotation-imports/media/?search=`    | 매핑에 사용할 미디어 후보                                |

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

응답은 `batch_id`, `counts`, `issues`, `annotations`, `token`을 담은 미리보기입니다. 이 토큰으로 커밋합니다. 커밋을 반복하면 라벨을 중복하지 않고 저장된 보고서를 반환합니다. **Manage data**와 **Create labels** 권한, 그리고 워크스페이스 멤버가 만든 키가 필요합니다. 형식과 옵션: [어노테이션 가져오기](https://docs.unitlab.ai/api-sdk-cli/ko/sdks/annotation-imports.md).

## 벤치마크 <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}'
```

요청당 최대 100개 ID를 보낼 수 있습니다. 응답은 `created`, `existing`, `deferred`, `skipped_by_reason` 건수를 알려 줍니다. [벤치마크](https://docs.unitlab.ai/api-sdk-cli/ko/sdks/benchmarks.md)를 참고하세요.

## 관련 문서 <a href="#related" id="related"></a>

[SDK: 워크플로 단계와 작업](https://docs.unitlab.ai/api-sdk-cli/ko/sdks/workflow-stages-and-tasks.md) · [오류, 요청 한도, 페이지네이션](https://docs.unitlab.ai/api-sdk-cli/ko/apis/errors-rate-limits-and-pagination.md)
