> For the complete documentation index, see [llms.txt](https://docs.facephi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.facephi.com/docs.facephi-en/rest-api/midapi-v2/daf.md).

# DAF (Document Anti-Fraud)

**DAF (Document Anti-Fraud)** is a service that analyzes the Identity document (and, optionally, a selfie) and determines whether they are authentic and consistent with each other. The service is integrated as part of the Facephi API ecosystem.

Based on the document (and, if provided, the selfie), DAF performs a set of anti-fraud validations and returns a single diagnosis:

* **APPROVED**: the document (and, where applicable, the match with the selfie) passes the validations.
* **DECLINED**: an inconsistency, manipulation, or quality/format noncompliance is detected that prevents the document from being validated.

### Asynchronous nature

DAF is an asynchronous service: the call that starts the validation does not block waiting for the result. It responds immediately with a transaction identifier (`transactionId`) and the consumer obtains the result through status queries (polling).

### Integration Flow

The typical integration follows these steps:

1. Obtain a [consumer token](/docs.facephi-en/rest-api/midapi-v2/autenticacion.md) valid to authenticate all calls.
2. [Upload the assets](/docs.facephi-en/rest-api/midapi-v2/daf/subida-de-assets.md) from the document (and, optionally, the selfie) to the storage service, obtaining a `fileKey` for each one.
3. [Start the validation](/docs.facephi-en/rest-api/midapi-v2/daf/iniciar-validacion.md) in DAF by sending the `fileKeys` obtained. DAF responds immediately with a `transactionId`.
4. [Query the status](/docs.facephi-en/rest-api/midapi-v2/daf/consultar-estado.md) of the transaction through polling until obtaining a terminal status.

### Endpoint Summary

| Endpoint                  | Method | Description                                                                                               |
| ------------------------- | ------ | --------------------------------------------------------------------------------------------------------- |
| `/consumer/token`         | POST   | Issues the consumer JWT token (valid for 1 h). Requires the headers `platform-id` and `platform-api-key`. |
| `/storage`                | POST   | Uploads an asset (document or selfie) and returns its `fileKey`.                                          |
| `/v2/daf/validate`        | POST   | Starts a DAF validation. Responds `202` with `transactionId`.                                             |
| `/v2/daf/{transactionId}` | GET    | Queries the status/result of a transaction (polling).                                                     |
