Quick Start
Get files uploading in four steps. Create a project, request an upload URL, push the file directly to storage, then confirm.
1Create a Project
Sign in to the dashboard and create a new project. You'll receive an API key in the format xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012. This key is shown once — copy it immediately.
2Request an Upload URL
1curl -X POST https://www.xfiles.dev/api/v1/files/upload-intent \2 -H "Authorization: Bearer xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012" \3 -H "Content-Type: application/json" \4 -d '{5 "filename": "photo.jpg",6 "contentType": "image/jpeg",7 "size": 204800,8 "visibility": "public",9 "ownerUserId": "user_123",10 "entity": {11 "type": "post",12 "id": "post_abc123",13 "role": "gallery",14 "position": 015 },16 "transformations": {17 "image": { "enabled": true, "visibility": "public" }18 }19 }'1{2 "fileId": "abc123def456",3 "uploadUrl": "https://storage.example.com/...?X-Amz-Signature=...",4 "key": "files/originals/public/proj_id/abc123def456/photo-k9x2m7.jpg",5 "expiresIn": 9006}3Upload the File
PUT the file body to the presigned URL. The Content-Type and Content-Length must match exactly what you declared in step 2 — the server will reject mismatches with 403.
1curl -X PUT "UPLOAD_URL_FROM_STEP_2" \2 -H "Content-Type: CONTENT_TYPE_FROM_STEP_2" \3 --data-binary @photo.jpg4Confirm the Upload
1curl -X POST https://www.xfiles.dev/api/v1/files/confirm \2 -H "Authorization: Bearer xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012" \3 -H "Content-Type: application/json" \4 -d '{ "fileId": "abc123def456" }'1{2 "file": {3 "id": "abc123def456",4 "filename": "photo-k9x2m7.jpg",5 "originalFilename": "photo.jpg",6 "contentType": "image/jpeg",7 "size": 204800,8 "visibility": "public",9 "uploadStatus": "confirmed",10 "ownerUserId": "user_123",11 "entity": {12 "type": "post",13 "id": "post_abc123",14 "role": "gallery",15 "position": 016 },17 "transformations": {18 "image": { "enabled": true, "visibility": "public" }19 },20 "createdAt": "2026-03-12T10:00:00.000Z"21 }22}How it works: Files never pass through your application server. Uploads go directly to S3 via presigned URLs. Downloads are always served through CloudFront CDN — public files get permanent CDN URLs, private files get signed CDN URLs. Your server only handles the intent and confirmation steps.
Authentication
All /api/v1/* routes authenticate via Bearer token: a project's API key, or an organization key naming the project.
1Authorization: Bearer xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012| Format | xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012 — 35 characters total |
| Created via | Dashboard — the project menu at the top of the sidebar — New project. The key is shown once; copy it immediately |
| Rotation | Dashboard — Keys & access — Rotate key. The new key is shown once; the old one stops at once, or after 24 hours if you choose that for a rolling deploy. Files, bundles, links already handed out and your users' platform tokens are unaffected. |
| Errors | Missing or invalid key returns 401 Unauthorized |
API Reference
File EndpointsAPI Key Auth
| Method | Path | Description |
|---|---|---|
| POST | /api/v1/files/upload-intent | Get presigned upload URL |
| POST | /api/v1/files/confirm | Confirm upload after S3 PUT |
| GET | /api/v1/files | List files with pagination, entity attachments, and filters |
| GET | /api/v1/files/{id} | Get file details + CDN URLs |
| PATCH | /api/v1/files/{id} | Update visibility or owner |
| DELETE | /api/v1/files/{id} | Delete a file — reversible for 30 days |
| DELETE | /api/v1/files | Bulk delete by entity filters — also reversible |
| GET | /api/v1/files/deleted | The trash: what can still be restored |
| POST | /api/v1/files/{id}/restore | Undo a delete |
| POST | /api/v1/files/{id}/url | Generate fresh CDN URLs |
/api/v1/files/upload-intentCreates a pending file record and returns a presigned upload URL. The presigned URL locks Content-Type and Content-Length so the client cannot upload a different file than declared.
1{2 "filename": "photo.jpg", // Required — original filename3 "contentType": "image/jpeg", // Required — locked in presigned URL4 "size": 204800, // Required — locked in presigned URL5 "visibility": "public", // Optional — default "private"6 "ownerUserId": "user_123", // Optional — track who uploaded7 "entity": { // Optional — attach to an entity8 "type": "post", // Polymorphic entity type9 "id": "post_abc123", // Polymorphic entity ID10 "role": "gallery", // Optional — avatar, logo, gallery, document, etc.11 "position": 0 // Optional — display order (0 = primary, default: 0)12 },13 "transformations": { // Optional — image variant behavior14 "image": {15 "enabled": true, // Enable image variant generation (default: false)16 "visibility": "public" // "public" or "private" (default: "private")17 }18 }19}1{2 "fileId": "abc123def456",3 "uploadUrl": "https://storage.example.com/...?X-Amz-Signature=...",4 "key": "files/originals/public/proj_id/abc123def456/photo-k9x2m7.jpg",5 "expiresIn": 9006}/api/v1/files/confirmVerifies the file exists in storage, updates status to confirmed, increments storage usage, and auto-creates a file attachment if entity was provided at upload.
1{2 "fileId": "abc123def456"3}1{2 "file": {3 "id": "abc123def456",4 "filename": "photo-k9x2m7.jpg",5 "originalFilename": "photo.jpg",6 "contentType": "image/jpeg",7 "size": 204800,8 "visibility": "public",9 "uploadStatus": "confirmed",10 "ownerUserId": "user_123",11 "entity": {12 "type": "post",13 "id": "post_abc123",14 "role": "gallery",15 "position": 016 },17 "transformations": {18 "image": { "enabled": true, "visibility": "public" }19 }20 }21}/api/v1/filesList all confirmed files for the authenticated project. No filters required — call with just your API key to get all files. Always returns 20 files per page. Every file includes its CDN url (and variants for transform-enabled images), so you can render a whole grid from this one response — no need to call /url per file. Each file also includes its entity attachment (or null). Optional filters narrow the results. When filtering by entity, results are sorted by position ascending. (Signed URLs for private files expire in 5 min; use POST /{id}/url to refresh them.) Once an account has been out of credit for more than 7 days, private originals and private variants come back with url: null, and privateLinks says why — see Billing & Credits.
1# List all files — no filters needed2curl https://www.xfiles.dev/api/v1/files \3 -H "Authorization: Bearer xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012"4
5# Page 26curl "https://www.xfiles.dev/api/v1/files?page=2" \7 -H "Authorization: Bearer xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012"8
9# Filter by entity — e.g. all images for a product10curl "https://www.xfiles.dev/api/v1/files?entityType=product&entityId=prod_abc123&role=gallery" \11 -H "Authorization: Bearer xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012"12
13# Combine filters — public files for a specific owner14curl "https://www.xfiles.dev/api/v1/files?visibility=public&ownerUserId=user_123" \15 -H "Authorization: Bearer xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012"1{2 "files": [3 {4 "id": "abc123def456",5 "filename": "sneaker-front-k9x2m7.jpg",6 "originalFilename": "sneaker-front.jpg",7 "contentType": "image/jpeg",8 "size": 204800,9 "visibility": "public",10 "uploadStatus": "confirmed",11 "ownerUserId": "user_123",12 "entity": {13 "type": "product",14 "id": "prod_abc123",15 "role": "gallery",16 "position": 017 },18 "transformations": {19 "image": { "enabled": true, "visibility": "public" }20 },21 "url": "https://cdn.example.com/files/originals/public/proj_1/abc123def456/sneaker-front-k9x2m7.jpg",22 "variants": [23 { "width": 100, "url": "https://cdn.example.com/files/variants/public/proj_1/abc123def456/sneaker-front-k9x2m7_w100.webp" },24 { "width": 400, "url": "https://cdn.example.com/files/variants/public/proj_1/abc123def456/sneaker-front-k9x2m7_w400.webp" }25 ],26 "createdAt": "2026-03-12T10:00:00.000Z"27 },28 {29 "id": "def456ghi789",30 "filename": "contract-2024-m3x7k.pdf",31 "originalFilename": "contract-2024.pdf",32 "contentType": "application/pdf",33 "size": 4100000,34 "visibility": "private",35 "uploadStatus": "confirmed",36 "ownerUserId": null,37 "entity": {38 "type": "order",39 "id": "ord_k4m91",40 "role": "invoice",41 "position": 042 },43 "transformations": {44 "image": { "enabled": false, "visibility": "private" }45 },46 "url": "https://cdn.example.com/files/originals/private/proj_1/def456ghi789/contract-2024-m3x7k.pdf?Expires=...&Signature=...",47 "createdAt": "2026-03-12T09:30:00.000Z"48 }49 ],50 "total": 42,51 "page": 1,52 "totalPages": 3,53 "privateLinks": { "paused": false }54}/api/v1/files/{id}Returns full file details and CDN URLs. All files are served through CloudFront — public files get direct CDN URLs, private files get signed CDN URLs. Raster images with transforms enabled include resized variant URLs. Out of credit past the 7-day grace, the details still come back, with a private url (and private variants' urls) null and privateLinks saying why.
1curl https://www.xfiles.dev/api/v1/files/abc123def456 \2 -H "Authorization: Bearer xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012"1{2 "file": {3 "id": "abc123def456",4 "filename": "photo-k9x2m7.jpg",5 "originalFilename": "photo.jpg",6 "contentType": "image/jpeg",7 "size": 204800,8 "visibility": "public",9 "uploadStatus": "confirmed",10 "ownerUserId": "user_123",11 "entity": {12 "type": "post",13 "id": "post_abc123",14 "role": "gallery",15 "position": 016 },17 "transformations": {18 "image": { "enabled": true, "visibility": "public" }19 }20 },21 "url": "https://cdn.example.com/files/originals/public/.../photo-k9x2m7.jpg",22 "variants": [23 { "width": 100, "url": "https://cdn.example.com/files/variants/public/.../photo-k9x2m7_w100.webp" },24 { "width": 300, "url": "https://cdn.example.com/files/variants/public/.../photo-k9x2m7_w300.webp" },25 { "width": 400, "url": "..." },26 { "width": 600, "url": "..." },27 { "width": 800, "url": "..." },28 { "width": 1000, "url": "..." },29 { "width": 1200, "url": "..." }30 ],31 "privateLinks": { "paused": false }32}/api/v1/files/{id}Update file visibility, variant settings, owner, or display position. Changing visibility moves the S3 original between public/private paths. Changing variant visibility purges existing variants so they regenerate at the correct path.
1{2 "visibility": "public", // Optional — original file access3 "ownerUserId": "user_456", // Optional — reassign owner4 "position": 2, // Optional — display order (0 = primary, max 10000)5 "transformations": { // Optional — image variant behavior6 "image": {7 "enabled": true, // Toggle variant generation on/off8 "visibility": "public" // "public" or "private" (default: "private")9 }10 }11}1{2 "file": { ... }3}/api/v1/files/{id}Deletes a file. It stops serving immediately and disappears from every listing — but it is kept for 30 days and can be restored. Variants are removed and are NOT restored; they regenerate on demand the next time a variant URL is requested.
1curl -X DELETE https://www.xfiles.dev/api/v1/files/abc123def456 \2 -H "Authorization: Bearer xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012"1{2 "success": true,3 "restorable": true4}/api/v1/filesBulk delete all files matching entity filters. Use this when deleting a parent entity (e.g. a product) to clean up all attached files in one call. At least one filter is required. Reversible per file, exactly like deleting one — which matters most here, since a single filter can match a whole gallery.
1curl -X DELETE "https://www.xfiles.dev/api/v1/files?entityType=product&entityId=prod_456" \2 -H "Authorization: Bearer xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012"3
4# With role filter — delete only gallery images, keep documents5curl -X DELETE "https://www.xfiles.dev/api/v1/files?entityType=product&entityId=prod_456&role=gallery" \6 -H "Authorization: Bearer xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012"1{2 "deleted": 5,3 "restorable": true4}/api/v1/files/deletedThe trash — files that are deleted but can still be brought back. Paginated, 20 per page. No URLs are returned: the stored objects are gone until a file is restored, so a link would only 404. Use restorableUntil to show your users how long they have.
1curl https://www.xfiles.dev/api/v1/files/deleted \2 -H "Authorization: Bearer xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012"1{2 "files": [3 {4 "id": "abc123def456",5 "originalFilename": "contract.pdf",6 "size": 204800,7 "deletedAt": "2026-09-12T10:00:00.000Z",8 "restorableUntil": "2026-10-12T10:00:00.000Z",9 "entity": { "type": "order", "id": "ord_99", "role": "invoice" }10 }11 ],12 "total": 1,13 "page": 1,14 "totalPages": 1,15 "restoreWindowDays": 3016}/api/v1/files/{id}/restoreUndo a delete. The file starts serving again and reappears in listings. Returns 410 once the 30-day window has passed and the stored copy has expired — at that point it is genuinely gone, and the honest answer is better than a success that leaves you with a broken link. Restoring works whatever the balance; out of credit past the 7-day grace, a private file's urls come back null, as from GET.
1curl -X POST https://www.xfiles.dev/api/v1/files/abc123def456/restore \2 -H "Authorization: Bearer xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012"1{2 "file": { ... },3 "url": "https://cdn.example.com/files/originals/public/.../contract.pdf",4 "variants": [ ... ],5 "privateLinks": { "paused": false }6}/api/v1/files/{id}/urlGenerate fresh CDN URLs for a single file. The list and GET endpoints already return URLs, so you mainly need this to REFRESH a private file's signed URL after the 5-minute expiry. Public files get permanent CDN URLs; private files get signed CDN URLs (valid for 5 minutes). Images with transforms enabled include variant URLs. Every answer carries privateLinks; out of credit past the 7-day grace, a private file answers 402 instead, while a public file still gets its URL.
1curl -X POST https://www.xfiles.dev/api/v1/files/abc123def456/url \2 -H "Authorization: Bearer xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012"1// Public file with public variants — permanent CDN URLs:2{3 "url": "https://cdn.example.com/files/originals/public/.../photo.jpg",4 "variants": [5 { "width": 100, "url": "https://cdn.example.com/files/variants/public/.../photo_w100.webp" },6 { "width": 300, "url": "..." },7 ...8 ]9}10
11// Private file with private variants — signed CDN URLs (5 min expiry):12{13 "url": "https://cdn.example.com/...?Signature=...&Expires=...",14 "variants": [15 { "width": 100, "url": "https://cdn.example.com/...?Signature=...&Expires=..." },16 ...17 ],18 "expiresIn": 30019}20
21// SVGs and non-image files — original URL only, no variants:22{23 "url": "https://cdn.example.com/...?Signature=...",24 "expiresIn": 30025}26
27// Private file, out of credit past the 7-day grace — 402:28{29 "error": "Private file links are paused: this account is out of credit. Add credits at /dashboard/billing and they come back at once.",30 "privateLinks": { "paused": true, "reason": "out_of_credit", "outOfCreditSince": "...", "pausedAt": "...", "message": "..." }31}Upload Security
The presigned URL cryptographically locks the following fields. If the client sends different values, the server rejects the upload with 403 Forbidden.
| Locked Field | What It Prevents |
|---|---|
Content-Type | Must match the contentType declared at intent — server rejects mismatches |
Content-Length | Must match the size declared at intent — prevents uploading larger files |
Visibility | Cannot tamper with visibility flag |
Project ID | Cannot assign file to a different project |
File ID | Cannot reassign to a different database record |
Expiry | URL is valid for 15 minutes only |
Two-step verification: After the client uploads, the confirm endpoint verifies the file actually exists in storage before marking it as confirmed. This prevents orphaned database records from failed or abandoned uploads.
File Visibility
Independent Visibility
All files are always served through CloudFront CDN — never directly from S3. Original files and image variants have independent visibility. Public files get permanent CDN URLs. Private files get signed CDN URLs (5 min expiry). Use transformations.image.visibility to control variant access — either "public" or "private" (defaults to "private").
| Public | Private (default) | |
|---|---|---|
| Original file | Permanent CDN URL — no signing needed | Signed CDN URL (5 min expiry) |
| Image variants | Permanent CDN URL — no signing needed | Signed CDN URL (5 min expiry) |
Use Case: Photo Marketplace
Private high-res originals (paid downloads) with public preview variants (thumbnails for browsing). Set visibility: "private" and transformations.image.visibility: "public".
Changing visibility: Use PATCH /api/v1/files/{id} with visibility and/or transformations.image.visibility. Changing original visibility moves the S3 object between public/private paths. Changing variant visibility purges existing variants so they regenerate at the correct path.
Image Variants
Image variants are opt-in — set transformations.image.enabled: true at upload time or toggle it later via PATCH. When enabled, variants are generated on demand the first time they're requested, then cached by the CDN. Raster images (JPEG, PNG, GIF, WebP, AVIF and TIFF, up to 50MB) are resized and reformatted; any other file is served as the original, and asking PATCH to turn variants on for one answers 422. SVGs are vector graphics that scale infinitely — they don't get variants and are always served as the original file. When not enabled, no variant URLs are returned and no variants are generated.
1# Raster images — resized + reformatted, available at predefined widths2https://cdn.example.com/.../{baseName}_w{width}.{format}3
4# You don't need to construct these URLs — the API returns them for you.5# Use GET /api/v1/files/{id} or POST /api/v1/files/{id}/urlSupported Widths
Supported Formats
CDN-only delivery: All files — originals and variants — are always served through CloudFront CDN, never directly from S3. Public variants get permanent CDN URLs. Private variants get signed CDN URLs — use POST /api/v1/files/{id}/url to generate fresh ones.
Filename Rules
Filenames you provide are sanitized before being used as storage keys. The original filename is preserved in the database for display.
| # | Rule |
|---|---|
| 1 | Convert to lowercase |
| 2 | Remove special characters (keep alphanumeric, spaces, hyphens) |
| 3 | Replace spaces with hyphens |
| 4 | Collapse multiple hyphens |
| 5 | Preserve the original extension |
| 6 | Append a unique 6-character suffix to avoid collisions |
| 7 | Truncate base name to 100 characters max |
Example
Input: "Best Ever Photo (2024).JPG"
Output: "best-ever-photo-2024-a7x9k2.jpg"
Content Types
You must declare the content type at upload intent time. Only whitelisted MIME types are accepted. The presigned URL locks both Content-Type and Content-Length so S3 rejects mismatches. Maximum file size: 500 MB.
Images
image/jpeg
image/png
image/gif
image/webp
image/svg+xml
image/avif
image/tiff
image/bmp
image/ico
Documents
application/pdf
application/msword
application/vnd.openxmlformats-*
text/plain
text/csv
text/html
text/css
text/javascript
application/json
application/xml
Archives
application/zip
application/gzip
application/x-tar
Audio
audio/mpeg
audio/wav
audio/ogg
audio/webm
Video
video/mp4
video/webm
video/ogg
Fonts
font/woff
font/woff2
font/ttf
font/otf
Adobe
application/postscript
application/illustrator
image/vnd.adobe.photoshop
application/x-photoshop
application/x-indesign
application/vnd.adobe.indesign-idml-package
application/vnd.adobe.aftereffects.project
application/vnd.adobe.premiere
application/vnd.adobe.xd
image/x-adobe-dng
3D Models
model/gltf-binary
model/gltf+json
Trash & Restore
Deleting a file is reversible for 30 days. It stops serving immediately and vanishes from every listing, but the record survives and the stored copy is kept — so you can offer your own users a trash without building one, and without holding deleted files in your database yourself.
DELETE hides the file at once. Its URLs stop working the moment the call returns — a deleted file is never still being served.
GET /api/v1/files/deleted lists what can still come back, each with a restorableUntil date you can show your users.
POST /api/v1/files/{id}/restore puts one back. It starts serving again and reappears in listings.
After 30 days the stored copy expires and restore answers 410. The record is then removed by a cleanup job.
Variants are not restored — they regenerate on demand the first time a variant URL is requested, so there is nothing to wait for.
1// Show what can still be recovered2const { files, restoreWindowDays } = await xfiles("/api/v1/files/deleted");3
4files.map((f) => ({5 name: f.originalFilename,6 deletedAt: f.deletedAt,7 // Days left, for "expires in 12 days" next to a Restore button8 daysLeft: Math.ceil(9 (new Date(f.restorableUntil) - Date.now()) / 8640000010 ),11}));12
13// Put one back14const res = await fetch(`${BASE}/api/v1/files/${id}/restore`, {15 method: "POST",16 headers: { Authorization: `Bearer ${process.env.XFILES_API_KEY}` },17});18
19if (res.status === 410) {20 // The 30 days are up — the copy is gone. Say so rather than21 // reporting a success that leaves a broken link on the page.22}Why this matters for bulk deletes: DELETE /api/v1/files?entityType=product&entityId=prod_456 can match an entire gallery in one call. It is reversible per file for the same 30 days, which is the difference between a mistyped filter being an inconvenience and being an incident.
Bundles
A bundle is a named, versioned set of files that a build produces — a game's maps, an asset pack, a static site. You publish a whole folder at once, your players or visitors download it, and next week you publish the next version of it. XFiles stores each piece of content once by its SHA-256 and never overwrites it, so an unchanged file is never uploaded again, and every URL is fixed and cached for a year.
Files or bundles?
Files are what your users upload, one at a time, into your app. Bundles are what your build produces and everybody downloads. If it comes out of a build folder, it is a bundle.
| Files | Bundles | |
|---|---|---|
| For | One upload at a time: an avatar, an invoice, a product photo | A whole folder at once: a game's maps, an asset pack, a static site |
| Belongs to | A record in your app, and the person who uploaded it | Your release: it has a name and versions |
| Changing it | Replace or delete the file | Publish a new version; roll back by making an old one live |
| Images | Thumbnails at any width, made on first request | Served exactly as built |
| Private | A signed URL per file, for minutes | One token opens a whole bundle, per player, for up to a day |
| Repeats | Each upload is stored | Unchanged content is uploaded and stored once — across every public version and bundle; a private bundle keeps its own |
| Served from | AWS (CloudFront) | Cloudflare, built for files downloaded again and again |
| Billed | Storage and downloads | Storage (each piece once) and downloads, at the same prices |
Bundles come from their own address, not the one your files use. Always take a bundle's URLs from what xfiles gives you — the API, --json, the pointer or the manifest — and never build them yourself.
Each version gets a manifest — every file's path, SHA-256, size and type — written once when the version is committed, and never changed.
A small pointer, live.json, names the live version. Making a version live, or rolling back, moves only the pointer.
A file's URL is the manifest's contentBase plus its SHA-256. Content and manifests are cached for a year; the pointer for 30 seconds.
Protected versions can't be deleted until unprotected. Deleted versions can be made live again for 7 days; then content nothing uses is removed.
An interrupted upload can be run again: content that already arrived is skipped, and nothing is committed until every file is there.
1curl -O https://www.xfiles.dev/xfiles-sync.mjs2
3XFILES_API_KEY=xf_… node xfiles-sync.mjs ./build/city-600 --bundle city-600 \4 --protect --message "East district" --json5# {"bundle":"city-600","version":8,"manifest":"https://<cdn>/…/b/city-600/v/8.json",6# "sha256":"…","live":true,"protected":true,"files":2081,"new":312,"reused":1769, …}Safe to run on every build: a folder exactly like the live version publishes nothing, and --json answers the live version with "unchanged": true. --force publishes a new version anyway.
1// Pin a version: store the manifest URL from --json. Or read the pointer:2// https://<cdn>/files/assets/public/<project>/b/city-600/live.json3const manifest = await fetch(manifestUrl).then((r) => r.json());4
5const [sha256] = manifest.files["ground/L0/12_7.webp"];6loadTile(manifest.contentBase + sha256);Private bundles — for drafts — serve nothing without a token for that one bundle. Create one with { "visibility": "private" } (or --private). Your server asks POST /api/v1/bundles/{name}/access for a token (two hours by default) and hands the URLs on; every file URL then ends in ?{query}.
Limits: Only GET and HEAD. 1,200 requests per IP address per minute on bundles; private bundles also 300 per token and 600 per IP address. Past a limit a file answers 429 with Retry-After, CORS and {"error":"rate_limited","retryAfter":60}: wait, then carry on. A missing or forbidden file answers 403.
Billing: Storage and downloads, at the same prices as files. Content shared between versions or bundles is stored, and billed, once; every download is counted exactly, a Range request by the part sent. A file counts at its stored size even when it travels compressed, as JSON does.
Organising a studio's content
One project for all your games. Public content is stored once per project, so a sound or texture three games use is uploaded and stored once.
One bundle per game for what is built with it — levels, maps, textures. The game follows the live version, or pins one by storing a manifest URL.
One shared library bundle for what many games use — sounds, music, fonts. Which sound plays where is a setting in each game's own database, holding a path from the library, so changing it takes effect at once, with no publish.
Drafts for testers in a private bundle; release by publishing the same folder to the public one.
1// settings come from your game's database — what an admin assigns:2// { "jump": "sfx/explosion-big.ogg", "menu": "music/menu.ogg" }3const live = await fetch(SOUNDS_LIVE_URL).then((r) => r.json());4const library = await fetch(live.manifest).then((r) => r.json());5const urlOf = (path) => library.contentBase + library.files[path][0];6
7playSound(urlOf(settings.sounds.jump));A new version of the library reaches every game within 30 seconds, and making the previous version live undoes it. A setting can hold a SHA-256 instead of a path to keep that exact sound even when the library changes: names centralise, hashes pin.
Publishing from your own server
The sync script is five API calls, which a tool or a server can make directly — a sound editor adding to the library, say. Always with your API key, never from a browser.
1POST /api/v1/bundles/{name}/versions start a draft → { version }2POST /api/v1/bundles/{name}/versions/{n}/files list { path, sha256, size, contentType }, ≤1,000 a call3 → missing: [{ sha256, url, headers }]4PUT {url} each missing file, with exactly those headers5 (412 = already stored: success)6POST /api/v1/bundles/{name}/versions/{n}/commit { message?, live?, protect? } → the version7POST /api/v1/bundles/{name}/live { version } — make live, or roll backEvery request and response, each error and what to do about it, private tokens and what is kept for how long are in /llms.txt — written so you can hand it to an AI assistant and have it build the integration.
Billing & Credits
XFiles uses a prepaid credit balance. There's no subscription, no free tier, and no monthly invoice. There's no cap on how many files you keep by default — you simply pay for the GB you actually use. You top up an amount; storage, bandwidth, new image variants and the platform are debited as they accrue, and when your balance hits zero the API immediately stops accepting uploads. Private files and bundles, and search, live updates, chat, notifications and multiplayer, keep working for 7 more days — an email tells you until when — then pause too. Public files and bundles keep being served, and billed. Nothing stored is deleted, and a top-up restores everything at once. A project can also be given its own storage or file-count ceiling, which is off unless you ask for one; past it, uploads are refused with 413 rather than quietly growing the bill.
Storage
$0.05
per GB per month, debited daily
Bandwidth
$0.20
per GB transferred via CDN
Image variants
$0.50
per 1,000 new variants — each width of an image, the first time it is built
Search, live updates, chat, notifications, multiplayer and email
The platform draws on the same balance, at these rates. Each day (UTC) is billed once it is over, as one line in your Billing activity. A connection is billed by its minutes (at least one), a match by its players' minutes, a document while it is kept, a push as part of its notification, and a mailbox and its mail by the day. Receiving mail is not charged.
| Search | $0.10/1k searches | Each search, from a browser or your server; a multi-search counts each query in it. |
| Search | $0.10/1k documents/mo | Documents kept in your collections, charged by the day: a day costs the monthly rate divided by the days in that month. |
| Live updates | $1.00/1M events | Each event published on a channel — by your server, by a browser, and the ones chat and notifications publish to deliver live. |
| Live updates | $1.00/1M connection-minutes | Every minute a WebSocket stays open — at least one per connection. |
| Chat | $0.01/1k messages | Each message sent in a conversation. |
| Notifications | $0.10/1k notifications | Each notification, to each user — in-app and web push included, however many devices. |
| Multiplayer | $0.10/1k player-minutes | Each player's minutes in a match, counted when it ends. |
| $0.50/mailbox/mo | Each mailbox, charged by the day while it exists: receiving, spam filtering, mail apps and the API included. A deleted mailbox stops costing at once. | |
| $0.10/GB/mo | The mail your mailboxes keep, measured every hour and charged by the day. | |
| $0.30/1k recipients | Each recipient of each message sent, from the API or a mail app. Receiving is not charged. |
Out-of-credit behaviour
From the moment the balance is at zero or below, starting an upload (upload-intent), finishing one (confirm, complete) and publishing a new bundle version return 402 Payment Required. Clients should treat 402 as a signal to prompt the user to top up — no retry succeeds until credits are added.
Private files and private bundles get 7 more days. Until then their links are issued as usual, and every list, get, url and restore response says when they pause in privateLinks.pausesAt. After it they pause until a top-up: the read endpoints (GET /api/v1/files, GET /api/v1/files/{id}) and restore keep answering, with url: null on every private original and private variant and privateLinks saying why; POST /api/v1/files/{id}/url answers 402 for a private file; and private bundles' access answers 402. Public files and public variants keep their URLs, public bundles keep being served, and links already handed out work until they expire. Nothing stored is deleted, you can still open your own files in the dashboard, and a top-up brings every link back at once. An account that has never added credit has no grace: its private links are paused from the start.
The platform — search, live updates, chat, notifications and multiplayer — keeps working for the same 7 days. Then your key and tokens answer 402 payment_required and open connections close (4402) until a top-up, which resumes it within a minute with the same keys; an account that has never added credit is paused from the start. Your dashboard's platform pages keep working throughout, and say so.
1{ "paused": false } with credit2
3{ "paused": false, "reason": "out_of_credit", at zero: links still issued,4 "outOfCreditSince": "2026-11-04T09:00:00.000Z", until pausesAt5 "pausesAt": "2026-11-11T09:00:00.000Z" }6
7{ "paused": true, "reason": "out_of_credit", after: private urls are null8 "outOfCreditSince": "2026-11-04T09:00:00.000Z", (both dates null if the account9 "pausedAt": "2026-11-11T09:00:00.000Z", never had credit)10 "message": "Private file links are paused: this account is out of credit. …" }Top-ups and low-balance alerts
Adding credits is a one-shot Stripe Checkout in mode=payment — no card is stored, no recurring charge is created. Pick an amount on /dashboard/billing, pay, and the balance updates as soon as Stripe's webhook fires. Stripe's hosted receipt URL is preserved with the transaction for accounting.
Each account has a configurable low-balance threshold (default $5.00). The first time your balance drops at or below that line, you get one warning email. The flag clears the next time you top up, so the alert can fire again for the next cycle.
Error codes
| Status | Meaning |
|---|---|
| 400 | Invalid request — missing fields, disallowed content type, file too large |
| 401 | Missing or invalid API key |
| 402 | Out of credits — uploads and new bundle versions at once; POST /files/{id}/url for a private file, and private bundle access, after the 7-day grace. Top up at /dashboard/billing: everything resumes as soon as the balance is above zero |
| 403 | A browser origin the project does not allow — or "code": "suspended": the account is suspended, and every call with its keys is refused until that is lifted. Public files and bundles already published stay up, and the keys work again unchanged afterwards |
| 403 | "code": "project_deleted" — the project was deleted; its keys answer this until it is restored or the 30 days run out |
| 404 | File not found — or, with an organization key, a project that is not in the organization |
| 500 | Server error — safe to retry with backoff |
Organizations
Projects live in an organization. Everyone starts with a personal one; make more from the organization menu at the top of the dashboard's sidebar, say one per client or product. An organization key (Dashboard — Organization — Organization keys) works for every project in its organization, so a server running many sites keeps one secret instead of one per site, and makes their projects itself. Name the project in each call:
1Authorization: Bearer xfo_…2X-XFiles-Project: <project id>It works everywhere a project key does — files, bundles and the platform (on the WebSocket, send project in the auth frame). It is for servers only: a request carrying an Origin header is refused with 403. Without the header you get 400 project_required; a project outside the organization answers 404. Deleting the key in the dashboard stops it at once (the platform within a minute).
Projects API
With an organization key, your server manages the organization's projects — no dashboard needed when a new site signs up. Creating is idempotent on externalId (your own id for the site): sending the same one again returns the existing project with 200 instead of making a second, so a retry is always safe.
1POST /api/v1/projects { name, externalId?, allowedOrigins?, limits? }2 → 201 { project, created: true } · 200 when the externalId exists3GET /api/v1/projects ?externalId= &deleted=true &limit= &after=4 → { projects, next }5GET /api/v1/projects/{id} → { project }6PATCH /api/v1/projects/{id} { name?, allowedOrigins?, limits? } → { project }7DELETE /api/v1/projects/{id} → { deleted: true, restoreUntil }8POST /api/v1/projects/{id}/restore within 30 days → { project } · 410 after9POST /api/v1/projects/{id}/revoke-tokens10 end every user token now → { revoked: true }11GET /api/v1/projects/{id}/usage ?from=YYYY-MM-DD &to= (≤ 92 days)12 → { storage, bandwidth, platform }, by day or month| limits | connections (≤ 5,000), searchesPerSecond (≤ 200) and rooms (≤ 200) can only lower the platform's own limits for that project; storageBytes and files cap its uploads (413 past them). Send null to remove one. |
| allowedOrigins | A list (or comma-separated string) of exact origins, as on Keys & access. |
| Keys | Projects made this way have no key of their own — the organization key is theirs. Add one later from the dashboard if a site needs its own. |
| Delete | Keys and tokens stop at once (the platform within a minute) and the project answers 403 project_deleted. Files and data stay for 30 days, then go for good. A new project can't take a deleted one's externalId (409) until it is restored or gone. |
| Billing | Every project in an organization is billed to its owner's credit balance. |
Building with an AI assistant?
Point it at the complete reference, or connect the MCP server so it can read these docs and use your project.