Copy a template

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
nameYour name, or the original's name with " (copy)"
duplicatedFromThe original's id
layoutVersionStarts at 0
previousPdfsEmpty: that history belongs to the original
archivedAtnull, 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. 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

curl "$HOS_API/signing/templates?workspaceId=ws_a1b2c3" \  -H "Authorization: Bearer $HOS_KEY"

Copy it

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.

curl -X POST "$HOS_API/signing/templates/tpl_d4e5f6/pdf?workspaceId=ws_a1b2c3" \  -H "Authorization: Bearer $HOS_KEY" \  -F "[email protected]"

Authorization

ServiceAccountKey
AuthorizationBearer <token>

A service account API key, sent whole as a bearer token: hsk_<40 hex>.hss_<64 hex>.

In: header

Path Parameters

signingTemplateId*string

The template to act on. IDs come from List templates.

Query Parameters

workspaceId*string

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

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

POSTCopy a template
curl -X POST "https://example.com/signing/templates/RVeFlYdDGgoESUXespsR/duplicate?workspaceId=ws_a1b2c3" \  -H "Content-Type: application/json" \  -d '{}'
{  "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"      }    ]  }}
POST
/signing/templates/{signingTemplateId}/duplicate

Replace a template's PDF POST

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 ```bash curl "$HOS_API/signing/templates?workspaceId=ws_a1b2c3" \ -H "Authorization: Bearer $HOS_KEY" ``` #### Request ```bash 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. ```bash 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.

Check a template's roles and fields POST

Runs the same check a save runs, and saves nothing. Send `roles` and `fields` to check a change; leave either out to use what is stored. **Permission:** `signing:read` @ `workspace/{workspaceId}/signingTemplate/{signingTemplateId}`