Skip to main content

DocuSign connector for aisquare.pipe

Project description

aisquare-pipe-docusign

DocuSign source and sink connectors for aisquare.pipe. Ships with the aisquare-pipe[full] extras bundle.

Install

pip install aisquare-pipe-docusign

aisquare-pipe is pulled in transitively — no separate install needed.

For development:

cd connectors/docusign
pip install -e ".[dev]"

Configuration

Two authentication flows are supported. The connector picks the right one based on which keys are present in config.

# Flow 1: JWT Grant (recommended for server-to-server / platform integrations)
config = {
    "integration_key": "YOUR_INTEGRATION_KEY",
    "user_id":         "USER_GUID_TO_IMPERSONATE",
    "private_key":     "-----BEGIN RSA PRIVATE KEY-----\n...",  # str or bytes
    "auth_server":     "account-d.docusign.com",  # "account.docusign.com" for prod
    "account_id":      "optional — auto-discovered if omitted",
}

# Flow 2: Authorization Code refresh-token (user OAuth)
config = {
    "client_id":     "INTEGRATION_KEY",
    "client_secret": "SECRET_KEY",
    "refresh_token": "REFRESH_TOKEN",
    "auth_server":   "account-d.docusign.com",
    "account_id":    "optional",
}

JWT consent: the first time JWT Grant is used for a given integration key + user, a one-time consent URL must be visited manually. See DocuSign's JWT Grant Authentication guide.

Usage

Pull signed documents (default mode)

from aisquare.pipe import PullParams
from aisquare_pipe_docusign import DocusignSource

source = DocusignSource()
params = PullParams(params={
    "status": "completed",
    "from_date": "2024-01-01",
    "limit": 50,
})

for envelope in source.pull(config, params):
    # envelope.data is PDF bytes; metadata has envelope_id, document_id, filename, status
    print(envelope.metadata["filename"], len(envelope.data), "bytes")

Pull envelope metadata instead

params = PullParams(params={
    "mode": "envelopes",
    "status": "completed",
    "from_date": "2024-01-01",
})

for envelope in source.pull(config, params):
    # envelope.data is a dict of envelope fields (status, subject, recipients, ...)
    print(envelope.metadata["envelope_id"], envelope.data["status"])

Send a document for signature

from aisquare.pipe import DataEnvelope
from aisquare_pipe_docusign import DocusignSink

sink = DocusignSink()
with open("contract.pdf", "rb") as f:
    pdf_bytes = f.read()

envelope = DataEnvelope(
    content_type="application/pdf",
    data=pdf_bytes,
    source_id="my-app",
    metadata={
        "filename": "contract.pdf",
        "signers": [
            {"name": "Alice Example", "email": "alice@example.com"},
            {"name": "Bob Example",   "email": "bob@example.com"},
        ],
        "subject": "Please sign this contract",
        "email_blurb": "Sign at your convenience.",
    },
)
result = sink.push(envelope, config)
print(f"Sent envelope: {result.ref}")

Pull params reference

Key Default Meaning
mode "documents" "documents" → one envelope per signed PDF; "envelopes" → one envelope per signing transaction as JSON
status (none) Filter — "completed", "sent", "delivered", ...
from_date (none) ISO date; DocuSign requires at least one of from_date/envelope_ids
to_date (none) ISO date
folder_id (none) Restrict to a folder
envelope_ids (none) List of specific envelope IDs; skips listing
include_combined False Documents mode: also fetch the combined PDF (document_id="combined")
limit (none) Cap total envelopes
account_id (auto) Override account

Push metadata reference

Key Required Meaning
filename yes Document filename shown to signers
signers yes List of {name, email, recipient_id?, routing_order?} dicts
subject no Email subject (default: "Please sign")
email_blurb no Email body

Features

  • Two auth flows — JWT Grant (server-to-server) and Authorization Code refresh-token (user OAuth)
  • Two source modes — pull signed PDFs or envelope metadata via params["mode"]
  • Status / date / folder / envelope-id filters — translated into the list_status_changes call
  • Rate-limit aware — exponential backoff on HTTP 429 / 503
  • Auto-discovery of account_id — supplied by get_user_info, overridable via config["account_id"]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aisquare_pipe_docusign-0.1.0.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aisquare_pipe_docusign-0.1.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file aisquare_pipe_docusign-0.1.0.tar.gz.

File metadata

  • Download URL: aisquare_pipe_docusign-0.1.0.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for aisquare_pipe_docusign-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f02edbc97d4ad4873e00bbb6292e835038db93fb1d492d79fd8e8265cac59650
MD5 d1d3644b7ee0e322b8e3e02a6f33cd05
BLAKE2b-256 df3cae8229c37fbb0ec4d7fc8f15c65132b4d9e71fb02e6427d38cca3f884ee2

See more details on using hashes here.

File details

Details for the file aisquare_pipe_docusign-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aisquare_pipe_docusign-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 52c554fb232cb268fec68b1d6dfe20711fb6923492436845a81eaeed589e5f09
MD5 4f4972e865ce662deda93e3a54856c87
BLAKE2b-256 599616a18aa10ee253f157ba1ddaca5076520d3808955dd722f5f7c9a7bc4bf6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page