Guides

    Document lifecycle

    Step-by-step control over create, generate and export, for when one-shot generation isn't enough.

    Step-by-step control over the lifecycle, for when one-shot generation isn't enough — typically because you need to attach files and let DocDealer extract data from them first.

    Rendering diagram…
    From an empty document to a rendered file

    The attachment leg is covered in Attachments and OCR. If you have no attachments, skip to one-shot generation — it does the create and the generate together.

    Create a document

    curl
    curl -X POST https://thedocdealer.com/api/documents \
      -H "Authorization: Bearer $DOCDEALER_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"templateId": "<uuid>", "title": "Poder — Ana Torres", "type": "api"}'

    Returns { "documentId": "<uuid>", "success": true }. Omitting templateVersionId pins the document to the template's latest published version, and a template with no published version returns 404 — see Versioning.

    Keep that documentId. GET /api/documents returns an empty array for API-key callers — it lists the calling user's documents and a key has no user — so there is no way to list it back later.

    Generate

    POST /api/documents/generate with a documentId (rather than a templateId) pushes your formData, generates every applicable section, and renders the DOCX. See the quickstart for the key format, and Generation for what happens per section.

    Which sections are "applicable" is decided by the template's section visibility rules, not by you.

    Export

    POST /api/documents/export re-renders stored content in another format. It takes documentId and the document content HTML you want rendered, plus a type:

    typeReturns
    docDefault. A .docx byte stream.
    pdfA .pdf byte stream.
    allA ZIP with both plus every referenced attachment. Capped at 60 seconds.
    previewJSON { previewUrl, filename } for an Office-Online viewer, not bytes.

    Discovering the form schema

    Two ways in, depending on whether you want the shape or the state.

    GET /api/templates/{templateId} returns the template including formSchema, which holds objects (repeating groups) and fields. Each field's type tells you what a value looks like — see Templates and the form schema.

    Use this when you are building a static integration against a known template.