Crear un Smart Report
Crea un registro SmartReport en estado borrador (status: "draft") vinculado a una plantilla (template) y un smartBatch existentes. Usa este endpoint cuando ya tengas un SmartBatch completado o en curso y quieras gestionar la creación del reporte, la generación del PDF, la obtención del HTML y el envío por correo electrónico como pasos independientes.
Crear un registro en borrador devuelve HTTP 200 OK con el nuevo SmartReport dentro de { data }. No ejecuta pasos de verificación ni renderiza un PDF por sí solo — continúa con Generar PDF de Smart Report o Enviar Smart Report por correo electrónico. Si deseas ejecutar pasos de verificación y producir un reporte en una sola solicitud, utiliza Ejecutar un Smart Report.
Endpoint
POST https://api.verifik.co/v2/smart-reports
Este endpoint también es accesible a través del proxy de Smart-Agent en https://ai.verifik.co/v2/smart-reports usando tu propio encabezado por cliente Authorization: Bearer <VERIFIK_JWT>. La ejecución compartida mediante x402 está bloqueada con 403 Forbidden.
Encabezados
| Nombre | Valor | Descripción |
|---|---|---|
Content-Type | application/json | Formato del payload de la solicitud. |
Authorization | Bearer <VERIFIK_JWT> | JWT con alcance de cliente (authUser.clientId). |
Cuerpo
| Nombre | Tipo | Requerido | Descripción |
|---|---|---|---|
template | string | Sí | ObjectId de la plantilla contra la cual renderizar este reporte. |
smartBatch | string | Sí | ObjectId del SmartBatch que suministra los resultados de las filas de verificación. |
name | string | No | Nombre visible para el reporte. Máx. 150 caracteres. |
externalRefId | string | No | Identificador de correlación del llamador. Máx. 200 caracteres. |
webhookUrl | string | No | URL webhook http o https de sobrescritura por reporte. Máx. 2048 caracteres. |
rowIndex | integer | No | Índice de fila base cero (>= 0) del SmartBatch vinculado. |
createdByChannel | string | No | Canal de origen: "portal", "api", "mcp", "x402" o "webhook". Predeterminado "portal". |
Flujo paso a paso vs ejecución headless
- Usa
POST /v2/smart-reportscuando tu flujo ya haya ejecutado unSmartBatch(por ejemplo desde la interfaz de SmartBatch o la API de cola) y quieras crear primero unSmartReporten borrador (status: "draft"), previsualizar el HTML con Recuperar HTML de Smart Report, renderizar el PDF con Generar PDF de Smart Report y enviarlo con Enviar Smart Report por correo electrónico. - Ten en cuenta que
createdByChanneltoma el valor"portal"por defecto en esta ruta, por lo que las integraciones por API deberían enviarcreatedByChannel: "api"cuando rastreen la atribución del canal.
Solicitud
- Node.js
- PHP
- Python
- Go
- cURL
import axios from "axios";
const run = async () => {
const { data } = await axios.post(
"https://api.verifik.co/v2/smart-reports",
{
template: "6801a2b3c4d5e6f7a8b9c0d2",
smartBatch: "6801a2b3c4d5e6f7a8b9c0d3",
name: "Applicant 42 Draft Report",
externalRefId: "applicant-42",
webhookUrl: "https://webhooks.example.com/verifik",
rowIndex: 0,
createdByChannel: "api",
},
{
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.VERIFIK_JWT}`,
},
}
);
console.log(data);
};
run();
<?php
$ch = curl_init("https://api.verifik.co/v2/smart-reports");
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([
"template" => "6801a2b3c4d5e6f7a8b9c0d2",
"smartBatch" => "6801a2b3c4d5e6f7a8b9c0d3",
"name" => "Applicant 42 Draft Report",
"externalRefId" => "applicant-42",
"webhookUrl" => "https://webhooks.example.com/verifik",
"rowIndex" => 0,
"createdByChannel" => "api",
]));
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-reports"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {os.getenv('VERIFIK_JWT')}",
}
payload = {
"template": "6801a2b3c4d5e6f7a8b9c0d2",
"smartBatch": "6801a2b3c4d5e6f7a8b9c0d3",
"name": "Applicant 42 Draft Report",
"externalRefId": "applicant-42",
"webhookUrl": "https://webhooks.example.com/verifik",
"rowIndex": 0,
"createdByChannel": "api",
}
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{}{
"template": "6801a2b3c4d5e6f7a8b9c0d2",
"smartBatch": "6801a2b3c4d5e6f7a8b9c0d3",
"name": "Applicant 42 Draft Report",
"externalRefId": "applicant-42",
"webhookUrl": "https://webhooks.example.com/verifik",
"rowIndex": 0,
"createdByChannel": "api",
})
req, _ := http.NewRequest("POST", "https://api.verifik.co/v2/smart-reports", 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" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $VERIFIK_JWT" \
-d '{
"template": "6801a2b3c4d5e6f7a8b9c0d2",
"smartBatch": "6801a2b3c4d5e6f7a8b9c0d3",
"name": "Applicant 42 Draft Report",
"externalRefId": "applicant-42",
"webhookUrl": "https://webhooks.example.com/verifik",
"rowIndex": 0,
"createdByChannel": "api"
}'
Respuesta
- 200 OK
- 401
- 403
- 409
- 422
{
"data": {
"_id": "6801a2b3c4d5e6f7a8b9c0d1",
"template": "6801a2b3c4d5e6f7a8b9c0d2",
"smartBatch": "6801a2b3c4d5e6f7a8b9c0d3",
"name": "Applicant 42 Draft Report",
"status": "draft",
"externalRefId": "applicant-42",
"webhookUrl": "https://webhooks.example.com/verifik",
"rowIndex": 0,
"createdByChannel": "api",
"createdAt": "2026-11-24T20:00:00.000Z",
"updatedAt": "2026-11-24T20:00:00.000Z"
}
}
{
"message": "Unauthorized",
"code": "Unauthorized"
}
{
"message": "Shared x402 execution is forbidden on this endpoint",
"code": "Forbidden"
}
{
"message": "\"template\" is required",
"code": "MissingParameter"
}
{
"message": "UnprocessableEntity",
"code": "UnprocessableEntity"
}
Integración con Webhooks y MCP
- Webhooks: Almacenar
webhookUrlyexternalRefIden elSmartReporten borrador garantiza que las llamadas posteriores de generación (smart_batch_report_generated,smart_batch_report_generation_failed) y envío por correo (smart_batch_report_sent,smart_batch_report_delivery_failed) hereden tu destino de callback por reporte e identificador de correlación. Consulta Webhooks de SmartReports. - Integración MCP: Para ejecutar reportes headless en una sola llamada desde agentes de IA, utiliza
smart_report_run. Consulta MCP y Agentes de IA.
Notas
- La creación exitosa devuelve HTTP
200(no201) constatus: "draft". - Guarda
data._idpara llamadas posteriores a Recuperar un Smart Report, Generar PDF de Smart Report, Descargar PDF de Smart Report, Recuperar HTML de Smart Report y Enviar Smart Report por correo electrónico.