Générer le PDF d'un Smart Report
Effectuez le rendu d'un PDF pour un SmartReport existant à l'aide de "puppeteer" ou "pdfkit", calculez verificationScore en option et recevez le tampon PDF encodé en base64 accompagné de downloadUrl et htmlUrl.
En cas de succès, ce point de terminaison passe le rapport à status: "generated", enregistre verificationScoreSummary lorsque la notation est activée et émet le webhook smart_batch_report_generated. Si la génération du PDF échoue, le rapport passe à status: "failed" et le webhook smart_batch_report_generation_failed est émis.
Point de terminaison
POST https://api.verifik.co/v2/smart-reports/{id}/generate
Ce point de terminaison accepte des payloads JSON jusqu'à 64 Mo (afin de prendre en charge les documents printHtml personnalisés). Il est également accessible via le proxy Smart-Agent à l'adresse https://ai.verifik.co/v2/smart-reports/{id}/generate en utilisant votre propre en-tête par client Authorization: Bearer <VERIFIK_JWT>. L'exécution partagée x402 est bloquée avec 403 Forbidden.
En-têtes
| Nom | Valeur | Description |
|---|---|---|
Content-Type | application/json | Format du payload de la requête (limite de 64 Mo). |
Authorization | Bearer <VERIFIK_JWT> | JWT limité au client (authUser.clientId). |
Paramètres
| Nom | Type | Requis | Description |
|---|---|---|---|
id | string | Oui | ObjectId du SmartReport. |
Corps de la requête
| Nom | Type | Requis | Description |
|---|---|---|---|
engine | string | Non | Moteur de rendu PDF : "pdfkit" ou "puppeteer". |
rowIndex | number | Non | Index de ligne basé sur zéro provenant du SmartBatch lié. Vaut 0 par défaut. |
printHtml | string | Non | Chaîne HTML complète (max 64000000 caractères) utilisée pour les modèles non thématiques contenant <html. |
score | boolean | Non | Indique s'il faut calculer verificationScore et enregistrer verificationScoreSummary sur le rapport. |
scoreProfile | string | Non | Identifiant du profil de notation utilisé lorsque score est activé. Max 64 caractères. |
Comportement de rendu et de notation
- Sélection de ligne par défaut : Lorsque
rowIndexest omis, la génération utilise la ligne0par défaut. Demander une ligne hors limites renvoie409 Conflict(row_not_found). - HTML personnalisé (
printHtml) : Lorsque vous travaillez avec des modèles non thématiques fournissant un balisage<htmlcomplet, passezprintHtml(jusqu'à64000000caractères). - Score de vérification : Définissez
score: true(et éventuellementscoreProfile) pour calculerverificationScore, le renvoyer au niveau racine de la réponse et enregistrerverificationScoreSummarysur leSmartReport. Les profils inconnus échouent avec409 Conflict(unknown_score_profile).
Requête
- Node.js
- PHP
- Python
- Go
- cURL
import axios from "axios";
const run = async () => {
const id = "6801a2b3c4d5e6f7a8b9c0d1";
const { data } = await axios.post(
`https://api.verifik.co/v2/smart-reports/${id}/generate`,
{
engine: "puppeteer",
rowIndex: 0,
score: true,
},
{
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.VERIFIK_JWT}`,
},
}
);
console.log({
status: data.data.status,
pdfSize: data.pdf.size,
downloadUrl: data.pdf.downloadUrl,
});
};
run();
<?php
$id = "6801a2b3c4d5e6f7a8b9c0d1";
$ch = curl_init("https://api.verifik.co/v2/smart-reports/" . $id . "/generate");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer " . getenv("VERIFIK_JWT"),
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
"engine" => "puppeteer",
"rowIndex" => 0,
"score" => true,
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
import os
import requests
report_id = "6801a2b3c4d5e6f7a8b9c0d1"
url = f"https://api.verifik.co/v2/smart-reports/{report_id}/generate"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {os.getenv('VERIFIK_JWT')}",
}
payload = {
"engine": "puppeteer",
"rowIndex": 0,
"score": True,
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
)
func main() {
id := "6801a2b3c4d5e6f7a8b9c0d1"
body, _ := json.Marshal(map[string]interface{}{
"engine": "puppeteer",
"rowIndex": 0,
"score": true,
})
req, _ := http.NewRequest("POST", "https://api.verifik.co/v2/smart-reports/"+id+"/generate", bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+os.Getenv("VERIFIK_JWT"))
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
var out map[string]interface{}
json.NewDecoder(resp.Body).Decode(&out)
fmt.Println(out)
}
curl -X POST "https://api.verifik.co/v2/smart-reports/6801a2b3c4d5e6f7a8b9c0d1/generate" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $VERIFIK_JWT" \
-d '{
"engine": "puppeteer",
"rowIndex": 0,
"score": true
}'
Réponse
- 200 OK
- 401
- 403
- 404
- 409
- 422
- 500
{
"data": {
"_id": "6801a2b3c4d5e6f7a8b9c0d1",
"template": "6801a2b3c4d5e6f7a8b9c0d2",
"smartBatch": "6801a2b3c4d5e6f7a8b9c0d3",
"name": "Background Check - Applicant 42",
"status": "generated",
"pdfEngine": "puppeteer",
"pdfSize": 148320,
"generationDurationMs": 1840,
"generatedAt": "2026-11-24T20:00:04.000Z",
"verificationScoreSummary": {},
"rowIndex": 0,
"externalRefId": "applicant-42"
},
"pdf": {
"buffer": "JVBERi0xLjQK...",
"size": 148320,
"engine": "puppeteer",
"generationDurationMs": 1840,
"downloadUrl": "/v2/smart-reports/6801a2b3c4d5e6f7a8b9c0d1/download",
"htmlUrl": "/v2/smart-reports/6801a2b3c4d5e6f7a8b9c0d1/html"
},
"verificationScore": {}
}
{
"message": "Unauthorized",
"code": "Unauthorized"
}
{
"message": "Shared x402 execution is forbidden on this endpoint",
"code": "Forbidden"
}
{
"message": "template_not_found",
"code": "NotFound"
}
{
"message": "row_not_found",
"code": "row_not_found"
}
{
"message": "UnprocessableEntity",
"code": "UnprocessableEntity"
}
{
"message": "InternalServerError",
"code": "InternalServerError"
}
Codes d'erreur
| Statut | Code / Type d'erreur | Cause |
|---|---|---|
401 | Unauthorized | JWT manquant ou invalide. |
403 | Forbidden | Exécution partagée x402 tentée ; utilisez votre propre JWT par client. |
404 | not_found | L'ID du rapport n'existe pas ou appartient à un autre client. |
404 | template_not_found | Le modèle lié est introuvable. |
404 | batch_not_found | Le SmartBatch lié est introuvable. |
409 | MissingParameter | La validation Joi a échoué sur un ou plusieurs champs. |
409 | row_not_found | Le rowIndex demandé n'existe pas dans le lot. |
409 | unknown_score_profile | Le scoreProfile demandé n'est pas reconnu. |
422 | UnprocessableEntity | Erreur de validation Mongoose. |
500 | InternalServerError | Échec du rendu PDF ou du traitement interne (marque le rapport "failed" et émet smart_batch_report_generation_failed). |
Intégration Webhooks et MCP
- Webhooks : Émet
smart_batch_report_generateden cas de création PDF réussie, ousmart_batch_report_generation_faileden cas d'erreur de rendu (et met à jourstatusà"failed"). Consultez Webhooks SmartReports. - Équivalent MCP : Les agents IA peuvent générer le PDF d'un rapport directement via l'outil MCP
smart_report_generate_pdf. Consultez MCP et Agents IA.
Notes
pdf.buffercontient les octets PDF encodés en base64 directement dans la réponse JSON ; si vous préférez un flux PDF binaire, appelez Télécharger le PDF d'un Smart Report.verificationScoreest inclus dans la réponse lorsquescoreest activé.