Skip to content

Bug: envelopes.items.download() fails on binary PDF responses #11

@jasjastone

Description

@jasjastone

SDK Version

documenso_sdk (Python) — latest as of 2026-02-28

Description

documenso.envelopes.items.download() throws an error when the Documenso API correctly responds with a PDF file (Content-Type: application/pdf). The SDK does not handle binary responses, interpreting the raw PDF bytes as a text/JSON body and raising an unexpected response error.

Steps to Reproduce

from documenso_sdk import Documenso
import documenso_sdk

with Documenso(api_key="<API_KEY>", server_url="https://sign.example.com") as client:
    data = client.envelopes.items.download(
        envelope_item_id="envelope_item_xxxxxxxxxxxx",
        version=documenso_sdk.EnvelopeItemDownloadVersion.SIGNED,
    )

Expected Behavior

Returns the signed PDF content as bytes.

Actual Behavior

Unexpected response received: Status 200 Content-Type application/pdf.
Body: %PDF-1.7
%����
1 0 obj
<<
/Type /Pages
...

The SDK treats the raw PDF binary data as an error body and raises an exception.

Workaround

Use the raw REST API directly instead of the SDK:

import requests

resp = requests.get(
    f"{base_url}/api/v2/envelope/item/{item_id}/download",
    headers={"Authorization": api_key},
    timeout=60,
)
pdf_bytes = resp.content  #works correctly, returns ~993KB PDF

Additional Notes

  • The correct endpoint is GET /api/v2/envelope/item/{item_id}/download
  • The item_id must be the envelopeItems[0].id from the envelope details, not the envelope ID itself
  • Passing the envelope ID (e.g. envelope_xxxxxx) instead of the item ID (e.g. envelope_item_xxxxxx) results in a 404

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions