Skip to content

Documents

Endpoint de depot d'un document generique (convention, facture, etc.).

POST /:opcoId/documents

Depot d'un document. Traitement asynchrone via file d'attente.

Auth : X-API-KEY obligatoire.

Body (JSON)

json
{
  "typeFichier": "convention",
  "objets": [
    {
      "typeObjet": "dossier",
      "idObjet": "INT-001"
    }
  ],
  "_files": { "document": "base64..." }
}

Champs du body

ChampTypeRequisDescription
typeFichierstringOuiType du fichier (ex: convention, facture, cerfa)
objetsarrayOuiAu moins 1 objet lie au document
_filesobjectNonFichiers joints en base64

Champs d'un objet

ChampTypeRequisDescription
typeObjetstringOuiType de l'objet (ex: dossier, facture)
idObjetstringOuiIdentifiant de l'objet

Headers optionnels

HeaderDescription
Idempotency-KeyCle d'idempotence. Si deja vue, retourne 200 + duplicate.

Reponse 202

json
{
  "jobId": "550e8400-e29b-41d4-a716-446655440000",
  "status": "pending",
  "statusUrl": "/opco-ep/jobs/550e8400-e29b-41d4-a716-446655440000"
}

Reponse 200 (doublon)

json
{
  "jobId": "550e8400-e29b-41d4-a716-446655440000",
  "status": "duplicate",
  "statusUrl": "/opco-ep/jobs/550e8400-e29b-41d4-a716-446655440000"
}

Suivez le job via GET /:opcoId/jobs/:jobId.

Erreurs

Code HTTPCode erreurDescription
400VALIDATION_ERRORBody invalide (typeFichier manquant, objets vide)
403HTTP_ERRORX-API-KEY manquant

Exemple curl

bash
curl -X POST -H "X-API-KEY: votre-cle" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: doc-001" \
  -d '{"typeFichier": "convention", "objets": [{"typeObjet": "dossier", "idObjet": "INT-001"}]}' \
  "https://api.opcovia.com/opco-ep/documents"