Skip to main content

Endpoint

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

Corps de la requête

{
  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

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

{
  "taskId": "cmpkb4ghw00016qduu44p7n2q",
  "status": "PENDING",
  "type": "SENTIMENT_ANALYSIS",
  "costCents": 20,
  "estimatedCompletionMs": 3600000
}

Statuts possibles

StatutDescription
PENDINGEn attente de réponses
VALIDATINGDes réponses ont été reçues, consensus en cours
COMPLETEDConsensus atteint — résultat disponible
FAILEDPas assez de réponses concordantes

Types de tâches

{
  "type": "SENTIMENT_ANALYSIS",
  "content": "Le service client était catastrophique.",
  "options": ["Positif", "Négatif", "Neutre"]
}

Erreurs courantes

CodeHTTPDescription
MISSING_FIELDS400type, content ou options manquant
INVALID_TYPE400Type de tâche non reconnu
OPTIONS_REQUIRED400Minimum 2 options requises
INSUFFICIENT_CREDITS402Solde insuffisant pour créer la tâche
UNAUTHORIZED401JWT manquant ou expiré

Récupérer le résultat

Une fois la tâche complétée, utilisez GET /api/v1/tasks/:id ou configurez un webhook pour recevoir le résultat automatiquement.