Créer un Smart Batch à partir d'un fichier
Importez une charge utile CSV, XLSX ou JSONL dans un nouveau SmartBatch. Le serveur décode le texte brut ou les URL de données en base64, applique la limite MAX_ROWS (20000 par défaut), résout les en-têtes de colonnes et les alias en camelCase par rapport aux dépendances d'étapes de votre BatchConfiguration, et calcule une estimation du coût en crédits.
Les lignes acceptées sont enregistrées dans le lot au statut pending, tandis que les lignes mal formées sont renvoyées dans rejectedRows. Passez autoStart: true pour vérifier les autorisations de points de terminaison du compte et démarrer le traitement immédiatement ; sinon, aucune vérification n'est exécutée et aucun crédit n'est dépensé.
Point de terminaison
POST https://api.verifik.co/v2/smart-batches/from-file
Ce point de terminaison est également accessible via le proxy Smart-Agent à l'adresse https://ai.verifik.co/v2/smart-batches/from-file avec votre propre en-tête 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 de la charge utile de la requête. |
Authorization | Bearer <VERIFIK_JWT> | JWT lié au client (authUser.clientId). |
Corps de la requête
| Nom | Type | Requis | Description |
|---|---|---|---|
batchConfiguration | string | Oui | ObjectId BatchConfiguration détenu par le client authentifié. |
name | string | Oui | Nom affiché du lot. 150 caractères maximum. |
content | string | Oui | Texte brut CSV/JSONL ou URL de données en base64 (data:<mime>;base64,<payload>). |
format | string | Non | Format d'entrée : "csv", "xlsx" ou "jsonl". Par défaut batchConfiguration.inputFormat ou "csv". |
autoStart | boolean | Non | Définissez true pour démarrer le lot créé immédiatement après l'import. |
Les clés de corps inconnues sont rejetées par la validation Joi avec 409 MissingParameter.
Requête
- Node.js
- PHP
- Python
- Go
- cURL
import axios from "axios";
const run = async () => {
const { data } = await axios.post(
"https://api.verifik.co/v2/smart-batches/from-file",
{
batchConfiguration: "6801a2b3c4d5e6f7a8b9c0d4",
name: "November CSV Import",
format: "csv",
content: "Document Type,Document Number\nCC,1032386359\nCC,1007463534\n",
autoStart: false,
},
{
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.VERIFIK_JWT}`,
},
}
);
console.log(data);
};
run();
<?php
$payload = [
"batchConfiguration" => "6801a2b3c4d5e6f7a8b9c0d4",
"name" => "November CSV Import",
"format" => "csv",
"content" => "Document Type,Document Number\nCC,1032386359\nCC,1007463534\n",
"autoStart" => false,
];
$ch = curl_init("https://api.verifik.co/v2/smart-batches/from-file");
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($payload));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
import os
import requests
url = "https://api.verifik.co/v2/smart-batches/from-file"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {os.getenv('VERIFIK_JWT')}",
}
payload = {
"batchConfiguration": "6801a2b3c4d5e6f7a8b9c0d4",
"name": "November CSV Import",
"format": "csv",
"content": "Document Type,Document Number\nCC,1032386359\nCC,1007463534\n",
"autoStart": False,
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
)
func main() {
body, _ := json.Marshal(map[string]interface{}{
"batchConfiguration": "6801a2b3c4d5e6f7a8b9c0d4",
"name": "November CSV Import",
"format": "csv",
"content": "Document Type,Document Number\nCC,1032386359\nCC,1007463534\n",
"autoStart": false,
})
req, _ := http.NewRequest("POST", "https://api.verifik.co/v2/smart-batches/from-file", 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-batches/from-file" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $VERIFIK_JWT" \
-d '{
"batchConfiguration": "6801a2b3c4d5e6f7a8b9c0d4",
"name": "November CSV Import",
"format": "csv",
"content": "Document Type,Document Number\nCC,1032386359\nCC,1007463534\n",
"autoStart": false
}'
Réponse
- 200 OK
- 401
- 403
- 404
- 409 (Ingestion / Config)
- 409 (MissingParameter)
- 422
- 500 (Seuil / Format)
{
"data": {
"batch": {
"_id": "6801a2b3c4d5e6f7a8b9c0d3",
"batchConfiguration": "6801a2b3c4d5e6f7a8b9c0d4",
"client": "507f1f77bcf86cd799439013",
"name": "November CSV Import",
"status": "pending",
"executor": "browser",
"source": "smart_batch",
"headlessRun": false,
"creditsSpent": 0,
"rows": [
{
"rowIndex": 0,
"inputData": {
"Document Type": "CC",
"documentType": "CC",
"Document Number": "1032386359",
"documentNumber": "1032386359"
},
"status": "pending",
"results": {},
"errors": []
},
{
"rowIndex": 1,
"inputData": {
"Document Type": "CC",
"documentType": "CC",
"Document Number": "1007463534",
"documentNumber": "1007463534"
},
"status": "pending",
"results": {},
"errors": []
}
],
"totalRows": 2,
"completedRows": 0,
"failedRows": 0,
"partialRows": 0,
"createdAt": "2026-11-24T20:05:00.000Z",
"updatedAt": "2026-11-24T20:05:00.000Z"
},
"columns": [
"Document Type",
"documentType",
"Document Number",
"documentNumber"
],
"accepted": 2,
"rejected": 0,
"rejectedRows": [],
"estimate": {
"itemCount": 2,
"creditsPerItem": 0.04,
"totalCredits": 0.08,
"breakdown": [
{
"sequence": 1,
"featureCode": "co-cedula",
"price": 0.04,
"total": 0.08
}
]
}
}
}
{
"message": "Unauthorized",
"code": "Unauthorized"
}
{
"message": "Shared x402 execution is forbidden on this endpoint",
"code": "Forbidden"
}
{
"message": "batch_configuration_not_found",
"code": "NotFound"
}
{
"message": "batch_file_is_empty",
"code": "Conflict"
}
{
"message": "\"content\" is required",
"code": "MissingParameter"
}
{
"message": "UnprocessableEntity",
"code": "UnprocessableEntity"
}
{
"message": "409:batch_file_exceeds_max_rows:20000",
"code": "InternalServerError"
}
Notes
- L'analyse de fichier applique
MAX_ROWS(20000par défaut) et génère automatiquement des alias d'en-têtes en camelCase afin que des colonnes commeDocument Numbersoient résolues versdocumentNumber. - Pour les classeurs
.xlsx, transmettez une URL de données en base64 (data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,<payload>) avecformat: "xlsx". - Les erreurs
409 Conflictincluentbatch_file_has_no_sheets,batch_file_is_empty,batch_file_has_no_rows,batch_file_has_no_usable_rows,batch_jsonl_parse_failed_on_line_<N>,batch_configuration_has_no_stepsetendpoints_not_in_account. - Les erreurs de validation des lignes (
0ligne valide), les erreurs de format non pris en charge et les erreurs de dépassement deMAX_ROWSrenvoient HTTP500.