Assemble Document
The Assemble Document method is used to produce a completed document, by merging answer data with a HotDocs template. The completed document can be assembled in different formats, such as DOCX and PDF.
Assemble Document Output
The documents produced by the AssembleDocument method can be output in different formats, including DOCX, PDF, and HTML. See output format for a full list of available formats.
Answer Output
You may need to output the answers used in an assembly instead of a completed document. To output Answer XML, specify the Answers output format in the format parameter when making a request.
Assemble Document POST
HTTP Request
POST https://{subscribedEndpoint}/hdcs/assemble/{subscriberID}/{packageID}/{templatename=null}
Parameters
Name | Location | Required | Description |
subscribedEndpoint | Path | Yes |
The endpoint to which the caller is subscribed. This is either:
|
subscriberID | Path | Yes |
The caller's Cloud Services subscriber ID |
packageID | Path | Yes | An ID identifying the package containing the template from which you wish to assemble a document. This is set when uploading the package file. If you are using the HotDocs Hub to store templates, see Get a Package ID from HotDocs Hub. |
templatename | Path | No | The file name of the specific template from which you are requesting to assemble a document. This can be omitted to automatically request an assembly from the primary template in the package. |
date | HTTP header or query string | Yes | The date and time (in UTC) of the request, formatted according to RFC 1123. This date can be included either as a parameter on the query string or in an "x-hd-date" (custom) HTTP header. |
signature | HTTP header | Yes | The base64-encoded HMAC calculated using the parameters of this request. Note: the HMAC must be included in an "Authorization" HTTP header. See HMAC Calculation for Assemble Document for more information. |
format | Query string | No | The output format requested. For example, DOCX for a Microsoft Word document.
Use the Answers output format to output the Answer XML string used by the assembly |
billingRef | Query string | No | Enables you to specify information to include in usage logs for this call. For example, you can use a string to uniquely identify the end user that initiated the request and/or the context in which they made the call. When you later review usage logs, you can see which end users initiated each request. This information can enable you to audit or pass costs on to those end users. |
encodeFileNames | Query string | Yes | Either True (encoded) or False (unencoded). Indicates whether filenames in the returned multi-part MIME document are encoded. All new integrations with Cloud Services must encode file names. Unencoded file names are for legacy integrations only. If True, the filenames are first encoded in UTF-8, then URL-encoded. This allows any special character valid in a file name to be passed back in the Response. This flag is useful as special characters can lead to errors when parsing the response back from the server, if filenames are not encoded properly. If retrieved files are saved to disk, the file names should be decoded before writing to disk. |
RetrieveFromHub |
Query string |
No |
Enables you to retrieve a HotDocs template from the HotDocs Hub instead of a template stored in the Cloud Services cache. Select from the following options (case-insensitive):
|
(additional settings) | Query string | No | You can also optionally include on the query string any document assembly settings from those listed in AssembleDocumentOptions.Settings. Settings specified on the query string will override the defaults designated in the Cloud Services administration portal. |
answers | Request body | No | You must supply the XML answer string used in the assembly in the request body. You must also add the appropriate Content-Type header to the request (see below). |
Example URL
https://cloud.hotdocs.ws/hdcs/assemble/examplesubscriber/ed40775b-5e7d-4a51-b4d1-32bf9d6e9e29?format=Native&billingRef=exampleBillingRef
Response
If successful, this method returns a multi-part MIME document in the response body. Each MIME part corresponds to a document/attachment in a requested output format.
Request Headers
When making an Assemble request to Cloud Services, the request must include the following headers.
Name |
Type |
Example Data |
Description |
Example (C#) |
x-hd-date |
DateTime value |
2015-01-31T08:55:19Z |
A Date and Time for the request. This is the same value as the date/time used when calculating the HMAC. |
request.Headers.Add("x-hd-date", timestamp.ToString("yyyy-MM-ddTHH:mm:ssZ")); |
Content-Type |
String |
text/xml |
The type of content being sent with the request. For document assembly, the content is HotDocs Answer XML. |
request.Headers.Add("Content-Type", "text/xml"); |
Authorization |
String |
Calculated HMAC |
The HMAC used to sign the request. |
request.Headers.TryAddWithoutValidation("Authorization", hmac); |
Keep-Alive |
Boolean |
false |
The connection to Cloud Services should not be a persistent connection when assembling a document, as only a single request is being made. |
request.Headers.Add("Keep-Alive", "false"); |
Example Request
POST https://cloud.hotdocs.ws/hdcs/assemble/examplesubscriber/ed40775b-5e7d-4a51-b4d1-32bf9d6e9e29?format=Native&UnansweredFormat=[Variable] HTTP/1.1
x-hd-date: 2015-07-13T10:09:35Z
Authorization: L+pdiZ7UZ8xbVG66LyYaS30JF94=
Keep-Alive: false
Content-Type: text/plain; charset=utf-8
Host: cloud.hotdocs.ws
Content-Length: 165Expect: 100-continue
Connection: Keep-Alive
Hello World
HMAC Calculation for Assemble Document
For calls to Assemble a document, the HMAC is calculated from the following list of parameters:
Name |
Type |
Example Data |
Description |
signingKey |
String |
example-signing-key |
The Signing Key assigned to your Cloud Services account. You can find your Signing Key by logging in to the Cloud Services Portal. |
date |
DateTime |
2015-01-31T08:55:19Z |
Date and time, using the format "yyyy-MM-ddTHH:mm:ssZ". For example, a datetime of 31/05/2015 08:55:19 is formatted as 2015-01-31T08:55:19Z. |
subscriberID |
String |
ExampleCompany |
Subscriber ID named used to connect to Cloud Services. This was provided when you signed up to Cloud Services. |
packageID |
String |
ed40775b-5e7d-4a51-b4d1-32bf9d6e9e29 |
The name of the HotDocs Package File (.hdpkg) uploaded to Cloud Services. |
templateName |
String |
"" |
A string value. The name of the template in the package file that is to be assembled. If there is only one template in the package, an empty string is used. |
sendPackage |
Boolean |
False |
A boolean value. For assembling a document in Cloud Services, this is always False. |
billingRef |
String |
ExampleCustomer, Template Upload |
Enables you to specify information to include in usage logs for this call. For example, you can use a string to uniquely identify the end user that initiated the request and/or the context in which they made the call. When you later review usage logs, you can see which end users initiated each request. This information can enable you to audit or pass costs on to those end users. |
format |
String |
Native |
The format of the assembled document. |
settings | String | AddHdMainDiv=true\nUnansweredFormat=[Variable] |
A string containing assembly settings, to control assembly behaviour, separated by a newline character. These include URLs for retrieving JavaScript and stylesheets. If you are not using any assembly settings, you must use an empty string to calculate the HMAC. |
Example (C#)
Walkthrough
For a full walkthrough of calculating the HMAC and assembling a document in Cloud Services, see the Cloud Services Example 2: Assemble a Document article in the HotDocs Integrations documentation.
Code
For a full code example of assembling a document in Cloud Services, see the CloudServicesAPIExample2DocumentAssemble project in the HotDocs Integration Examples.