# Request paths

> An upload, a private download and an image transform, call by call.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://files.docs.sypnia.com/architecture/request-paths/

For agents: Files request paths: upload (JWT verified with cached JWKS, transaction as authenticated with claims, insert policy check, stream to storage with SHA-256, type sniffing, size enforcement, metadata row commit, scan queued → pending); signed download (sign endpoint checks select policy as user, HMAC over bucket/path/expiry/options; edge verifies signature without DB and fetches object); transform (CDN miss → function reads original if public or signed, libvips resize, EXIF stripped, long cache).

## An upload

1. `POST /object/avatars/user-42/photo.jpg` with `apikey` and the user's JWT reaches the engine.
2. The engine verifies the JWT with the project's JWKS (cached), finds the project and its database.
3. It opens a transaction as role `authenticated` with the JWT's claims, and runs the `insert` check of your policies against the row it is about to write.
4. It streams the body to storage, computing SHA-256 and sniffing the type, and enforces the size limit while streaming.
5. It writes the metadata row and commits. If scanning is on, it queues the scan and the row stays `pending`.

## A private download with a signed URL

1. The app asks `POST /object/sign/receipts/order-1042.pdf`; the engine checks the `select` policy as the user and returns a URL with an HMAC signature over bucket, path, expiry and options.
2. The browser opens the URL on the content host; the edge verifies the signature and the expiry without calling the database, and fetches the object from storage.

## An image transform

1. `GET https://<ref>.files.sypnia.app/menu/pan.jpg?width=600&format=webp` reaches the CDN.
2. On a cache miss, the transform function reads the original (public bucket, or a valid signature), resizes it with libvips, strips EXIF and returns it with a long cache time.
3. Later requests with the same options are served from the CDN.
