GuidesAsync Endpoints
Guides

Async Endpoints

Learn how Deepvue's asynchronous API endpoints work, including the create/result polling pattern, recommended intervals, and best practices.

Overview

Some Deepvue APIs use an asynchronous pattern where verification requests are submitted first and results are retrieved separately. This is common for verifications that depend on external government data sources with variable response times.

How async endpoints work

Async endpoints follow a two-step create → poll pattern:

Submit the request

Call the create endpoint with the required parameters. The API returns a transaction_id immediately without waiting for the data source to respond.

curl -X POST "https://production.deepvue.tech/v1/verification/post-driving-license" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "x-api-key: YOUR_CLIENT_SECRET" \
  -H "Content-Type: application/json" \
  -d '{"dl_number": "DL1234567890", "dob": "1990-01-01", "consent": "Y", "reason": "KYC"}'

Store the transaction ID

The create endpoint returns a transaction_id. Store this value — you will need it to retrieve the result.

{
  "code": 200,
  "transaction_id": "abc123def456",
  "message": "Request accepted"
}

Poll for the result

Call the result endpoint with the transaction_id to check if the verification is complete.

curl -X GET "https://production.deepvue.tech/v1/verification/get-driving-license?transaction_id=abc123def456" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "x-api-key: YOUR_CLIENT_SECRET"

If the result is not yet available, the API returns a 202 status with a message indicating the request is still being processed. Retry after a short delay.

Most async results are available within 5–30 seconds. Use exponential backoff starting at 3 seconds to avoid unnecessary API calls.

import time
import requests

def poll_for_result(transaction_id, headers, max_attempts=10):
    url = f"https://production.deepvue.tech/v1/verification/get-driving-license"
    delay = 3

    for attempt in range(max_attempts):
        response = requests.get(
            url,
            params={"transaction_id": transaction_id},
            headers=headers
        )

        if response.status_code == 200:
            data = response.json()
            if data.get("data"):
                return data  # Result is ready

        time.sleep(delay)
        delay = min(delay * 2, 30)  # Cap at 30 seconds

    raise TimeoutError("Result not available after maximum attempts")

Best practices

  • Store transaction IDs persistently — Save them in your database so you can retry polling if your process restarts.
  • Don't poll too aggressively — Excessive polling counts toward your rate limits. Start at 3 seconds and increase the interval.
  • Set a timeout — If a result hasn't arrived after 2–3 minutes, log the transaction ID and contact support.
  • Handle partial results — Some endpoints may return partial data while processing continues. Check the response status fields before using the data.
  • Use bulk endpoints for volume — If you need to verify many records, consider the Bulk Validations endpoints instead of making individual async requests.