Authensure Python SDK
Official Python SDK for Authensure - the electronic signature and document authentication platform.
Features
- 🔐 Full API Coverage - Access all Authensure API endpoints
- 🐍 Type Hints - Complete type annotations with Pydantic models
- ⚡ Async Support - Native async/await for high-performance applications
- 🔄 Automatic Retries - Built-in exponential backoff for transient errors
- ⏱️ Rate Limit Handling - Automatic rate limit detection and backoff
- 🔗 Webhook Verification - Easy webhook signature verification
- 📁 File Uploads - Simplified document upload handling
- 🐛 Debug Mode - Detailed logging for development
Installation
pip install authensure
Quick Start
from authensure import Authensure
# Initialize with API key
client = Authensure(api_key="your_api_key_here")
# Or with access token
client = Authensure.create_with_token("your_access_token")
# Create an envelope
envelope = client.envelopes.create(
name="Contract Agreement",
message="Please sign this document",
)
# Add a recipient
client.envelopes.add_recipient(
envelope_id=envelope.id,
email="signer@example.com",
name="John Doe",
role="signer",
)
# Send for signing
client.envelopes.send(envelope.id)
Async Usage
import asyncio
from authensure import Authensure
async def main():
async with Authensure(api_key="your_api_key") as client:
# Create envelope asynchronously
envelope = await client.envelopes.create_async(
name="Contract Agreement",
)
# Add recipients in parallel
await asyncio.gather(
client.envelopes.add_recipient_async(envelope.id, "alice@example.com", "Alice"),
client.envelopes.add_recipient_async(envelope.id, "bob@example.com", "Bob"),
)
asyncio.run(main())
Authentication
Using API Key
client = Authensure(api_key="your_api_key")
Using Email/Password Login
client = Authensure(access_token="temporary")
response = client.auth.login("user@example.com", "password")
# Token is automatically set for subsequent requests
Configuration Options
client = Authensure(
api_key="your_api_key", # API key for authentication
access_token="your_token", # JWT access token
base_url="https://api.authensure.app/api", # API base URL
timeout=30.0, # Request timeout in seconds
retry_attempts=3, # Number of retry attempts
retry_delay=1.0, # Initial retry delay in seconds
debug=False, # Enable debug logging
)
API Reference
Envelopes
# List envelopes
envelopes = client.envelopes.list(status="DRAFT")
# Get an envelope
envelope = client.envelopes.get("envelope_id")
# Create an envelope
envelope = client.envelopes.create(name="My Contract", message="Please sign")
# Add a recipient
recipient = client.envelopes.add_recipient(
envelope_id="envelope_id",
email="signer@example.com",
name="John Doe",
role="signer",
)
# Send for signing
envelope = client.envelopes.send("envelope_id")
# Void an envelope
envelope = client.envelopes.void("envelope_id", reason="Contract cancelled")
Documents
# Upload a document
with open("contract.pdf", "rb") as f:
document = client.documents.upload(
envelope_id="envelope_id",
file=f.read(),
filename="contract.pdf",
)
# Get signed document URL
result = client.documents.get_signed_url("document_id")
print(result["url"])
# Download a document
content = client.documents.download("document_id")
Templates
# List templates
templates = client.templates.list()
# Create from template
envelope = client.templates.use(
template_id="template_id",
name="New Contract",
recipients=[
{"roleId": "role_1", "email": "signer@example.com", "name": "John Doe"}
],
)
Contacts
# List contacts
contacts = client.contacts.list(search="acme", limit=20)
# Create a contact
contact = client.contacts.create(
email="contact@example.com",
name="Jane Smith",
company="Acme Inc",
)
Webhooks
# Create a webhook
webhook = client.webhooks.create(
url="https://your-app.com/webhooks/authensure",
events=["envelope.signed", "envelope.completed"],
)
# Verify webhook signature
from authensure.resources.webhooks import WebhooksResource
is_valid = WebhooksResource.verify_signature(
payload=request_body,
signature=request.headers["X-Authensure-Signature"],
secret="your_webhook_secret",
)
# Construct verified event
event = WebhooksResource.construct_event(
payload=request_body,
signature=signature,
secret="your_webhook_secret",
)
print(f"Event type: {event.event}")
print(f"Data: {event.data}")
Error Handling
from authensure import (
Authensure,
AuthensureError,
AuthenticationError,
ValidationError,
NotFoundError,
RateLimitError,
)
try:
envelope = client.envelopes.get("invalid_id")
except NotFoundError:
print("Envelope not found")
except AuthenticationError:
print("Invalid API key")
except RateLimitError as e:
print(f"Rate limited, retry after: {e.retry_after} seconds")
except ValidationError as e:
print(f"Validation errors: {e.validation_errors}")
except AuthensureError as e:
print(f"API error: {e.message} (code: {e.code})")
Development
Install development dependencies
pip install -e ".[dev]"
Run tests
pytest
Run tests with coverage
pytest --cov=src/authensure --cov-report=html
Type checking
mypy src/authensure
Linting
ruff check src/authensure
Resources
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for authensure 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| authensure-1.0.1.tar.gz | 22.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| authensure-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 51.5 kB
Release files / authensure-1.0.1.tar.gz
| Download URL | authensure-1.0.1.tar.gz |
|---|---|
| Size | 22.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d53d8a068296cd6f9b182f8a5d53884a20015d871d7604dcfc6c6762ee609d6
|
|
BLAKE2b-256 checksum How to use checksums |
267322cd51fca422a86a9e45f37cc363d84722f24b0639e66167a85b15593546
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / authensure-1.0.1-py3-none-any.whl
| Download URL | authensure-1.0.1-py3-none-any.whl |
|---|---|
| Size | 29.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e9b586ce94f8ac42daf20cee9e15f29bda3fe0684b6bca2bd1765ac4fd7143b9
|
|
BLAKE2b-256 checksum How to use checksums |
5bec9ff5bc16de24b2ca7b8985c512208c5cf9d6a0c17d9ab64749f9a8d89544
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Security for authensure 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.