Saltar a contenido

API - Ejemplos de llamadas

Variables usadas en los ejemplos: - API local: http://127.0.0.1:8080 - API publica: https://apifirma.jdmarquez.dev - Token BC: replace_me - Device: tablet-recepcion-1

En esta pagina los ejemplos se muestran contra la URL publica de pruebas. Si estas en local, sustituye https://apifirma.jdmarquez.dev por http://127.0.0.1:8080.

1) Registrar tablet

curl -X POST "https://apifirma.jdmarquez.dev/v1/devices" \
  -H "Authorization: Bearer replace_me" \
  -H "Content-Type: application/json" \
  -d '{
    "deviceId":"tablet-recepcion-1",
    "name":"Recepcion 1"
  }'

2) Emitir codigo de activacion

curl -X POST "https://apifirma.jdmarquez.dev/v1/devices/tablet-recepcion-1/activation-code" \
  -H "Authorization: Bearer replace_me"

3) Activar tablet

curl -X POST "https://apifirma.jdmarquez.dev/v1/devices/activate" \
  -H "Content-Type: application/json" \
  -d '{
    "deviceId":"tablet-recepcion-1",
    "activationCode":"ABCD2345"
  }'

Guarda el deviceToken devuelto y usalo en el resto de llamadas de tablet.

4) BC crea solicitud

curl -X POST "https://apifirma.jdmarquez.dev/v1/signature-requests" \
  -H "Authorization: Bearer replace_me" \
  -H "Content-Type: application/json" \
  -d '{
    "externalRef":"BC-1001",
    "deviceId":"tablet-recepcion-1",
    "documentName":"autorizacion.pdf",
    "pdfBase64":"<BASE64_PDF>",
    "guestName":"John Doe",
    "reservationRef":"RES-1001"
  }'

5) Tablet reanuda activo o pide siguiente

curl -H "X-Device-Token: <DEVICE_TOKEN>" \
  "https://apifirma.jdmarquez.dev/v1/devices/tablet-recepcion-1/active"
curl -H "X-Device-Token: <DEVICE_TOKEN>" \
  "https://apifirma.jdmarquez.dev/v1/devices/tablet-recepcion-1/next"

6) Tablet inicia firma

curl -X POST \
  -H "X-Device-Token: <DEVICE_TOKEN>" \
  "https://apifirma.jdmarquez.dev/v1/signature-requests/<REQUEST_ID>/start-signing"

7) Tablet envia PDF firmado

curl -X POST "https://apifirma.jdmarquez.dev/v1/signature-requests/<REQUEST_ID>/signed" \
  -H "X-Device-Token: <DEVICE_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{
    "signedPdfBase64":"<BASE64_PDF_FIRMADO>",
    "signatureMetadata":{
      "signedAt":"2026-03-05T10:12:00Z",
      "deviceId":"tablet-recepcion-1",
      "strokeCount":18,
      "appVersion":"0.2.0"
    }
  }'

8) BC consulta estado y descarga resultado

curl -H "Authorization: Bearer replace_me" \
  "https://apifirma.jdmarquez.dev/v1/signature-requests/<REQUEST_ID>"
curl -L \
  -H "Authorization: Bearer replace_me" \
  "https://apifirma.jdmarquez.dev/v1/signature-requests/<REQUEST_ID>/result" \
  -o "signed-<REQUEST_ID>.pdf"

Lectura relacionada