Documents

Generate a new PDF document from a project template. This allows you to programatically generate various types of documents such as invoices, reports, and forms. By using a project template, you can customize the layout and content of your document. This is useful for businesses that need to generate a large number of similar documents with different data. To create a document, visit the dashboard.


POST/v1/api/generate

Generate a document

This endpoint allows you to generate a new document from a project template, allowing for custom values for variables in your code. The generated document will be returned as a URL to a PDF file.

Authorizations

  • Name
    Authorization
    Type
    string
    header
    required
    Description

    Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Required attributes

  • Name
    projectId
    Type
    string
    Description

    The project ID (ex. 123e4567e89b12d3a456426655440000)

  • Name
    path
    Type
    string
    Description

    The path to the .html file to render (ex. index.html)

  • Name
    context
    Type
    object
    Description

    A dictionary that maps variables defined in the document to values to be substituted. For example, {{name}} will be replaced with the value of context['name'].

Response attributes

  • Name
    url
    Type
    string
    Description

    The URL of the generated document.

  • Name
    error
    Type
    string | null
    Description

    The error message, if any.

Request

POST
/v1/api/generate
curl --request POST \
     --url https://api.htmldocs.com/v1/api/generate \
     --header 'Authorization: <authorization>' \
     --header 'Content-Type: application/json' \
     --data '{
       "context": {},
       "path": "index.html",
       "projectId": "123e4567e89b12d3a456426655440000"
     }'

Response

{
  "url": "https://htmldocs.s3.amazonaws.com/path/to/result.pdf",
  "error": null
}

Was this page helpful?