You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何使用DocuSign API将已签署文档下载为合并PDF文件

Can I download signed documents as a single merged PDF via DocuSign API?

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:

  1. Authenticate your request
    Ensure you have a valid access token with the envelopes:read scope (required to retrieve envelope documents).

  2. Call the combined documents endpoint
    Use a GET request to the following endpoint, replacing {accountId} and {envelopeId} with your actual values:

    GET /v2.1/accounts/{accountId}/envelopes/{envelopeId}/documents/combined
    

    Include 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.pdf
    
  3. Handle 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=false to 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

火山引擎 最新活动