API v2 documentation

Identity verification with ID document, selfie and liveness.

التوثيق التقني متاح باللغة الإنجليزية.

1. Introduction

The FaceKYC API v2 creates verification sessions. Each session produces a single-use link and QR code that the person opens on their phone to photograph their document (Spanish DNI or NIE, or passport) and record a short video of their face with a liveness challenge. When done, FaceKYC decides approved, rejected or review and notifies you by webhook; you can also query it.

  • Base URL: https://api.facekyc.com
  • Format: UTF-8 JSON (Content-Type: application/json).
  • Errors: always {"error":"<code>"} with the matching HTTP status (see Errors).

2. Authentication

Every request from your server carries your API key in the Authorization header:

Authorization: Bearer fk_live_XXXXXXXX_…

Use the key only from your server: never in an app, a browser or a repository. Keys are bound to your company and to a contract. If a key is exposed, ask for it to be revoked and replaced.

3. Integration flow

  1. Your server creates the session with POST /v2/sessions and gets flow_url and qr_url.
  2. You send the link to the person or display the QR (for example, on an ATM screen).
  3. The person accepts the consent, photographs the document and records the liveness video.
  4. FaceKYC decides and sends you a signed webhook. You can also query GET /v2/sessions/{id}.
  5. If your contract includes it, you download the evidence with GET /v2/sessions/{id}/media.

4. Create a session

POST/v2/sessions

Headers: Authorization, Content-Type: application/json and a mandatory Idempotency-Key (8–128 characters A-Z a-z 0-9 _ . : -). Repeating the request with the same key and body within 24 hours returns the same response with Idempotent-Replayed: true and no new session. The same key with a different body returns 422 idempotency_key_reutilizada.

FieldRequiredDescription
channelYesapi, qr, pwa or atm: how the person will arrive.
referenceNoYour internal reference (1–64 printable ASCII characters). No personal data: it is rejected if it looks like an email, an ID number or a phone number.
atm_idWith atmATM or kiosk identifier (A-Z 0-9 _ -, up to 32).
document_typeNodni_es (default), nie_es or pasaporte.
localeNoInterface language, e.g. es (default) or en.
return_urlNohttps:// address the interface offers to go back to at the end.

Extra fields are not allowed (400).

curl -X POST https://api.facekyc.com/v2/sessions \
  -H "Authorization: Bearer $FACEKYC_API_KEY" \
  -H "Idempotency-Key: order-123-attempt-1" \
  -H "Content-Type: application/json" \
  -d '{"channel":"qr","reference":"order-123","document_type":"dni_es","locale":"en"}'

201 response:

{
  "id": "ses_01J…",
  "status": "created",
  "flow_url": "https://api.facekyc.com/s/…",
  "qr_url": "https://api.facekyc.com/s/…",
  "session_token": "st_…",
  "expires_at": "2026-11-28T16:00:00.000Z"
}
  • flow_url (to send) and qr_url (to show as a QR) are single-use: once the person opens one, the other stops working. Treat them as secrets.
  • The session expires at expires_at (by default, 60 minutes after creation).
  • Creating a session uses credits from your balance; without enough balance you get 402 saldo_insuficiente.
  • session_token is only needed for browserless integrations (ATMs with their own interface); keep it on your server.

5. Get a session

GET/v2/sessions/{id}

{
  "id": "ses_01J…",
  "status": "decided",
  "decision": "approved",
  "reasons": [],
  "scores": { … },
  "reference": "order-123",
  "channel": "qr",
  "document_type": "dni_es",
  "created_at": "…", "expires_at": "…", "decided_at": "…",
  "thresholds_version": "…", "rules_version": "…", "consent_version": "…"
}

If your contract includes data return, once the session is decided the response also contains extracted with the data read from the document.

6. Statuses and decisions

statusMeaning
createdCreated; nobody has opened the link or QR yet.
consent, document, livenessThe person is going through the flow (consent, document, liveness).
processingCapture finished; decision in progress.
decidedThere is a decision in decision.
closedClosed after the decision.
expired, cancelled, failedExpired, cancelled by your company or failed. Final statuses without a decision.

