Replace a template's PDF
Puts a new PDF behind the same fields. Every field keeps its place on the
page: positions are fractions of the page, so nothing is converted. The new
file replaces the old one; only a note of the old file is kept
(previousPdfs). The usual limits apply: 25 MB, 200 pages, no password.
Fields on pages the new file does not have. If the new PDF has fewer
pages and fields sit on the missing pages, send missingPageFields:
delete removes them, lastPage moves them to the new last page at the same
position (they can overlap boxes already there). Without it the answer is
409 with needsChoice: true and the report, and nothing is changed.
A page that exists in both files but changed size is not refused. It is
listed in report.resizedPages: check the fields there.
Send workspaceId in the query string.
Documents already made from this template keep their own copy and do not change.
What changes. The file is overwritten at the same place, so the
template's id and download link stay the same. pdf describes the new
file. layoutVersion goes up by one, so an editor holding the old
version gets a 409 on its next save and must read the template again.
previousPdfs gains a note of the old file. Fields keep their fieldId,
moved ones included.
Do it in this order. Save your field changes first: the replace works on the saved fields. One replace runs at a time per template.
HumaDocs never edits the text inside a PDF. Change the file elsewhere, then replace it.
Permission: signing:manage @ workspace/{workspaceId}/signingTemplate/{signingTemplateId}
Get the template ID first
curl "$HOS_API/signing/templates?workspaceId=ws_a1b2c3" \ -H "Authorization: Bearer $HOS_KEY"Request
curl -X POST "$HOS_API/signing/templates/tpl_a1b2c3/pdf?workspaceId=ws_a1b2c3" \ -H "Authorization: Bearer $HOS_KEY" \ -F "[email protected]"When the answer is 409 with needsChoice
Send the same file again with the choice. Nothing changed the first time.
curl -X POST "$HOS_API/signing/templates/tpl_a1b2c3/pdf?workspaceId=ws_a1b2c3" \ -H "Authorization: Bearer $HOS_KEY" \ -F "[email protected]" \ -F "missingPageFields=lastPage"After lastPage, report.movedFieldIds lists the fields to move off
anything they now overlap.
Authorization
ServiceAccountKey A service account API key, sent whole as a bearer token:
hsk_<40 hex>.hss_<64 hex>.
In: header
Path Parameters
The template to act on. IDs come from List templates.
Query Parameters
The workspace the template or document belongs to. Send it in the query string on every call, including the PDF upload. IDs come from List workspaces.
Request Body
multipart/form-data
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/signing/templates/RVeFlYdDGgoESUXespsR/pdf?workspaceId=ws_a1b2c3" \ -F file="string"{ "success": true, "template": { "id": "string", "name": "string", "description": "string", "pdf": { "fileName": "string", "pageCount": 0, "pageSizes": [ { "w": 0, "h": 0 } ], "sha256": "string", "md5": "string", "bytes": 0 }, "roles": [ { "roleId": "client", "label": "Client", "order": 1 } ], "fields": [ { "fieldId": "client_sig", "roleId": "client", "type": "signature", "label": "string", "required": true, "page": 0, "x": 0, "y": 0, "w": 0, "h": 0 } ], "createdAt": "2019-08-24T14:15:22Z", "updatedAt": "2019-08-24T14:15:22Z", "archivedAt": "2019-08-24T14:15:22Z", "layoutVersion": 0, "layoutChangedBy": null, "duplicatedFrom": "string", "previousPdfs": [ { "sha256": "string", "fileName": "string", "pageCount": 0, "replacedAt": "2019-08-24T14:15:22Z", "replacedBy": "string" } ] }, "report": { "oldPageCount": 0, "newPageCount": 0, "removedPages": [ 0 ], "resizedPages": [ 0 ], "fieldsOnMissingPages": [ "string" ], "movedFieldIds": [ "string" ], "deletedFieldIds": [ "string" ], "fileName": "string", "sha256": "string", "previousSha256": "string" }}Download a template's PDF GET
The original PDF, as uploaded. **Permission:** `signing:read` @ `workspace/{workspaceId}/signingTemplate/{signingTemplateId}`
Copy a template POST
A new template with the same PDF, roles, fields and description. The PDF is copied file to file, so the copy has its own file. The original is not changed. | | The copy | | --- | --- | | `name` | Your `name`, or the original's name with " (copy)" | | `duplicatedFrom` | The original's `id` | | `layoutVersion` | Starts at 0 | | `previousPdfs` | Empty: that history belongs to the original | | `archivedAt` | `null`, even when the original is archived | An archived template can be copied, which is how an old layout comes back. **New wording, same layout, keep the old template.** Copy it, then [replace the copy's PDF](/docs/api-reference/signing/templates/replaceSigningTemplatePdf). The console's **Duplicate and replace** does exactly these two calls. **Permission:** `signing:read` @ `workspace/{workspaceId}/signingTemplate/{signingTemplateId}` and `signing:manage` @ `workspace/{workspaceId}`. Both are checked. #### Get the template ID first ```bash curl "$HOS_API/signing/templates?workspaceId=ws_a1b2c3" \ -H "Authorization: Bearer $HOS_KEY" ``` #### Copy it ```bash curl -X POST "$HOS_API/signing/templates/tpl_a1b2c3/duplicate?workspaceId=ws_a1b2c3" \ -H "Authorization: Bearer $HOS_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Service agreement 2027" }' ``` #### Replace the copy's PDF Use the `template.id` from the answer. ```bash curl -X POST "$HOS_API/signing/templates/tpl_d4e5f6/pdf?workspaceId=ws_a1b2c3" \ -H "Authorization: Bearer $HOS_KEY" \ -F "[email protected]" ```