← Back to generator

Document Generator API

Generate templates programmatically through the same queue used by the website. API access requires an account API key and will later be limited to eligible subscriptions.

1. Create an API key

Log in to the website, then call this endpoint. The key is shown only once. Store it in a password manager or server secret.

POST /api/account/api-key
Cookie: psd_session=<your-login-session>

Never put the API key in browser JavaScript, public repositories, or client-side applications.

2. Generate a document

Send the template key and fields required by that template. The request is asynchronous and returns a task ID.

curl -X POST https://your-domain.com/api/v1/generate \
  -H "X-API-Key: vfy_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "template_key": "USA ID 2010,us-id-10,id",
    "fields": {
      "Firstname": "JOHN",
      "Lastname": "DOE",
      "Gender": "M"
    }
  }'

Response:

{
  "status": "queued",
  "task_id": "task-uuid",
  "status_url": "/api/v1/generate/task-uuid"
}

3. Poll the task

curl https://your-domain.com/api/v1/generate/task-uuid \
  -H "X-API-Key: vfy_your_key"

Poll every few seconds until the response status is success or error.

{
  "status": "success",
  "data": {
    "preview": "/outputs/task-uuid/preview.png",
    "download": "/api/download/task-uuid"
  }
}

Template fields

Use the exact field names configured by each template, such as Firstname, Lastname, Gender, Date of birth, Date of issue, and Photo. Template-specific dropdown values and formatting must match the website form.

The template selector in the website and the /api/templates endpoint identify available templates and their metadata.

Authentication and errors