Schedule a demo with an expertSchedule demo
Back to documentation
Guide20 min

Electronic signature

It implements electronic signature with legal validity linked to the confirmed identity of the signatory.

Legal framework

The electronic signature of JAAK complies with the Trade Code (Section 89-114), NOM-151-SCFI-2016 for data message maintenance and LFPDPPP for personal data protection.

1. To create a document to sign

First, put up the document you wish to sign:

POST / v1 / documents
const document = await jaak.documents.create({
  name: 'Contrato de Servicios',
  file: fs.readFileSync('./contrato.pdf'), // Buffer o base64
  mimeType: 'application/pdf',

  // Metadatos del documento
  metadata: {
    contractId: 'contract_123',
    type: 'service_agreement'
  }
});

console.log(document.id); // doc_abc123

2. Configure signing session

Create a signing session with signatories and configuration:

POST / v1 / signs
const signature = await jaak.signatures.create({
  documentId: document.id,

  // Lista de firmantes
  signers: [
    {
      name: 'Juan Pérez',
      email: 'juan@ejemplo.com',
      phone: '+525512345678',
      role: 'signer', // 'signer', 'witness', 'approver'
      order: 1, // Orden de firma (opcional)

      // Requerir verificación de identidad antes de firmar
      requireVerification: true,
      verificationConfig: {
        documentTypes: ['ine'],
        livenessCheck: true,
        faceMatch: true
      }
    },
    {
      name: 'María García',
      email: 'maria@empresa.com',
      role: 'signer',
      order: 2,
      requireVerification: true
    }
  ],

  // Configuración de la firma
  config: {
    // Tipo de firma
    signatureType: 'advanced', // 'simple', 'advanced', 'qualified'

    // Generar constancia NOM-151
    nom151: true,

    // Capturar geolocalización
    captureLocation: true,

    // Expiración de la sesión
    expiresIn: '7d',

    // Recordatorios automáticos
    reminders: {
      enabled: true,
      frequency: '24h'
    }
  },

  // URLs de notificación
  redirectUrl: 'https://tuapp.com/firma/completada',
  webhookUrl: 'https://tuapp.com/webhooks/firma'
});

// Obtener URLs para cada firmante
signature.signers.forEach(signer => {
  console.log(`${signer.name}: ${signer.signatureUrl}`);
});

3. Send invitations

Can send invitations automatically or manually:

// Opción 1: Envío automático por JAAK
await jaak.signatures.sendInvitations(signature.id, {
  method: 'email', // 'email', 'sms', 'whatsapp'
  message: 'Por favor firma el contrato de servicios.'
});

// Opción 2: Obtener URLs y enviar tú mismo
const signers = await jaak.signatures.getSigners(signature.id);
signers.forEach(signer => {
  // Envía signer.signatureUrl por tu propio canal
  sendCustomEmail(signer.email, signer.signatureUrl);
});

4. To process complete signature

He gets the web hook after all the signatories have signed:

Webhook: signature.complete
{
  "event": "signature.completed",
  "timestamp": "2025-01-09T15:30:00Z",
  "data": {
    "signatureId": "sig_abc123",
    "documentId": "doc_xyz789",
    "status": "completed",

    "signers": [
      {
        "name": "Juan Pérez",
        "email": "juan@ejemplo.com",
        "signedAt": "2025-01-09T14:00:00Z",
        "verificationId": "ver_123",
        "location": {
          "lat": 19.4326,
          "lng": -99.1332,
          "city": "Ciudad de México"
        },
        "ipAddress": "189.xxx.xxx.xxx"
      },
      {
        "name": "María García",
        "email": "maria@empresa.com",
        "signedAt": "2025-01-09T15:30:00Z",
        "verificationId": "ver_456"
      }
    ],

    "documents": {
      "signed": "https://docs.jaak.ai/signed_contract.pdf",
      "nom151": "https://docs.jaak.ai/nom151_certificate.pdf",
      "evidence": "https://docs.jaak.ai/evidence_package.zip"
    },

    "hashes": {
      "original": "sha256:abc123...",
      "signed": "sha256:def456..."
    }
  }
}

5. Download signed documents

// Obtener el documento firmado
const signedDoc = await jaak.signatures.getSignedDocument(signature.id);

// Descargar el PDF firmado
const pdfBuffer = await signedDoc.download('signed');
fs.writeFileSync('./contrato_firmado.pdf', pdfBuffer);

// Descargar constancia NOM-151
const nom151Buffer = await signedDoc.download('nom151');
fs.writeFileSync('./constancia_nom151.pdf', nom151Buffer);

// Descargar paquete de evidencia completo
const evidenceBuffer = await signedDoc.download('evidence');
fs.writeFileSync('./evidencia.zip', evidenceBuffer);

Evidence package

The evidence package includes everything necessary to validate the signature in a legal process:

  • Original document with Hash SHA-256
  • Document signed with time seals
  • Constance NOM-151 Maintenance
  • Identification check of each signatory
  • Audit registry with IP and geolocalization