Template Export
Export a template as a PDF or plain text file programmatically.
Overview
The export endpoint compiles one of your templates and returns it as a downloadable file. You supply the template's variables in the request body, and the rendered document is returned in the format you request.
All requests must be authenticated with an API key. See Authentication for how to create one.
Endpoint
POST /api/tasks/{templateId}/exportReplace {templateId} with the ID of the template you want to export.
Query parameters
format— the output format, eitherpdfortxt. Defaults topdfwhen omitted.
Request body
The body is a JSON object with a single variables field. It maps each variable name to a string or boolean value. Any variables you omit fall back to the template's configured defaults.
{
"variables": {
"<variable-name>": "<string | boolean>"
}
}If your template has no variables, send an empty object: { "variables": {} }.
Example
curl -X POST \
"https://www.hardcopies.net/api/tasks/TEMPLATE_ID/export?format=pdf" \
-H "Authorization: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "variables": { "includeNotes": true, "owner": "Alex" } }' \
--output tasks.pdfResponse
On success the endpoint returns 200 OK with the rendered file as the body. The response is sent as an attachment named tasks-YYYY-MM-DD.pdf or tasks-YYYY-MM-DD.txt depending on the requested format.
| Format | Content-Type |
|---|---|
pdf | application/pdf |
txt | text/plain |
Errors
Errors are returned as JSON with an error message. Validation errors also include an issues array describing what went wrong.
| Status | Description |
|---|---|
400 Bad Request | The request body is malformed, or the supplied variables are invalid or fail to compile the template. |
401 Unauthorized | The API key is missing or invalid. |
404 Not Found | No template matches the given templateId. |
429 Too Many Requests | The API key has exceeded its rate limit. |
500 Internal Server Error | An unexpected error occurred while generating the export. |