decision: approved, rejected or review (needs manual review; you will get another notification when it is resolved). reasons is a list of reason codes.

7. Cancel a session

POST/v2/sessions/{id}/cancel → {"id":"ses_…","status":"cancelled"}. The links stop working and deletion of the captured data is scheduled. If the session is already final: 409 estado_final.

8. Evidence

GET/v2/sessions/{id}/media lists the session images and videos (id, type, content_type, bytes, created_at) with a signed url that expires after 120 seconds (url_expires_at). That URL is downloaded without an API key. Evidence is stored encrypted and deleted when your contract's retention period ends; after that the download returns 410 borrado.

9. Webhooks

FaceKYC sends a JSON POST to the public https:// address you registered. Events: session.decided, session.review_required, session.expired, session.cancelled.

{"id":"evt_…","type":"session.decided","created":1764160000,
 "data":{"session_id":"ses_…","reference":"order-123","status":"decided","decision":"approved","reasons":[]}}

Notifications carry no personal data. Headers:

  • X-FaceKYC-Event-Id: event identifier (use it to avoid processing the same event twice).
  • X-FaceKYC-Timestamp: seconds since 1970.
  • X-FaceKYC-Signature: v1= + hex HMAC-SHA256 of timestamp + "." + body with your webhook secret.

Always verify the signature over the raw body (before parsing it) and reject timestamps more than 5 minutes off. Answer quickly with a 2xx; any other answer (including a redirect, which is not followed) counts as a failure and is retried after 1 min, 5 min, 30 min, 2 h, 12 h and 24 h. When in doubt, confirm the status with GET /v2/sessions/{id}.

Node.js:

const crypto = require('node:crypto');
function verifySignature(secret, ts, rawBody, header) {
  if (!/^\d{1,12}$/.test(ts) || Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false;
  const expected = 'v1=' + crypto.createHmac('sha256', secret).update(ts + '.' + rawBody).digest('hex');
  return String(header || '').split(',').map((v) => v.trim()).some((v) =>
    v.length === expected.length && crypto.timingSafeEqual(Buffer.from(v), Buffer.from(expected)));
}

PHP:

function verifySignature(string $secret, string $ts, string $body, string $header): bool {
  if (!preg_match('/^\d{1,12}$/', $ts) || abs(time() - (int)$ts) > 300) return false;
  $expected = 'v1=' . hash_hmac('sha256', $ts . '.' . $body, $secret);
  foreach (array_map('trim', explode(',', $header)) as $v) {
    if (hash_equals($expected, $v)) return true;
  }
  return false;
}
// $body = file_get_contents('php://input');

Until the business dashboard is published, webhook registration and its secret are handled through support.

10. Embedding the flow in your website or app

  • Link: send flow_url through your usual channel (email, SMS, your app).
  • QR: generate a QR code from qr_url and display it.
  • Mobile apps: open the link in the system browser, SFSafariViewController (iOS) or Chrome Custom Tabs (Android). If you use a WebView, it must allow the camera (getUserMedia) and inline playback.
  • The FaceKYC interface cannot be embedded in an iframe.
  • With return_url, the interface offers to go back to your site at the end. The decision is not carried in that address: query the API or wait for the webhook.

11. Errors

HTTPCodes
400falta_idempotency_key, reference_invalida, falta_atm_id, return_url_invalida, campo_inesperado, peticion_invalida
401clave_invalida
402saldo_insuficiente
403contrato_no_valido, servicio_suspendido, permiso_denegado
404no_encontrada
409estado_final
410borrado (evidence already deleted)
422idempotency_key_reutilizada
429demasiadas_sesiones, demasiados_fallos
5xxTemporary error: retry with the same Idempotency-Key.

12. Limits and good practice

  • There is a per-key limit of sessions per minute, and a temporary block after several attempts with invalid keys (429).
  • Retry network errors and 5xx with the same Idempotency-Key to avoid duplicate sessions.
  • Do not put personal data in reference: use an internal identifier.
  • Treat review as “pending”: do not grant access until you get the final decision.

13. API v1

API v1 is being retired. If you still use it, migrate to v2 and contact us for help with the change.