> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dataspike.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Analyze Documents

> Analyze passports, IDs, and government-issued documents for authenticity and deepfake manipulation.

The **Identity Document Analysis API** evaluates uploaded images of **passports**, **national IDs**, and other **government-issued documents** to verify their authenticity and detect digital tampering or deepfake manipulations.

This API is purpose-built for **KYC**, **onboarding**, and **fraud prevention** workflows, helping ensure that the documents submitted by users are genuine, unaltered, and machine-readable.

> ⚠️ The model is trained primarily on **government-issued identity documents**. Submissions of non-official or stylized documents (e.g., mockups, templates, or artistic edits) may result in **undefined or low-confidence results**.

***

## Endpoint Overview

**Method:** `POST`\
**Path:** `/api/v4/deepfake/document/image/analyze`\
**Base URL:** `https://api.dataspike.io`\
**Authentication:** Include your API key in the header\
`ds-api-token: <YOUR_API_KEY>`

**Supported formats:** `.jpg`, `.jpeg`, `.png`, `.webp`\
**Maximum file size:** `10 MB`\
**Content type:** `multipart/form-data` with a single `file` field

***

## Example Workflow (cURL)

Document analysis requests are processed **synchronously**, meaning the API performs the full analysis during the request and returns the final result immediately — no separate polling step is required.

### Submit a document for analysis

```bash theme={null}
curl -X POST "https://api.dataspike.io/api/v4/deepfake/image/analyze" \
  -H "ds-api-token: $DATASPIKE_API_KEY" \
  -F "file=@passport.jpg"
```

**Response (example):**

```json theme={null}
{
  "id": "01827ed4-c928-7a3c-9a30-7ab7cc169d11",
  "status": "queued",
  "job_type": "image",
  "content_type": "image/jpeg",
  "file_size_bytes": 1024,
  "score": 0.985,
  "verdict": "deepfake_likely",
  "sandbox": false
}
```

The response is returned as soon as the analysis completes.\
You can directly read the `score` and `verdict` fields to interpret the result.

| Field     | Description                                                                                                 |
| --------- | ----------------------------------------------------------------------------------------------------------- |
| `score`   | Confidence value (0–1). Higher values indicate a higher likelihood of manipulation or AI-generated content. |
| `verdict` | Classification result — for example `deepfake_likely` or `deepfake_unlikely`.                               |

> **Tip:** Choose a score threshold appropriate for your verification workflow.\
> For example, flag results with `score > 0.5` for manual review or secondary validation.

***

## Important Guidelines

* **Intended Input:** High-quality scans or photos of **government-issued identity documents** (passports, IDs, licenses).
* **Undefined Results:** Non-standard documents (mockups, templates, low-resolution scans) may yield **undefined** or **low-confidence** outcomes.
* **Lighting and Clarity:** Ensure the document is well-lit, unblurred, and occupies most of the image frame.
* **File Size:** Maximum 10 MB per upload. Resize or compress large images before submission.
* **Rate Limits:** Poll every 1–3 seconds when checking job status. Avoid tight loops to prevent throttling.

***

## Typical Flow

1. Upload the image of the ID/passport using the `/deepfake/image/analyze` endpoint.
2. Receive the job `id` in the response.
3. Poll the `/deepfake/job/{id}` endpoint periodically until `status` becomes `completed`.
4. Read the `score` and `verdict` fields to assess document authenticity.
5. Take action based on your fraud or KYC workflow.

***

## Sandbox Testing

For testing and integration purposes, you can use the sandbox environment:

**Base URL:** `https://sandboxapi.dataspike.io`

This environment behaves identically but uses non-production scoring and does not affect your production quota.
