Get started

Quickstart

From no key to a downloaded Florida lease, starting from what your user typed. Everything below runs in test mode: free, watermarked, never billed.

1. Get a test key

Sign in to the Docgen console, open API keys and create a test key. It's shown once; put it in your server's environment.

Terminal
export DOCGEN_API_KEY="dg_test_…"
Call the API from your server only. Requests from a browser are refused with secret_key_in_browser.

2. Start a session

Send your user's request as the first message, and name the user in Docgen-Subject. Use your own user ID, taken from your login (Subjects).

curl https://api.129.212.147.181.sslip.io/v1/sessions \  -H "Authorization: Bearer $DOCGEN_API_KEY" \  -H "Docgen-Subject: wp_user:48213" \  -H "Content-Type: application/json" \  -d '{  "message": "I need a residential lease for my condo in Miami, Florida"}'

You get back a turn. The assistant found a likely form and asks the user to confirm it, as a question of type form whose option values are form IDs:

201 Created (trimmed)
{  "object": "turn",  "reply": {    "text": "It sounds like you need a Residential Lease Agreement. Is that right?",    "question": {      "id": "form",      "type": "form",      "options": [        {          "value": "tpl_01JAZ7RKQ3M8D2X5V9T4N6P0CE",          "label": "Residential Lease Agreement"        },        {          "value": "other",          "label": "Something else"        }      ]    }  },  "session": {    "id": "ses_01JBA2M8K3Q4R5S6T7V8W9X0YZ",    "phase": "discovery",    "subject": "wp_user:48213"  }}

3. Answer the questions

Show reply.text and a control for reply.question, then send the user's choice as a typed answer with the option's value:

curl https://api.129.212.147.181.sslip.io/v1/sessions/ses_01JBA2M8K3Q4R5S6T7V8W9X0YZ/messages \  -H "Authorization: Bearer $DOCGEN_API_KEY" \  -H "Docgen-Subject: wp_user:48213" \  -H "Content-Type: application/json" \  -d '{  "answer": {    "question": "form",    "value": "tpl_01JAZ7RKQ3M8D2X5V9T4N6P0CE"  }}'

The session moves to intake and the reply asks the form's first question. Keep answering each reply.question, or send free text as text, until session.phase is ready. Sessions covers the details.

4. Generate the document

A ready session lists actions. Run document.generate: its request is the call below.

curl https://api.129.212.147.181.sslip.io/v1/documents \  -H "Authorization: Bearer $DOCGEN_API_KEY" \  -H "Docgen-Subject: wp_user:48213" \  -H "Idempotency-Key: lease-0001" \  -H "Content-Type: application/json" \  -d '{  "session": "ses_01JBA2M8K3Q4R5S6T7V8W9X0YZ"}'

The response comes back as soon as the job is queued:

202 Accepted
{  "id": "doc_01JB8ZQ0R7XKQ5V3M4N2P8T6WY",  "object": "document",  "status": "queued",  "template": "tpl_01JAZ7RKQ3M8D2X5V9T4N6P0CE@v1",  "session": "ses_01JBA2M8K3Q4R5S6T7V8W9X0YZ",  "jurisdiction": "US-FL",  "mode": "basic",  "formats": [    "pdf"  ],  "livemode": false,  "links": {    "self": "/v1/documents/doc_01JB8ZQ0R7XKQ5V3M4N2P8T6WY",    "stream": "/v1/documents/doc_01JB8ZQ0R7XKQ5V3M4N2P8T6WY/stream"  },  "created_at": "2026-10-07T10:44:12Z",  "expires_at": "2026-10-08T10:44:12Z"}

5. Download the files

Wait for status: "succeeded" by polling, or by streaming. Then download each file to your own storage.

cURL
curl https://api.129.212.147.181.sslip.io/v1/documents/doc_01JB8ZQ0R7XKQ5V3M4N2P8T6WY \  -H "Authorization: Bearer $DOCGEN_API_KEY"# → "status": "succeeded", "files": { "pdf": { "url": …, "expires_at": … } }
cURL
curl -o lease.pdf "$FILE_URL"   # the files.pdf.url from the response
Files are temporary. Links stop working at expires_at (7 days by default) and the files are deleted. We don't keep a copy, so download them straight away. Data lifetime →
PDF and HTML are available today. DOCX is on the way; until then, asking for it returns format_unavailable before anything is queued or billed.

Next steps