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

bash 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

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

3) Activar tablet

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

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

4) BC crea solicitud

En Swagger UI este endpoint aparece con un ejemplo pre-rellenado que incluye un PDF dummy valido de dos paginas con el texto PRUEBA y un recuadro para firmar. Para curl, sustituye <BASE64_PDF> por tu PDF en Base64 o copia el ejemplo desde Swagger.

bash 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

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

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

6) Tablet inicia firma

bash 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

bash 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

Listar solicitudes recientes, opcionalmente filtradas:

bash curl -H "Authorization: Bearer replace_me" \ "https://apifirma.jdmarquez.dev/v1/signature-requests?status=pending&deviceId=tablet-recepcion-1&limit=50"

Consultar una solicitud concreta:

bash curl -H "Authorization: Bearer replace_me" \ "https://apifirma.jdmarquez.dev/v1/signature-requests/<REQUEST_ID>"

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

9) Revocar o eliminar una tablet

Revocar corta el acceso de la tablet, pero conserva el registro para reactivarla despues:

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

Eliminar borra el registro de la tablet si no tiene solicitudes abiertas:

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

Si hay solicitudes pending, displayed o signing, la eliminacion devuelve 409 CONFLICT.

Lectura relacionada