Copy a document as a new draft
A new draft from any document, in any status: draft, sent, finished, declined, expired or cancelled. The original keeps its state; only the copy is new. The PDF is copied file to file from this document's own copy, so field changes made on this document come along.
| Copied | Not copied |
|---|---|
| The PDF, roles, fields, signing order, message, reminder setting, the template it came from | The people (every role starts empty), the values you filled in, the sign-by date, delivery (the copy uses email) and the send-from address and number |
The copy is named after the original with " (copy)" and starts with a
created event whose data.duplicatedFrom is this document's id.
To change a sent document's PDF, copy it, then replace the copy's PDF.
Permission: signing:read @ workspace/{workspaceId}/signingRequest/{signingRequestId}
and signing:send @ workspace/{workspaceId}. Both are checked.
Get the document ID first
curl "$HOS_API/signing/requests?workspaceId=ws_a1b2c3" \ -H "Authorization: Bearer $HOS_KEY"Copy it
curl -X POST "$HOS_API/signing/requests/req_a1b2c3/duplicate?workspaceId=ws_a1b2c3" \ -H "Authorization: Bearer $HOS_KEY"Authorization
ServiceAccountKey A service account API key, sent whole as a bearer token:
hsk_<40 hex>.hss_<64 hex>.
In: header
Path Parameters
The document to act on. IDs come from List documents.
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.
Response Body
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/signing/requests/sZG0nWcpWKBF7zT8CqcN/duplicate?workspaceId=ws_a1b2c3"{ "success": true, "request": { "id": "string", "templateId": "string", "templateName": "string", "name": "string", "message": "string", "status": "draft", "order": "parallel", "delivery": "email", "sendFrom": { "email": "[email protected]", "phone": "string" }, "layoutVersion": 0, "layoutChangedBy": null, "previousPdfs": [ { "sha256": "string", "fileName": "string", "pageCount": 0, "replacedAt": "2019-08-24T14:15:22Z", "replacedBy": "string" } ], "snapshot": { "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 } ] }, "signerSummary": { "total": 0, "completed": 0 }, "prefills": { "property1": "string", "property2": "string" }, "prefillEditable": [ "string" ], "expiresAt": "2019-08-24T14:15:22Z", "remindEveryDays": 2, "createdAt": "2019-08-24T14:15:22Z", "sentAt": "2019-08-24T14:15:22Z", "allSignedAt": "2019-08-24T14:15:22Z", "completedAt": "2019-08-24T14:15:22Z", "declinedAt": "2019-08-24T14:15:22Z", "voidedAt": "2019-08-24T14:15:22Z", "expiredAt": "2019-08-24T14:15:22Z", "result": null, "finalizeError": "string" }}Replace a draft's PDF POST
Drafts only. A document that has been sent never changes. 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. The template the draft came from is not changed. A value you filled in goes with its field: it is removed with a deleted field and kept with a moved one. The replace is listed in the document's events (`pdf_replaced`) and in the audit pages of the finished document. **What changes.** The draft's file is overwritten at the same place. `snapshot.pdf` describes the new file, `layoutVersion` goes up by one (an editor holding the old version gets a 409 on its next save), and `previousPdfs` gains a note of the old file. People, the message and the other settings stay as they are. **Do it in this order.** Save your changes to the draft first: the replace works on the saved fields. One replace runs at a time per draft. To change a sent document, make a new draft with [Copy a document as a new draft](/docs/api-reference/signing/documents/duplicateSigningRequest) and replace that draft's PDF. **Permission:** `signing:send` @ `workspace/{workspaceId}/signingRequest/{signingRequestId}` #### Get the document ID first ```bash curl "$HOS_API/signing/requests?workspaceId=ws_a1b2c3" \ -H "Authorization: Bearer $HOS_KEY" ``` #### Request ```bash curl -X POST "$HOS_API/signing/requests/req_a1b2c3/pdf?workspaceId=ws_a1b2c3" \ -H "Authorization: Bearer $HOS_KEY" \ -F "[email protected]" \ -F "missingPageFields=delete" ``` `missingPageFields` is needed only when fields sit on pages the new file does not have. Without it, that case answers 409 with `needsChoice` and changes nothing.
Save a document as a new template POST
A new template from this document's PDF, roles and fields, in any status. It never changes an existing template, including the one the document came from. The PDF is copied file to file from this document's own copy, so a draft whose PDF was replaced becomes a template with the new file. Not copied: the people, the values you filled in, the message, the sign-by date, reminders and the signing order. The roles and fields go through the same check as a template save, so a document whose fields would not pass that check answers 400. **Permission:** `signing:read` @ `workspace/{workspaceId}/signingRequest/{signingRequestId}` and `signing:manage` @ `workspace/{workspaceId}`. Both are checked.