Documentación API

REST JSON bajo /api/v1. OpenAPI 3.1: /api/openapi

Autenticación

Authorization: Bearer vef_tu_clave

Crear imagen

curl -X POST "http://localhost:3000/api/v1/images?sync=true" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: pedido-1234" \
  -d '{
    "template_id": "TU_TEMPLATE_ID",
    "modifications": [
      { "name": "titulo", "text": "Oferta de verano" },
      { "name": "precio", "text": "29,99 €" }
    ],
    "webhook_url": "https://tu-app.com/hooks/render"
  }'

PDF

curl -X POST "http://localhost:3000/api/v1/pdfs" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"template_id":"...","modifications":[]}'

Lote

curl -X POST "http://localhost:3000/api/v1/batches" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{"template_id":"...","items":[{"modifications":[]},{"modifications":[]}]}'

Webhooks

Verifica X-Signature: sha256=… (HMAC-SHA256 del body con tu secreto). Eventos: render.completed, render.failed.

JavaScript (fetch)

const res = await fetch("http://localhost:3000/api/v1/images", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${apiKey}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    template_id: templateId,
    modifications: [{ name: "titulo", text: "Hola" }],
  }),
});
const job = await res.json();
console.log(job.status, job.id);

Salud

GET /api/health · GET /api/health/ready (DB + Redis)