Replace a draft's PDF

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 and replace that draft's PDF.

Permission: signing:send @ workspace/{workspaceId}/signingRequest/{signingRequestId}

Get the document ID first

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

Request

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.

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

signingRequestId*string

The document to act on. IDs come from List documents.

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

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

POSTReplace a draft's PDF
curl -X POST "https://example.com/signing/requests/sZG0nWcpWKBF7zT8CqcN/pdf?workspaceId=ws_a1b2c3" \  -F file="string"
{  "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"  },  "signers": [    {      "id": "string",      "roleId": "string",      "name": "string",      "email": "string",      "contactId": "string",      "phone": "string",      "order": 0,      "status": "pending",      "consentAt": "2019-08-24T14:15:22Z",      "openedAt": "2019-08-24T14:15:22Z",      "lastEmailAt": "2019-08-24T14:15:22Z",      "lastSmsAt": "2019-08-24T14:15:22Z",      "lastLinkAt": "2019-08-24T14:15:22Z",      "completedAt": "2019-08-24T14:15:22Z",      "declinedAt": "2019-08-24T14:15:22Z",      "declineReason": "string",      "ip": "string",      "userAgent": "string",      "timezone": "string",      "remindersSent": 0,      "nextReminderAt": "2019-08-24T14:15:22Z"    }  ],  "report": {    "oldPageCount": 0,    "newPageCount": 0,    "removedPages": [      0    ],    "resizedPages": [      0    ],    "fieldsOnMissingPages": [      "string"    ],    "movedFieldIds": [      "string"    ],    "deletedFieldIds": [      "string"    ],    "fileName": "string",    "sha256": "string",    "previousSha256": "string"  }}
POST
/signing/requests/{signingRequestId}/pdf

Download a document's PDF GET

The document's own copy of the PDF, before signing. For the signed result use [Download the finished PDF](/docs/api-reference/signing/finished-documents/downloadSigningResult). **Permission:** `signing:read` @ `workspace/{workspaceId}/signingRequest/{signingRequestId}`

Copy a document as a new draft POST

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](/docs/api-reference/signing/documents/replaceSigningRequestPdf). **Permission:** `signing:read` @ `workspace/{workspaceId}/signingRequest/{signingRequestId}` and `signing:send` @ `workspace/{workspaceId}`. Both are checked. #### Get the document ID first ```bash curl "$HOS_API/signing/requests?workspaceId=ws_a1b2c3" \ -H "Authorization: Bearer $HOS_KEY" ``` #### Copy it ```bash curl -X POST "$HOS_API/signing/requests/req_a1b2c3/duplicate?workspaceId=ws_a1b2c3" \ -H "Authorization: Bearer $HOS_KEY" ```