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

# Créer une tâche

> POST /api/v1/tasks — Soumettre une tâche d'annotation.

## Endpoint

```
POST https://dloopiq.onrender.com/api/v1/tasks
Authorization: Bearer <jwt_acheteur>
Content-Type: application/json
```

***

## Corps de la requête

```typescript theme={null}
{
  type: TaskType           // obligatoire
  content: string         // obligatoire — texte, URL image/audio, ou JSON structuré
  options: string[]       // obligatoire — réponses possibles (min 2)
  locale?: string         // optionnel — 'fr' | 'en' | 'de' | 'zh' | 'es' | 'ar' (défaut: 'en')
  maxCents?: number       // optionnel — budget max par tâche en centimes (défaut: 20)
  projectId?: string      // optionnel — rattacher à un projet existant
  validationsNeeded?: number  // optionnel — nombre de réponses requises (défaut: 3)
}
```

***

## Exemple

```bash theme={null}
curl -X POST https://dloopiq.onrender.com/api/v1/tasks \
  -H "Authorization: Bearer eyJhbGci..." \
  -H "Content-Type: application/json" \
  -d '{
    "type": "SENTIMENT_ANALYSIS",
    "content": "Ce produit est absolument fantastique !",
    "options": ["Positif", "Négatif", "Neutre"],
    "locale": "fr",
    "maxCents": 25
  }'
```

***

## Réponse

```json theme={null}
{
  "taskId": "cmpkb4ghw00016qduu44p7n2q",
  "status": "PENDING",
  "type": "SENTIMENT_ANALYSIS",
  "costCents": 20,
  "estimatedCompletionMs": 3600000
}
```

***

## Statuts possibles

| Statut       | Description                                     |
| ------------ | ----------------------------------------------- |
| `PENDING`    | En attente de réponses                          |
| `VALIDATING` | Des réponses ont été reçues, consensus en cours |
| `COMPLETED`  | Consensus atteint — résultat disponible         |
| `FAILED`     | Pas assez de réponses concordantes              |

***

## Types de tâches

<Tabs>
  <Tab title="SENTIMENT_ANALYSIS">
    ```json theme={null}
    {
      "type": "SENTIMENT_ANALYSIS",
      "content": "Le service client était catastrophique.",
      "options": ["Positif", "Négatif", "Neutre"]
    }
    ```
  </Tab>

  <Tab title="IMAGE_CLASSIFICATION">
    ```json theme={null}
    {
      "type": "IMAGE_CLASSIFICATION",
      "content": "https://example.com/image.jpg",
      "options": ["Chat", "Chien", "Oiseau", "Autre"]
    }
    ```
  </Tab>

  <Tab title="BINARY_CHOICE">
    ```json theme={null}
    {
      "type": "BINARY_CHOICE",
      "content": "Cette image contient-elle du contenu explicite ?",
      "options": ["Oui", "Non"]
    }
    ```
  </Tab>

  <Tab title="AI_RESPONSE_RATING">
    ```json theme={null}
    {
      "type": "AI_RESPONSE_RATING",
      "content": "Question: Quelle est la capitale de la France ?\nRéponse: La capitale de la France est Paris.",
      "options": ["Excellent", "Bon", "Moyen", "Mauvais"]
    }
    ```
  </Tab>
</Tabs>

***

## Erreurs courantes

| Code                   | HTTP | Description                             |
| ---------------------- | ---- | --------------------------------------- |
| `MISSING_FIELDS`       | 400  | `type`, `content` ou `options` manquant |
| `INVALID_TYPE`         | 400  | Type de tâche non reconnu               |
| `OPTIONS_REQUIRED`     | 400  | Minimum 2 options requises              |
| `INSUFFICIENT_CREDITS` | 402  | Solde insuffisant pour créer la tâche   |
| `UNAUTHORIZED`         | 401  | JWT manquant ou expiré                  |

***

## Récupérer le résultat

Une fois la tâche complétée, utilisez [`GET /api/v1/tasks/:id`](/api-reference/tasks-list) ou configurez un [webhook](/api-reference/webhooks) pour recevoir le résultat automatiquement.
