Templates with tags (mail merge)

Beta

This feature is in beta. For now it is available only to some users. We will release it gradually to more accounts once testing ends. If you want to use it, ask your JAAK contact for access.

Description

A tagged template is a Markdown or HTML text where you mark where each data item goes and where each person signs. On send, JAAK fills the tags with the values of that send and generates a new PDF. The text reflows by itself: a long value is never cut and never overlaps another.

Nobody writes coordinates. JAAK places the signature boxes where the tags are.

Tags

TagWhat it does
{{key}}A data item filled in on send. Example: {{empresa.razon_social}}.
{{key|fecha}}A date data item. It is sent as an ISO date (YYYY-MM-DD) and the document shows it in Spanish, for example 22 de noviembre de 2026.
{{firma:ROLE}}A signature box for the signer with that role. Example: {{firma:EL CLIENTE}}.

Rules:

  • The key uses lowercase letters, digits, underscore and dot. Example: cliente.rfc.
  • A key can appear as many times as you want. You send one value and it fills every place.
  • fecha is the only filter.
  • A role can repeat, for example in annexes or in several signature blocks.
  • The template needs at least one {{firma:ROLE}} tag.
  • Any other tag form is rejected when the template is saved, not when it is sent.

Step 1. Create the template

curl -X POST https://signa.sandbox.jaak.ai/api/v1/templates/source \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Demo services contract",
    "source_type": "markdown",
    "signature_type": "advanced",
    "content": "# Services contract\n\nBetween {{empresa.razon_social}} and {{cliente.nombre}} (RFC {{cliente.rfc}}), signed on {{contrato.fecha|fecha}}.\n\n{{firma:EL PRESTADOR}}\n\n{{firma:EL CLIENTE}}\n"
  }'
FieldDescription
nameTemplate name.
source_typemarkdown or editor (HTML).
contentThe template text, as a string. The body cannot exceed 6 MiB.
signature_typeSignature type of the template. See Signature type per signer.
role_signature_typesOptional. Signature type per role.
initialsOptional. Who initials and which pages are skipped: enabled, roles and skip_pages.
data_keysOptional. Changes the visible label, the type (text, multiline, date) or whether a key is required. A key that is not in the text is rejected.

The response is 201. It includes the data keys JAAK found in the text (data_keys) and the signing roles.

Step 2. Send with values

Send template_values with one value per key and the signers in submitters. The role of each signer must match a {{firma:ROLE}} tag.

curl -X POST https://signa.sandbox.jaak.ai/api/v1/submissions \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "template_id": 1234,
    "send_email": false,
    "template_values": {
      "empresa.razon_social": "Inversiones Demo, S.A. de C.V.",
      "cliente.nombre": "Ana Ejemplo Pérez",
      "cliente.rfc": "XAXX010101000",
      "contrato.fecha": "2026-11-22"
    },
    "submitters": [
      { "role": "EL PRESTADOR", "name": "Representante Demo", "email": "representante@ejemplo.com" },
      { "role": "EL CLIENTE", "name": "Ana Ejemplo Pérez", "email": "ana.ejemplo@ejemplo.com" }
    ]
  }'

What happens on each send

  1. JAAK validates the values before it generates the document.
  2. It fills every tag and generates a new PDF for that send.
  3. It places the signature boxes where the {{firma:ROLE}} tags are and applies the initials of the template.
  4. It creates the send on that document.

Each send uses a hidden copy of the template. That copy does not appear in the template list. The original template does not change, and if you edit it later, earlier sends keep their document.

The legal text changes only at the tags. The rest is untouched.

Values are data, not code

JAAK escapes each value before it generates the document. A value such as <script> or **bold** appears as literal text. Scripts do not run and external images are not loaded.

Errors

When there is an error no send is created. The message names the key.

SituationExample response
A required key is missing400: falta el valor obligatorio de la clave "empresa.representante"
A key does not exist in the template400, with the key name.
A date is not valid400, with the key name.
A value is too long400, with the key name.
A tag uses an unknown form or a role that does not existRejected when the template is saved.
The body exceeds 6 MiB413.

Next steps