Developer Guide · Python

How to add e-signatures
in Python

Add legally binding e-signatures to a Python app in four steps with the GetSigned REST API: get a token, create an envelope, send the signing link, and handle the completion webhook. Uses requests and Flask — no SDK required.

Get free API keys →
1

Get a bearer token

Exchange your OAuth2 client credentials for a short-lived access token using the requests library.

python
import os, requests

res = requests.post("https://api.getsigned.app/oauth/token", data={
    "grant_type":    "client_credentials",
    "client_id":     os.environ["GETSIGNED_CLIENT_ID"],
    "client_secret": os.environ["GETSIGNED_CLIENT_SECRET"],
})
token = res.json()["access_token"]
2

Create an envelope

Upload the PDF and declare signers and fields with a multipart request.

python
import json

with open("nda.pdf", "rb") as f:
    res = requests.post(
        "https://api.getsigned.app/v1/envelopes",
        headers={"Authorization": f"Bearer {token}"},
        files={"document": ("nda.pdf", f, "application/pdf")},
        data={
            "signers": json.dumps([{"name": "Jamie", "email": "jamie@client.io"}]),
            "fields":  json.dumps([{"type": "signature", "page": 1, "x": 420, "y": 580}]),
        },
    )
envelope = res.json()  # { "id": "env_...", "status": "draft" }
3

Send for signing

Sending generates a tokenized, single-use link per signer and emails it. Signers verify identity with email/SMS OTP.

python
requests.post(
    f"https://api.getsigned.app/v1/envelopes/{envelope['id']}/send",
    headers={"Authorization": f"Bearer {token}"},
)
4

Handle the completion webhook

When the last signer finishes, GetSigned seals the document and POSTs envelope.completed to your endpoint. Verify the HMAC-SHA256 signature before trusting the payload.

python
import hmac, hashlib, os
from flask import Flask, request, abort

app = Flask(__name__)
WEBHOOK_SECRET = os.environ["GETSIGNED_WEBHOOK_SECRET"]

@app.post("/webhooks/getsigned")
def getsigned_webhook():
    raw = request.get_data()  # raw bytes, before any JSON parsing
    sig = request.headers.get("X-GetSigned-Signature", "")
    expected = hmac.new(WEBHOOK_SECRET.encode(), raw, hashlib.sha256).hexdigest()
    if not hmac.compare_digest(sig, expected):  # constant-time
        abort(401)

    if request.json.get("event") == "envelope.completed":
        # GET /v1/envelopes/<id>/document -> sealed PDF, then update your DB
        pass
    return "", 200

Frequently asked questions

How do I add e-signatures in Python?

Use the GetSigned REST API with the requests library: POST your client credentials to /oauth/token for a bearer token, create an envelope by POSTing a PDF with signers and fields as a multipart request, send it to generate signing links, then handle the envelope.completed webhook (for example in Flask) to fetch the sealed PDF. No SDK is required.

Do I need a special Python SDK?

No. GetSigned is a plain REST API, so the standard requests library is enough for the full integration, and any web framework (Flask, FastAPI, Django) can receive the completion webhook.

Is there a free tier to build against?

Yes. The free Starter plan includes full REST API access, PKCS#7 sealing, OTP verification, and webhooks, with 5 envelopes per month — enough to build and test a complete Python integration.

Other stacks: Node.js guide · Language-agnostic guide

Ship signing in your Python app today

Get free API keys →