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.
@previewmarks a path operation function (sync orasync). 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 exactlyPrefer: tx=rollbackis 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: tracecommits normally and, for a caller with a stableIdentity.subject, addsX-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.
Sendproofappends 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
Mountorroot_path; discovery URLs include it. - The adapter does not pass
/sendproof/_previewthrough 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.0a1
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 | Actions |
|---|---|---|---|---|
| sendproof_fastapi-0.1.0a1.tar.gz | 13.3 kB | With provenance | Details for sendproof_fastapi-0.1.0a1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sendproof_fastapi-0.1.0a1-py3-none-any.whl | Python 3 | none | any | Details for sendproof_fastapi-0.1.0a1-py3-none-any.whl |
Total release size: 29.3 kB
Release files / sendproof_fastapi-0.1.0a1.tar.gz
| Download URL | sendproof_fastapi-0.1.0a1.tar.gz |
|---|---|
| Size | 13.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
de5c071af1ff2dcab18b740afed6b8a90e9013e5326efaba1633635856e22f7d
|
|
BLAKE2b-256 checksum How to use checksums |
d6160f819daa94cffa3ea0f1e3c57017edda08e72d091db8c57d0fb11240b556
|
| 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 22, 2026.
Transparency logRelease files / sendproof_fastapi-0.1.0a1-py3-none-any.whl
| Download URL | sendproof_fastapi-0.1.0a1-py3-none-any.whl |
|---|---|
| Size | 16.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c4138061d23ff26b2b3e5aff289a8ea000a4769e781f2e21b5e3ec950ad76bd8
|
|
BLAKE2b-256 checksum How to use checksums |
551a5e475b60e9af9e4e5115bcfb5320db45d63909a418901d51b349e39dff9f
|
| 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 22, 2026.
Transparency logSecurity for sendproof-fastapi 0.1.0a1
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.
Attestation for sendproof_fastapi-0.1.0a1.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 22, 2026.
Transparency logA 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.