# Sypnia Files documentation > Sypnia Files stores the files of your app: photos, documents, videos and anything your users upload. Public or private buckets, rules tied to who is signed in, uploads that survive a bad connection, images resized on the fly, and an S3-compatible API. Sypnia comes two ways, and every page says which one it is about: - **Sypnia Files engine** (open source, on any s3-compatible storage): Ingest, storage, aggregation, problem grouping, sessions, replay data and uptime checks. You read it through: The HTTP API, the MCP server, the CLI and the Console: one built-in page with the problems list and the session replay viewer. - **Sypnia Cloud** (hosted by us, paid with credits): The same engine, run by us. You read it through: The full app: replay player, performance, uptime, daily summary, search and teams. Every page is also plain Markdown: add `.md` to its address (`https://files.docs.sypnia.com/start/open-source-and-cloud.md`). All pages in one file: https://files.docs.sypnia.com/llms-full.txt ## Start here What Sypnia Files is, how it works, what is open source and what is Sypnia Cloud, the quickstarts, and how Sypnia uses it. - [Start here: overview](https://files.docs.sypnia.com/start.md): Section index for Sypnia Files: object storage on S3-compatible backends with buckets (public/private), access rules as Postgres row-level security using the same JWT as Sypnia Data (or any issuer), signed URLs, resumable uploads (tus, S3 multipart), image transforms and CDN, optional malware scanning, quotas, an S3-compatible API and bring-your-own bucket. Engine open source; Sypnia Cloud hosted. [Engine, Cloud] - [What Sypnia Files is](https://files.docs.sypnia.com/start/what-it-is.md): What Sypnia Files is: buckets (public/private), access rules as Postgres policies with auth.uid() (same user as Sypnia Data) or any JWT issuer, signed URLs (download and upload), resumable uploads, image transforms (resize/crop/WebP/AVIF) cached at the edge, optional malware scanning, S3-compatible API, bring-your-own S3/R2/MinIO. With Data in the same project metadata lives in the project database (policies can join tables); Run gets Files variables; Mail can attach by path. Not video streaming/transcoding, not backup, not a people file-sharing app. [Engine, Cloud] - [How it works](https://files.docs.sypnia.com/start/how-it-works.md): How Files works: upload to https://.files.sypnia.com/object// with user token (resumable for big files) → policy check on sypnia_files.objects in the project Postgres (403 if denied) → bytes to S3 or BYO bucket under project prefix, metadata row (bucket, path, size, type, owner, checksum; pending until scan if enabled) → download public via https://.files.sypnia.app CDN, private via signed URL or token (never cached for others) → image transforms by query params cached at edge. Two hosts: API on files.sypnia.com, content on files.sypnia.app (separate domain for safety). [Engine, Cloud] - [Open source and Sypnia Cloud](https://files.docs.sypnia.com/start/open-source-and-cloud.md): Files engine vs Cloud: engine on any S3-compatible storage or local folder, metadata in your Postgres 14+, any JWT issuer via JWKS, no CDN built in, transforms in engine, pluggable scanner (ClamAV image), no console; Cloud on Amazon S3 or BYO bucket, metadata in project DB, CloudFront CDN with edge transforms, GuardDuty Malware Protection per bucket, console with file browser and policy editor, credits. Same API/SDK/CLI/MCP; moving = copy objects + dump sypnia_files schema. [Engine, Cloud] - [Quickstart: Sypnia Cloud](https://files.docs.sypnia.com/start/quickstart-cloud.md): Files Cloud quickstart: npx @sypnia/files login; buckets create avatars --public --max-size 5MB --types …; SQL policy on sypnia_files.objects for insert to authenticated with check bucket_id and foldername()[1] = auth.uid(); upload with createFiles(…/client) session from @sypnia/data; url() with width/height/resize/format → .files.sypnia.app WebP. [Cloud] - [Quickstart: self-host](https://files.docs.sypnia.com/start/quickstart-self-host.md): Files self-host quickstart: clone sypnia-files, cp .env.example .env (SYPNIA_FILES_JWKS_URL), docker compose up (engine on :7500, MinIO storage, Postgres metadata, schema installed on start, secret key printed); npx @sypnia/files use http://localhost:7500 --key; buckets create; cp ./file files://bucket/path. [Engine] - [How Sypnia uses it](https://files.docs.sypnia.com/start/how-sypnia-uses-it.md): Dogfooding: Telemetry (the pilot, built on Sypnia end to end) points its engine's object storage (storage.endpoint, SYPNIA_STORAGE_ENDPOINT) at Files' S3-compatible API with one S3 key scoped to its private bucket telemetry-events (raw event segments, replay chunks, page snapshots, source maps; keys under each customer project's id; source maps never public). The Telemetry engine deletes expired data itself per plan. Public images of telemetry.sypnia.com and the docs come from a public bucket through Files' CDN. Files calls are spans in Telemetry's own traces. Rest of the suite: App keeps chat attachments in the private bucket app-uploads; Mail keeps inbound attachments and mailbox blobs it is told to keep; Design keeps renders and exports; Learn keeps course videos; Skills packages; sypnia.com and the product sites serve images and downloads. Self-hosted Telemetry engines can use a self-hosted Files engine the same way. [Engine, Cloud] ## Buckets and files Buckets, paths, public and private files, metadata and quotas. - [Buckets and files: overview](https://files.docs.sypnia.com/buckets.md): Buckets, paths, public and private files, metadata and quotas. [Engine, Cloud] - [Buckets and paths](https://files.docs.sypnia.com/buckets/buckets-and-paths.md): Files buckets and paths: bucket holds files identified by bucket + path (slashes look like folders; no folder objects); public bucket (download by anyone via CDN) vs private (default; download only by policy via token or signed URL; never shared in cache); uploads/replace/delete always by policy; names 3–63 lowercase/digits/dashes; paths ≤1,024 bytes UTF-8, no .., leading /, control chars; SDK list/move/copy/remove through policies. [Engine, Cloud] - [Metadata and quotas](https://files.docs.sypnia.com/buckets/metadata-and-quotas.md): Files metadata: row per file in sypnia_files.objects (id, bucket_id, name, owner from token, size, content_type, checksum SHA-256, scan_status, metadata JSON, case, timestamps, last_accessed_at), queryable/joinable/policy-able; upload with metadata option. Per-bucket limits: maxFileSize (413), allowedTypes (sniffed from bytes), scan on/off, cacheControl. Cloud project quotas: storage and monthly transfer; over storage → uploads refused insufficient_storage, downloads keep working. [Engine, Cloud] - [Use cases and traces](https://files.docs.sypnia.com/buckets/use-cases.md): Case attribution in Files: SDK option case or header Sypnia-Case on uploads, replacements, deletes and signed URLs; recorded in sypnia_files.objects.case (the case that last wrote the file) and in the audit log; inside a request traced by @sypnia/telemetry the SDK reads the active case and sends traceparent, so case can be omitted. A case file declares the buckets it uses: files: { reads: [menu], writes: [receipts] }; the Cases check reports a case that writes a bucket it does not list, or lists one it never uses. The case is a label, not a permission: policies decide access. Spans: files.upload , files.download , files.sign , files.delete , files.transform with sypnia.case, size, content type, never the file or its path's query. Cases shows each case's buckets and file counts. [Engine, Cloud] ## Access rules Who can read and write which file: policies with the same sign-in as Sypnia Data, signed URLs and keys. - [Access rules: overview](https://files.docs.sypnia.com/access.md): Who can read and write which file: policies with the same sign-in as Sypnia Data, signed URLs and keys. [Engine, Cloud] - [Policies](https://files.docs.sypnia.com/access/policies.md): Files policies: Postgres RLS on sypnia_files.objects; select (download, list), insert (upload), update (+insert new path) for upsert/move/metadata, delete; default deny. Examples: public read for a bucket, own folder via sypnia_files.foldername(name)[1] = auth.uid()::text, join with public.orders via metadata orderId. Helpers foldername, filename, extension; auth.uid/role/jwt from Sypnia Data or engine with other issuer (JWKS). Cloud console policy templates and SQL preview with lint. [Engine, Cloud] - [Signed URLs and keys](https://files.docs.sypnia.com/access/signed-urls-and-keys.md): Files signed URLs and keys: signedUrl(path, {expiresIn 1 s–7 days default 1 h, download name}) checked against select policies, transform options can be signed; signedUploadUrl(path, {expiresIn}) for one path, once, without session; keys: publishable (policies apply), secret (bypasses policies, servers only, refused from browsers with Origin), S3 access keys scoped to buckets/actions; in Cloud publishable/secret keys shared with Data per project. [Engine, Cloud] ## Uploads Direct uploads, resumable uploads for big files and bad connections, and signed upload URLs. - [Uploads: overview](https://files.docs.sypnia.com/uploads.md): Direct uploads, resumable uploads for big files and bad connections, and signed upload URLs. [Engine, Cloud] - [Direct uploads](https://files.docs.sypnia.com/uploads/direct-uploads.md): Files direct uploads: upload(path, file, {contentType sniffed, upsert (needs update policy), cacheControl, metadata}) → POST /object/{bucket}/{path}; response id, size, checksum, scan_status; checks in order: auth + bucket, path format, maxFileSize and direct-upload limit (413 → resumable), type sniffing vs allowedTypes, insert/update policy, storage quota; row written only after bytes stored. [Engine, Cloud] - [Resumable uploads](https://files.docs.sypnia.com/uploads/resumable-uploads.md): Files resumable uploads: uploadResumable(path, file, {chunkSize, onProgress}) resumes after drops; protocols tus 1.0 at POST /upload/resumable (Uppy, tus-js-client, TUSKit) and S3 multipart via S3 API; resumable for 24 h; file and metadata row appear only on completion, policies checked at start and end; max file per plan up to 50 GB; parts 5–100 MB except last. [Engine, Cloud] ## Images and the CDN Resizing, cropping and converting images in the URL, caching, and serving through the CDN. - [Images and the CDN: overview](https://files.docs.sypnia.com/images.md): Resizing, cropping and converting images in the URL, caching, and serving through the CDN. [Engine, Cloud] - [Image transforms](https://files.docs.sypnia.com/images/transforms.md): Files image transforms via URL query on .files.sypnia.app: width/height 1–2,500 px, resize cover|contain|fill (cover), gravity center|north|south|east|west|face, format origin|webp|avif|jpeg|png|auto (auto from Accept), quality 20–100 (80), blur 0–100; SDK bucket.url(); private via signed URL with options signed; originals JPEG/PNG/WebP/AVIF/GIF/HEIC/TIFF ≤25 MB and 50 MP; EXIF/GPS stripped; each distinct transform made once and cached, metered per month. [Engine, Cloud] - [CDN and caching](https://files.docs.sypnia.com/images/cdn-and-caching.md): Files caching: own address via Sypnia Domains (connect cdn. files:, public files, transforms and signed URLs; API stays on its host; use a files-only subdomain); public files at edge shared (bucket cacheControl, default 1 h); public transforms 30 days keyed by options; private via signed URL cached per URL until expiry; private via token not cached; upsert invalidates cached copies and transforms; versioned paths recommended; Range requests for video seeking; ETag/If-None-Match. [Engine, Cloud] ## S3 API and your own storage The S3-compatible API, and bringing your own S3, R2 or MinIO bucket. - [S3 API and your own storage: overview](https://files.docs.sypnia.com/s3.md): The S3-compatible API, and bringing your own S3, R2 or MinIO bucket. [Engine, Cloud] - [The S3-compatible API](https://files.docs.sypnia.com/s3/s3-api.md): Files S3-compatible API at https://.files.sypnia.com/s3 (path-style SigV4); S3 access keys via files s3-keys create --buckets --actions (shown once), bypass row policies but scoped to buckets/actions, audited, servers only; operations Get/Head/Put/Copy/Delete/DeleteObjects/ListObjectsV2/ListBuckets + multipart; writes get metadata rows and scanning. [Engine, Cloud] - [Bring your own bucket](https://files.docs.sypnia.com/s3/bring-your-own-bucket.md): Files bring-your-own bucket: objects in your bucket, metadata/policies/scanning/transforms by Files; AWS S3 via IAM role trusting Sypnia with external id (no long-lived keys); R2/MinIO/B2/Wasabi/any S3-compatible via access key stored encrypted with project key; files buckets create --storage s3://… --role arn; writes only under chosen prefix; external objects visible only after files buckets import. [Engine, Cloud] ## SDK, CLI and MCP The @sypnia/files package, the files command and the MCP tools for agents. - [SDK, CLI and MCP: overview](https://files.docs.sypnia.com/tools.md): The @sypnia/files package, the files command and the MCP tools for agents. [Engine, Cloud] - [The @sypnia/files package](https://files.docs.sypnia.com/tools/sdk.md): @sypnia/files subpaths: /client (uploads direct+resumable, downloads, URLs, signed URLs with user session), /server (secret key, bucket management, policies, imports, S3 keys), /react (useUpload, FileDrop with progress/resume), CLI npx @sypnia/files; createFiles(url, {session}) where session = @sypnia/data client, getAccessToken() object or token function; ESM + types; Node 20+, browsers, Bun, Deno, React Native. [Engine, Cloud] - [The CLI](https://files.docs.sypnia.com/tools/cli.md): Files CLI: login/logout/whoami/use; buckets create|ls|update|rm|import; ls files://bucket/prefix; cp (both ways, -r, resumable); mv, rm; sign --expires; policies ls|apply; s3-keys create|ls|revoke; --json; SYPNIA_FILES_KEY or --key. [Engine, Cloud] - [MCP for agents](https://files.docs.sypnia.com/tools/mcp.md): Files MCP at https://mcp.files.sypnia.com: OAuth (PKCE, DCR) or PAT with Sypnia account, or project token for one project; tools list_buckets/get_bucket, list_files/get_file, read_file, upload_file, sign_url, create_bucket/update_bucket (approval to make public), delete_files (approval), apply_policy (approval); approvals in console or files approve; audited. [Engine, Cloud] ## API reference The Files API: addresses, authentication, errors and limits. - [API reference: overview](https://files.docs.sypnia.com/api.md): Files API at https://.files.sypnia.com (content on .files.sypnia.app); auth apikey header (publishable/secret) + Bearer user JWT; error shape; codes 400 invalid_request/path/transform, 401 unauthorized/invalid_token, 403 policy_denied/secret_key_in_browser, 404 not_found/bucket_not_found, 409 already_exists, 413 too_large, 415 type_not_allowed, 423 scan_pending/infected, 507 insufficient_storage, 429 rate_limited. [Engine, Cloud] - [Endpoints](https://files.docs.sypnia.com/api/endpoints.md): Files API endpoints: buckets GET/POST/PATCH/DELETE /bucket; objects POST/GET/HEAD /object/{bucket}/{path} (x-upsert), POST /object/list/{bucket}, move/copy, DELETE /object/{bucket} {paths}, PATCH metadata; POST /upload/resumable (tus); POST /object/sign/… (signed download), POST /object/upload/sign/… (signed upload); GET /object/public/… on content host; policies endpoints (secret key); S3 keys; /s3 API. [Engine, Cloud] ## Architecture How Sypnia Files is built: its parts, where Rust runs, and how they connect. - [Architecture: overview](https://files.docs.sypnia.com/architecture.md): Files architecture: one Rust binary (axum; libvips) with auth, object API, tus server, S3 gateway, image transformer, MCP; metadata and policies in Postgres (sypnia_files), bytes in S3-compatible storage; content host behind CDN serves public files and transforms and checks signed URLs; @sypnia/files TypeScript; console private. [Engine, Cloud] - [Request paths](https://files.docs.sypnia.com/architecture/request-paths.md): 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). [Engine, Cloud] - [Data model](https://files.docs.sypnia.com/architecture/data-model.md): Files data model: sypnia_files.buckets (public, max_file_size, allowed_types, scan, cache_control, storage backend+prefix), objects (bucket_id, name, owner, size, content_type, checksum, scan_status not_scanned|pending|clean|infected, metadata, case; unique bucket+name; RLS on), uploads (resumable in progress), s3_keys (secret_hash, buckets, actions), audit; functions foldername/filename/extension; installed by sypnia-files install; storage key // so moves only update rows. [Engine, Cloud] - [Reference implementation on AWS](https://files.docs.sypnia.com/architecture/reference-implementation-aws.md): Files on AWS: CloudFront (API host .files.sypnia.com) → Lambda engine (API, tus, S3 gateway, MCP); CloudFront content host .files.sypnia.app with edge signed-URL checks and Lambda transform function; S3 objects under / with SSE-KMS per project and 7-day versioning; GuardDuty Malware Protection for S3 on scan buckets → EventBridge → scan_status; KMS per project; RDS Postgres (sypnia_files in project DB); CloudWatch. [Engine, Cloud] - [Failures and scaling](https://files.docs.sypnia.com/architecture/failures-and-scaling.md): Files failures: DB down (uploads/list/token downloads 503; public and signed URLs keep serving), storage down (503 Retry-After; cached served), partial uploads (resumable continue; abandoned expire 24 h, parts deleted), scanner down (scan buckets stay pending 423, never served unscanned, retries, notify after 1 h), transform failure (422; original available). Scaling with S3/CDN; stateless engine; streaming uploads. [Engine, Cloud] - [Codebase](https://files.docs.sypnia.com/architecture/codebase.md): Files codebase: crates core, objects, tus, s3, transform (libvips), storage (S3-compatible, local), scan (GuardDuty, ClamAV), install (schema), server (binary, Lambda, CLI, MCP); packages/files (@sypnia/files); deploy (compose, AWS template); spec; docs. [Engine, Cloud] ## Self-hosting Run the engine with Docker or on AWS against your own storage and Postgres. - [Self-hosting: overview](https://files.docs.sypnia.com/self-hosting.md): Run the engine with Docker or on AWS against your own storage and Postgres. [Engine, Cloud] - [Docker](https://files.docs.sypnia.com/self-hosting/docker.md): Files Docker: ghcr.io/sespinosav/sypnia-files (amd64/arm64, non-root) runs sypnia-files serve on :7500, install on first start; compose adds Postgres 16, MinIO, ClamAV when SYPNIA_FILES_SCAN=clamav; put a CDN/proxy in front; private until release. [Engine] - [AWS](https://files.docs.sypnia.com/self-hosting/aws.md): Files AWS template deploy/aws.yaml: Lambda engine behind CloudFront (API), second CloudFront for content with transform function, S3 SSE-KMS, KMS key, RDS or DatabaseUrl; parameters Domain, ContentDomain, CertificateArn, DatabaseUrl, JwksUrl, Scan none|guardduty; use a content domain outside the app domain for cookie safety. [Engine] - [Configuration](https://files.docs.sypnia.com/self-hosting/configuration.md): Files engine env: SYPNIA_FILES_DATABASE_URL, _STORAGE s3|local, _S3_ENDPOINT/_BUCKET/_REGION/_ACCESS_KEY_ID/_SECRET_ACCESS_KEY, _JWKS_URL/_ISSUER/_AUDIENCE, _SECRET_KEY, _SIGNING_KEY (HMAC signed URLs), _PUBLIC_URL, _MAX_DIRECT_UPLOAD (50MB), _SCAN none|clamav|guardduty. [Engine] - [Upgrades and backups](https://files.docs.sypnia.com/self-hosting/upgrades.md): Files upgrades: new image or stack update; migrations on start; refuses newer schema. Back up Postgres (sypnia_files) and storage (versioning/replication) together; sypnia-files doctor reports orphan rows and orphan files. [Engine] ## Security Policies, content isolation, malware scanning, the threat model and the checklist. - [Security: overview](https://files.docs.sypnia.com/security.md): Policies, content isolation, malware scanning, the threat model and the checklist. [Engine, Cloud] - [Threat model](https://files.docs.sypnia.com/security/threat-model.md): Files threat model: cross-user access (default deny, policies as user), active content (separate content domain files.sypnia.app, CSP sandbox, nosniff, active types as downloads), fake types (byte sniffing), malware (scan buckets, quarantine), leaked signed URL (expiry, signed options), secret key in browser (Origin refused, rotate), decompression/transform bombs (50 MP / 25 MB), storage exhaustion (per-project quotas). [Engine, Cloud] - [Malware scanning](https://files.docs.sypnia.com/security/malware-scanning.md): Files malware scanning per bucket (scan: on): pending → 423 scan_pending (SDK can wait), clean → allowed by policy, infected → 423 infected, quarantined 30 days then deleted; Cloud uses GuardDuty Malware Protection for S3; engine ClamAV or GuardDuty; file.infected webhook and console notice with uploader; detects known malware only. [Engine, Cloud] - [Checklist](https://files.docs.sypnia.com/security/checklist.md): Files checklist: minimal policies per private bucket; public upload buckets with maxFileSize, allowedTypes, scan when shared; shortest signed URL expiry; secret key only on servers, scoped S3 keys; public buckets only indexable content; self-hosted back up DB and storage together. [Engine, Cloud] ## Sypnia Cloud Projects, metering in credits, limits and plans. - [Sypnia Cloud: overview](https://files.docs.sypnia.com/cloud.md): Projects, metering in credits, limits and plans. [Engine, Cloud] - [Credits and limits](https://files.docs.sypnia.com/cloud/credits-and-limits.md): Files in Sypnia Cloud: metered items, plan amounts, overage from prepaid credits, extra capacity per item, no post-paid charges, limits published with plans. [Cloud] - [Plans](https://files.docs.sypnia.com/cloud/plans.md): Files plans: on its own, global Sypnia subscription tiers, per-item extra capacity; all prepaid; larger of product plan vs tier per item; when credits run out: notices at 80/100 %, 7 days of grace with everything working, then uploads past the plan refused; no file deleted. [Cloud] ## Reference Glossary, design decisions, the changelog and common questions. - [Reference: overview](https://files.docs.sypnia.com/reference.md): Glossary, design decisions, the changelog and common questions. [Engine, Cloud] - [Glossary](https://files.docs.sypnia.com/reference/glossary.md): Sypnia Files vocabulary: bucket, path, object, public bucket, private bucket, policy, signed URL, signed upload URL, resumable upload, transform, content host, scan status, quarantine, S3 access key, publishable key, secret key, engine. [Engine, Cloud] - [Design decisions](https://files.docs.sypnia.com/reference/decisions.md): Sypnia Files design decisions: files are served on .files.sypnia.app (sypnia.app is in the Public Suffix List), never under sypnia.com; malware scanning is off by default, with a console warning on buckets that accept public uploads; video is stored and served as files, without transcoding to adaptive streams; the largest file is 50 GB on paid plans and 50 MB on the free plan; one pair of publishable and secret keys per project for every product, with scopes per product; licenses: AGPL-3.0 engine, MIT @sypnia/files. [Engine, Cloud] - [Common questions](https://files.docs.sypnia.com/reference/faq.md): Short answers to what people ask first about Sypnia Files. [Engine, Cloud] - [Changelog](https://files.docs.sypnia.com/reference/changelog.md): What changed in Sypnia Files, newest first. [Engine, Cloud]