如何使用DocuSign API将已签署文档下载为合并PDF文件
Absolutely! You can totally download all signed documents from a DocuSign envelope as a single merged PDF using the eSignature API—this is a common use case, and it’s straightforward to implement.
How to do it:
The key is using the combined documents endpoint, which returns all envelope documents merged into one PDF file. Here’s a breakdown of the steps:
Authenticate your request
Ensure you have a valid access token with theenvelopes:readscope (required to retrieve envelope documents).Call the combined documents endpoint
Use aGETrequest to the following endpoint, replacing{accountId}and{envelopeId}with your actual values:GET /v2.1/accounts/{accountId}/envelopes/{envelopeId}/documents/combinedInclude these headers:
Authorization: Bearer {your_access_token}Accept: application/pdf
Example curl command to save the merged PDF directly:
curl --request GET \ --url 'https://demo.docusign.net/restapi/v2.1/accounts/{accountId}/envelopes/{envelopeId}/documents/combined' \ --header 'Authorization: Bearer {your_access_token}' \ --header 'Accept: application/pdf' \ --output merged_signed_documents.pdfHandle the response
The response will be binary PDF data. You can save this to a file, stream it to a user for download, or process it as needed in your application.
Additional tips:
- Including/excluding the completion certificate: By default, the merged PDF includes the DocuSign Certificate of Completion. To exclude it, add the query parameter
include_certificate=falseto the endpoint URL. - SDK support: All official DocuSign SDKs (Python, JavaScript, C#, etc.) wrap this endpoint for easier use. For example, in Python:
from docusign_esign import ApiClient, EnvelopesApi api_client = ApiClient() api_client.host = "https://demo.docusign.net/restapi" api_client.set_default_header("Authorization", "Bearer " + your_access_token) envelopes_api = EnvelopesApi(api_client) merged_pdf = envelopes_api.get_combined_documents(account_id, envelope_id) # Save to file with open("merged_signed_docs.pdf", "wb") as file: file.write(merged_pdf) - Envelope status: This works for fully signed envelopes. If the envelope is still in progress, the merged PDF will reflect the current state of all documents (e.g., unfilled fields, unsigned pages).
内容的提问来源于stack exchange,提问作者Ishita




