How to receive documents in binary format?

Help Center

DocuGenerate offers the flexibility of getting the generated documents in binary format rather than storing them in the cloud. By enabling this option when calling the generate document endpoint, you can obtain the binary representation of the generated document, whether it’s in PDF, Word, or another specified output format.

This approach is especially advantageous for privacy reasons, as documents are not stored anywhere in the cloud. Instead, they are delivered directly to you in binary form. To receive the binary response, ensure that you set the Accept header of your POST request to application/octet-stream. This signals the API to provide the binary document instead of the standard JSON response:

Accept: application/octet-stream

Here’s an example of getting the document in binary format when testing the API using Postman:

Create document by calling the API using Postman

Upon successful execution, the server’s response will include two additional headers:

  • Content-Disposition - This header specifies the filename of the generated document
  • X-Document-Id - This header contains the unique ID associated with the generated document

Request and response headers examples

If the filename of the generated document contains characters beyond the ASCII range (characters with codes 0 to 127), excluding those from the Latin-1 Supplement (ISO 8859-1), then the filename is URI-encoded when returned in the response headers. In this case, you need to URI-decode the filename to get its original value. Ensure that you handle URI decoding appropriately to obtain the correct filename.

Opting for binary retrieval enhances your document handling capabilities, ensuring both efficiency and privacy in your document generation process.