Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

sendproof-fastapi

Serves the Sendproof workbench from a FastAPI or Starlette application and runs rollback Preview and Observed Send through the application's own routing, dependencies and authorization.

pip install sendproof-fastapi sendproof-sqlalchemy
from fastapi import Depends, FastAPI
from sendproof_core import Identity
from sendproof_fastapi import AuthProvider, Sendproof, preview
from sendproof_sqlalchemy import SQLAlchemyPreview

app = FastAPI(title="Inventory")

def identity(request) -> Identity | None:        # read what your authentication already set up
    user = request.session.get("user")
    return user and Identity(user["name"], user["role"], subject=user["id"], authentication_type="session")

Sendproof(
    app,
    provider=SQLAlchemyPreview(engine, database="inventory_dev"),
    identity=identity,
    environment="Development",                       # off in any environment not listed
    auth_providers=[AuthProvider("Password", "cookie", "/auth/sign-in")],
)

@app.post("/items", status_code=201)
@preview                                             # below the route decorator
def create_item(item: ItemIn, db: Session = Depends(get_db)):
    ...

Open /sendproof/. Create the Sendproof before the application starts serving requests.

How it works

  • Opt in per operation. @preview marks a path operation function (sync or async). Only marked operations are advertised in discovery and accepted by the preview route. The function keeps its signature, so dependency injection and OpenAPI are unchanged.
  • Preview. A request to /sendproof/_preview/<path> with exactly Prefer: tx=rollback is routed with your application's router, authenticated and validated by your dependencies, and executed in-process. Nothing is proxied. The adapter buffers the response (1 MiB cap), rolls the data layer back, and only then returns HTTP 200 with the confirmed envelope. Denied, unknown, unmarked, oversized or unconfirmed requests never return an envelope. The inner status can be any application status, including 409 or a 422 validation failure.
  • Observed Send. The same URL with Prefer: trace commits normally and, for a caller with a stable Identity.subject, adds X-Sendproof-Trace. Fetch it at /sendproof/_api/traces/{id}; only the owner can, for five minutes by default (trace_ttl, 8 per owner, 32 in total).
  • Middleware order. Sendproof appends its middleware as the innermost user middleware, so your session and authentication middleware have already run when it asks for an identity.
  • Dispatch. A preview is re-dispatched in-process through the whole application, so every middleware (including path-based policies) sees the target path, with its own copy of the session and state. Just before the router, Sendproof checks again that the request still routes to the marked operation it checked first; a middleware that changed the method or path gets a 409 and nothing runs.

Options

Option Meaning
provider Data layer such as SQLAlchemyPreview. Without one nothing is advertised and previews answer 503.
identity (request) -> Identity | None, sync or async. Drives capabilities and trace ownership.
authorize (request, identity) -> bool. Optional policy for the workbench, previews and traces (401/403).
environment, environments Where the workbench is on. Defaults to $SENDPROOF_ENVIRONMENT, else Production; ("Development",).
auth_providers Sign-in integrations shown on the workbench sign-in page (cookie for a password JSON endpoint, personas, oidc...).
api_name, openapi_url, documents Display name and OpenAPI documents (default: your app title and openapi_url).
field_modules Same-origin ES modules that register custom field renderers.
include_sql_parameter_values Show SQL parameter values. Development only by default.
trace_ttl, clock Trace lifetime in seconds and an injectable monotonic clock.

Effects and logs

Record outgoing email, HTTP calls, jobs and messages with sendproof_core.record_email and friends, and skip delivery when they return True. Standard logging records are captured when their logger propagates to the root logger.

Notes

  • Mount under a prefix with Starlette Mount or root_path; discovery URLs include it.
  • The adapter does not pass /sendproof/_preview through your middleware twice; your middleware sees the preview request once, with the preview URL, before dispatch to the real route.
  • Streaming and file-path responses are buffered or rejected in a preview; websockets are not supported.
  • See the SQLAlchemy coverage notes for what a preview can and cannot roll back.

Metadata

Release files for sendproof-fastapi 0.1.0a2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sendproof-fastapi 0.1.0a2
File Size Uploaded Provenance Actions
sendproof_fastapi-0.1.0a2.tar.gz 14.5 kB With provenance Details for sendproof_fastapi-0.1.0a2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sendproof-fastapi 0.1.0a2
File Interpreter ABI Platform Actions
sendproof_fastapi-0.1.0a2-py3-none-any.whl Python 3 none any Details for sendproof_fastapi-0.1.0a2-py3-none-any.whl

Total release size: 31.8 kB

Release files / sendproof_fastapi-0.1.0a2.tar.gz

Download URL sendproof_fastapi-0.1.0a2.tar.gz
Size 14.5 kB
Tags Source
SHA-256 checksum
How to use checksums
df7fc6e1266ba9ff081279d4bece9665815e6f22ae9df8a5b095d20f2a5653cf
BLAKE2b-256 checksum
How to use checksums
f0a8719505dbb9728ce8bd1aa483c72315379ad61c805de132cc16f93ac8b14a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / sendproof_fastapi-0.1.0a2-py3-none-any.whl

Download URL sendproof_fastapi-0.1.0a2-py3-none-any.whl
Size 17.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9b8d53fdf1bb387fe37c14d6a1f33aec23543164284dfbffb770e9146097d85a
BLAKE2b-256 checksum
How to use checksums
4af578dbe7216a36be34e943f91a6ff25483ba91584535adf30632b38864e7fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Security for sendproof-fastapi 0.1.0a2

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sendproof_fastapi-0.1.0a2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page