Python · Integration

Add E-Signatures to FastAPI

Send documents for legally binding e-signature from your FastAPI application. One endpoint, no SDK required.

Quick start

  1. Get an API key from signb.ee (free, no credit card)
  2. Set SIGNBEE_API_KEY in your environment
  3. Add the code below to your app

FastAPI example

Python
from fastapi import FastAPI
from pydantic import BaseModel
import httpx

app = FastAPI()

class ContractRequest(BaseModel):
    content: str
    senderName: str
    senderEmail: str
    recipientName: str
    recipientEmail: str

@app.post("/send-contract")
async def send_contract(req: ContractRequest):
    async with httpx.AsyncClient() as client:
        response = await client.post(
            "https://signb.ee/api/send",
            headers={"Authorization": f"Bearer {SIGNBEE_API_KEY}"},
            json=req.dict(),
        )
    return response.json()

What happens

  1. Your app sends markdown or a PDF URL to Signbee
  2. Signbee generates a PDF (if markdown) and emails the recipient a signing link
  3. Recipient signs — both parties receive the signed PDF with SHA-256 certificate

Also works with AI agents

Install the MCP server to let Claude, Cursor, or Windsurf send documents directly:

npx -y signbee-mcp

Integration details

FastAPI is Python's modern, async-first web framework with automatic OpenAPI documentation generation. It's the ideal choice for building high-performance e-signature APIs that handle many concurrent signing requests.

Async advantage: FastAPI is built on Starlette's ASGI server, meaning every request handler is async by default. The httpx.AsyncClient used in the example makes non-blocking HTTP calls to the Signbee API, allowing your server to handle other requests while waiting for the response.

Pydantic validation: FastAPI uses Pydantic models for automatic request validation. The ContractRequest model in the example ensures all required fields are present and correctly typed before the API call is made. Invalid requests receive a detailed 422 error response automatically.

Automatic documentation: FastAPI generates interactive API documentation (Swagger UI at /docs, ReDoc at /redoc) automatically from your route definitions and Pydantic models. Your contract-sending endpoint is immediately documented and testable without writing any documentation manually.

Dependency injection: For production use, inject the httpx.AsyncClient and API key as FastAPI dependencies. This enables connection pooling (reusing HTTP connections across requests) and makes testing easier with dependency overrides.

Background tasks: FastAPI supports background tasks natively. Use BackgroundTasks to send contracts asynchronously — return an immediate response to the caller while the contract is generated and sent in the background.

FAQs

How do I add e-signatures to FastAPI?

Get an API key from signb.ee (free, no credit card), set SIGNBEE_API_KEY in your environment, and add a single POST request to your FastAPI application. The recipient receives a signing link by email, signs on any device, and both parties get a SHA-256 certified PDF.

Does Signbee work with FastAPI?

Yes. Signbee is a REST API that works with any language or framework including FastAPI. Send a POST request with your document content, sender and recipient details, and Signbee handles the entire signing ceremony. No SDK required.

Why is FastAPI good for e-signature integration?

FastAPI's async-first design handles many concurrent signing requests efficiently. Pydantic models validate requests automatically. Interactive API documentation is generated without additional code. It's the best choice for high-performance e-signature APIs in Python.

How does async help with contract signing?

The Signbee API call is I/O-bound (waiting for a network response). Async handlers let your server process other requests during this wait time. Under high concurrency, async handling dramatically improves throughput compared to synchronous frameworks.

Can FastAPI validate contract requests automatically?

Yes. Define a Pydantic model with required fields (content, senderName, senderEmail, recipientName, recipientEmail) and FastAPI validates every request automatically. Invalid requests receive a detailed 422 error with field-level error messages.

Related resources

Try Signbee — free, no credit card.