API: Document Generation That Scales with Your Business

    The Document Generation Challenge

    Your SaaS needs to generate invoices for thousands of customers. Your platform must create personalized certificates for course completions. Your CRM should produce proposals on demand. You need document generation that's programmable, reliable, and scales to millions of documents.

    Traditional designer tools like Canva require you to programmatically manipulate design elements—move text boxes, resize images, adjust layouts. This is complex, fragile, and slow. You need something better: send data, get documents. Simple.

    DocMiral's Data-Driven Paradigm

    DocMiral flips document generation on its head. Instead of manipulating designs, you work with structured data. Instead of building rendering infrastructure, you use our hosted platform. Instead of maintaining templates in code, designers manage them visually while you just call an API.

    The workflow is elegant: Templates define what documents look like and what data they need. Entities are the actual documents created by filling templates with your data. You send JSON, we return PDFs. That's it.

    Understanding Templates and Entities

    Templates: Think of templates as document blueprints. A template contains:

    • Visual Design: HTML with Tailwind CSS for rapid styling without writing custom CSS
    • Data Schema: JSON Schema that auto-generates from your template after building—no manual schema definition required
    • Flexible Schema Options: Choose between DocMiral MiniApps for UI-driven creation or your own custom JSON schema format when UI isn't important
    • Built-in Helpers: Use functions like qrcode(), barcode(), chart() instead of designing them manually
    • Static Asset Management: Upload images for each template and reference them via URLs for better asset organization
    • Logic: Jinja2 template syntax for conditionals, loops, and data manipulation

    Templates are version-controlled, shareable, and can be public (in our library) or private (your custom designs).

    Entities: Entities are the actual documents—instances created from templates. When you:

    • POST to /entities/build/pdf or /entities/build/image with template ID and data JSON
    • DocMiral validates your data against the template's auto-generated schema
    • Renders the template with your data
    • Instantly generates a PDF or image
    • Returns the document URL immediately

    Entities are stored, versioned, and can be regenerated or cloned with TARS AI assistance.

    Key Technical Features

    Tailwind CSS Integration: Style your templates with Tailwind utility classes instead of writing custom CSS. Rapid development with a modern, familiar framework.

    Auto-Generated Schemas: No need to manually define JSON schemas. Create your template, and DocMiral automatically generates the schema from your structure. Update the template, and the schema updates automatically.

    Schema Flexibility: Choose your approach based on your needs. Use DocMiral MiniApps for rich user interfaces when manual document creation is needed, or bring your own JSON schema format when you're purely focused on API-driven generation without UI concerns.

    Built-in Helper Functions: Generate complex elements instantly with helper functions: qrcode(data) for QR codes, barcode(number) for barcodes, chart(config) for data visualizations. No external libraries or image generation needed.

    Static Asset Management: Upload images directly to each template and reference them via clean URLs. Better asset organization, version control, and no broken image links as your templates evolve.

    MCP Server Integration: Leverage AI for template creation and modification using the DocMiral MCP server. Connect with Claude, GPT-4, or any MCP-compatible client to programmatically design, update, and optimize templates using natural language instructions.

    Three Paths to Implementation

    Path 1: Use the Public Template Library
    Browse our template library with hundreds of professionally designed templates: invoices, resumes, certificates, reports, proposals, and more. Pick a template, understand its auto-generated schema via the API, and start generating documents immediately. No design work needed.

    GET /templates?category=invoices
    → Returns available invoice templates

    POST /entities/build/pdf
    { "template": "invoice-modern", "data": {...} }
    → Instantly returns PDF URL

    Best for: Rapid prototyping, standard document needs, starting quickly without design resources.

    Path 2: Create Custom Templates
    Use our Studio interface to design templates from scratch with HTML and Tailwind CSS. The JSON schema auto-generates from your template structure. Optionally integrate MiniApps for manual document creation UIs. For AI-powered template creation, use the DocMiral MCP server with your preferred MCP client and language model to create or modify templates programmatically.

    POST /templates/
    { "name": "Company Invoice", "html": "..." }
    → Template created, schema auto-generated

    POST /entities/build/pdf
    { "template": "your-template-id", "data": {...} }
    → Returns PDF with your branding

    Best for: Full control over design, specific branding requirements, unique document structures, competitive differentiation.

    Path 3: Hybrid Approach
    Start with a public template, clone it, customize the design and schema to your needs, and save it as your private template. Get the speed of the library with the control of custom templates.

    Best for: Most companies—leverage proven designs, add your branding, tailor to specific workflows.

    Why DocMiral vs. Alternatives

    vs. Designer Tool APIs (Canva, Adobe Express):
    Designer tools require you to programmatically manipulate design elements—move text boxes, resize images, adjust layouts. This is fragile, complex, and slow. DocMiral is data-driven: you send structured JSON, we handle rendering. Templates define the layout; you provide the content. Clean separation, simple integration.

    Advantage: 10x simpler integration, deterministic output, no design complexity in your code.

    vs. Document Assembly Tools (Docmosis, Carbone, Windward):
    Traditional tools use complex proprietary template syntax and require manual schema definition. DocMiral uses familiar HTML with Tailwind CSS, auto-generates schemas, and provides built-in helpers for QR codes, barcodes, and charts. Plus, leverage AI via our MCP server for template creation and modification.

    Advantage: Modern web standards, auto-generated schemas, built-in helpers, AI-powered workflows, faster implementation.

    vs. Template.io, PDFMonkey, and similar services:
    Other services lock you into their template editors and limited customization options. DocMiral gives you full HTML/Tailwind control, static asset management, flexible schema options (MiniApps or custom JSON), and programmatic template creation via MCP server.

    Advantage: No vendor lock-in, full design control, extensible architecture, AI integration.

    Common Use Cases

    • Invoice & Receipt Automation: Generate invoices from your billing system. POST transaction data, get professional PDFs instantly.
    • Certificate Generation: Issue course completion certificates, achievement badges, or compliance certifications at scale.
    • Report Automation: Transform business data into formatted reports. Analytics dashboards generate PDF reports on demand.
    • Contract Generation: Create agreements, proposals, and legal documents from structured deal data in your CRM.
    • Marketing Collateral: Generate personalized brochures, one-pagers, or presentations for sales teams.
    • Resume/CV Services: Power job platforms or HR tools with professional resume generation from user profiles.
    • Educational Content: Generate worksheets, lesson plans, or study materials from content databases.

    Technical Architecture

    RESTful API: Standard HTTP methods, JSON payloads, predictable endpoints. See our complete API documentation with interactive examples.

    Authentication: JWT tokens for user sessions, dedicated API keys for server-to-server integration. OAuth 2.0 support for third-party applications.

    Scalability: Designed to handle millions of documents. Asynchronous rendering for bulk operations. CDN-backed file delivery.

    Versioning: Templates are versioned. Entities link to specific template versions, ensuring consistency even as templates evolve.

    Webhooks: Get notified when document generation completes, perfect for async workflows in high-volume scenarios.

    Getting Started: From Zero to Production

    1. Create Account: Sign up and access your dashboard at /profile/dashboard
    2. Generate API Key: Navigate to /profile/apikeys and create your first API key
    3. Browse Templates: Explore our template library or create your own in Studio
    4. Read API Docs: Check the complete API reference for endpoints, schemas, and examples
    5. Make First Request: POST to /entities/build/pdf with your template ID and data
    6. Integrate: Add DocMiral to your application workflow—CRM, billing system, reporting tools, wherever documents are needed

    Example: Instant Invoice Generation

    // Choose a template from the library

    GET /templates?category=invoices

    // Instantly generate PDF from your data

    POST /entities/build/pdf

    {

    "templateId": `TEMPLATE_ID`,

    "data": {

    "invoiceNumber": "INV-2025-001",

    "customer": {

    "name": "Acme Corporation",

    "address": "123 Business St"

    },

    "items": [

    { "description": "Web Development", "quantity": 40, "price": 150 },

    { "description": "Design Services", "quantity": 20, "price": 120 }

    ],

    "total": 8400

    }

    }

    // Response with instant PDF URL

    {

    "status": 1,

    "data": {

    "id": "entity-abc123",

    "file_url": "https://storage.docmiral.com/files/invoice-001.pdf"

    }

    }

    // Or generate as image instead

    POST /entities/build/image

    // Same payload, returns PNG/JPG URL

    Bottom line: DocMiral's API transforms document generation from a complex engineering challenge into a simple data problem. Send JSON, get professional PDFs. Whether you're generating 10 documents a month or 10 million, whether you use our templates or build your own, DocMiral scales with your business. Explore our complete API documentation to get started.