Skip to main content

Official Python SDK for Coffrify — encrypted file transfer infrastructure.

Project description

coffrify

Official Python SDK for Coffrify — encrypted file transfer infrastructure.

Install

pip install coffrify
# or with uv
uv add coffrify
# or with poetry
poetry add coffrify

Requires Python 3.9+.

Quickstart

from coffrify import Coffrify

client = Coffrify(api_key="cfy_live_...")  # or set COFFRIFY_API_KEY env var

# Create a transfer
result = client.transfers.create(
    files=[{"name": "rapport.pdf", "size": 1_240_000, "mime_type": "application/pdf"}],
    expires_in_hours=72,
    max_downloads=10,
    password="secret",
)
print(result["share_url"])

# List webhooks
webhooks = client.webhooks.list()

# Subscribe to a webhook (secret returned ONCE)
created = client.webhooks.create(
    name="Production",
    url="https://app.example.com/hooks/coffrify",
    events=["transfer.created", "transfer.downloaded"],
)
print("SAVE THIS SECRET:", created["secret"])

Webhook signature verification

from flask import Flask, request, abort
from coffrify.webhooks import verify

app = Flask(__name__)

@app.post("/hooks/coffrify")
def webhook():
    result = verify(
        raw_body=request.data.decode("utf-8"),
        signature_header=request.headers.get("X-Coffrify-Signature"),
        secret=os.environ["COFFRIFY_WEBHOOK_SECRET"],
    )
    if not result.valid:
        abort(400, result.reason)

    event = result.event
    if event["type"] == "transfer.downloaded":
        # ...
        pass
    return ("", 200)

The signature header X-Coffrify-Signature: t=<ts>,v1=<hex> is verified with constant-time comparison and a ±5 minute timestamp tolerance.

Auto-retry & Idempotency

The SDK auto-injects Idempotency-Key headers on every POST/PUT/PATCH/DELETE for safe retries. Network errors and 5xx/429 responses retry up to 3 times with exponential backoff.

Disable with Coffrify(api_key=..., max_retries=0, auto_idempotency=False).

Auth

Authentication uses Bearer tokens with your API key:

  • Live keys: cfy_<64 hex> — production data
  • Test keys: cfy_test_<64 hex> — sandbox
key = client.api_keys.create(
    name="CI deploy bot",
    scopes=["transfers:write", "webhooks:manage"],
    expires_in_days=90,
    allowed_ips=["1.2.3.4/32"],
)
print("SAVE:", key["key"])

License

MIT

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

coffrify-0.1.1.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

coffrify-0.1.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file coffrify-0.1.1.tar.gz.

File metadata

  • Download URL: coffrify-0.1.1.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for coffrify-0.1.1.tar.gz
Algorithm Hash digest
SHA256 682a0d9d7be737fc47a5f22e62b8fa0767004198e6f8cad64bab12168502b149
MD5 0cc0ee94991c9052ab8e1c3c23982fc2
BLAKE2b-256 c1cf09b9b48121ea16ae7ae7cb40676a1acf00c6c3d6da13c4de773a8224c4a3

See more details on using hashes here.

File details

Details for the file coffrify-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: coffrify-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for coffrify-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 769ea9c55f9e0b7ef661ff1db493d1118af9a58d357e6de4017b5a2f1995130e
MD5 f1817a47a6ba2daf5716a4498e4a7aba
BLAKE2b-256 d10901daa1660e73a09065b51ff2d1f61601aa4b50dd0d9f1ba053dc7bac5958

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