Documents

Create a document

POST https://api.129.212.147.181.sslip.io/v1/documents

Generates a document from a ready session; send Docgen-Subject with it. Returns at once with status: "queued"; send Accept: text/event-stream to stream it instead (same events as GET /v1/documents/{document}/stream).

A session can make any number of documents (another mode, another format); each appears in the session's outputs.

Headers

Authorization string required
Bearer dg_test_… or Bearer dg_live_…
Docgen-Subject string optional
Your reference for the end user (a user ID, a hash; never an email). A session is bound to the subject it was created with, and every call on it must send the same value or it is 404. Set it from your own login, never from what the browser sent. Required to create and list sessions unless your organisation has subjects turned off.
Idempotency-Key string optional
Retrying with the same key and body returns the original response. Kept 24 hours.

Body

session string required
A ready session. Its form and answers are used; send Docgen-Subject too.
mode enum
basic drafts quickly from the answers; advanced drafts against current state law. Defaults to basic, or advanced for a form filed on its official PDF, which offers only that (see the session's document.generate action). One of basic, advanced
formats array of enums default ["pdf"]
One of pdf, docx, html
lifetime_seconds integer
How long file links live, up to your plan maximum (7 days).
metadata Metadata object
Up to 20 keys of your own, echoed back and shown in logs. Don't put personal data here.

Returns

202 Accepted: a Document object. Queued. With Accept: text/event-stream, the event stream instead.

Errors

StatusCodeWhat to do
422parameter_missingPass session.
422parameter_invaliderror.fields names the bad parameter (mode, formats, lifetime_seconds, metadata).
422format_unavailableDOCX is not available yet; ask for pdf or html. A form filed on its official PDF (a deed, for example) comes only as pdf.
422mode_unavailableA form filed on its official PDF comes only in advanced mode, which is its default. The session's document.generate action lists the modes and formats a form offers.
409session_not_readyThe session is still finding the form or asking questions; pending_question is what is left.
404session_not_foundCheck the ID, and that Docgen-Subject is the subject the session was created for.
410session_deletedThe session was deleted with its conversation and answers. Start a new one.
503provider_unavailableNo model is configured for live keys yet. Use a test key.

Any endpoint can also return the common errors (bad key, rate limit, idempotency).