Skip to content

Render a Screenshot or a PDF from a Template

With the Template API, you can render a PDF or a screenshot from a stored template.

Templates can be dynamic, with data injected at render time.

To do this, we:

  • Replace the {* DOP_XXX *} tags in your template with the data you provide in the API request. Objects are JSON-stringified.
  • Inject all your data into the global window.doppioData object so you can handle it manually if needed.

Routes

Templates are defined as either PDF or screenshot templates when they are created. Unlike the classic render routes, template routes therefore do not include /pdf/ or /screenshot/ in the URL.

Method: POST

  • Template direct render Route: api.doppio.sh/v1/template/direct
  • Template sync render Route: api.doppio.sh/v1/template/sync
  • Template async render Route: api.doppio.sh/v1/template/async

Request body

json
{
    "templateId": "80d89528-5d3d-4310-be1a-efc349389841", // Your template ID
    "templateData": { // Object containing the data to inject into the template
        "DOP_name": "Renaud", // Replaces {* DOP_name *} with "Renaud"
        "DOP_RANDOM_STUFF": { // Replaces {* DOP_RANDOM_STUFF *} with the JSON-stringified object
            "myKey": "myValue"
        }
    },
    "doppio": { // OPTIONAL: define or override presignedUrl during the template request
        "presignedUrl": "https://your-bucket-name.s3.amazonaws.com/your-object-key?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=*REDACTED*%2F20240315%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240315T120000Z&X-Amz-Expires=300&X-Amz-Signature=*REDACTED*&X-Amz-SignedHeaders=host;content-length;content-type&content-type=application%2Foctet-stream"
    }
}

Response

Responses follow the same structure as the classic routes, depending on the render method: /direct, /sync, or /async.

For the full list of possible response codes, see What to expect from us.



/sync Render Response

If the request succeeds, Doppio responds with the following payload:

Property nameTypeDescription
doppioRequestIdstringUnique identifier for the request.
renderStatusstringRendering status for your document. Either SUCCESS or ERROR.
documentUrlstringURL where you can access the rendered document.
isAsyncbooleanWhether the request is asynchronous. For this render method, the value is always false.
isCustomBucketbooleanWhether the document is stored in your own S3 bucket or temporarily in ours.

/async Render Response

If the request succeeds, Doppio responds with the following payload:

Property nameTypeDescription
requestIdstringUnique identifier for the request. Used to associate it with the webhook call.
jobIdstringIdentifier for the render job. Save it in case you need to contact us about your request.

/direct Render Response

If the request succeeds, Doppio responds with your rendered document.

All rights reserved