01

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

POST /api/v1/files/upload-intent
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": 0
15 },
16 "transformations": {
17 "image": { "enabled": true, "visibility": "public" }
18 }
19 }'
Response
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": 900
6}

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.

PUT to presigned URL
1curl -X PUT "UPLOAD_URL_FROM_STEP_2" \
2 -H "Content-Type: CONTENT_TYPE_FROM_STEP_2" \
3 --data-binary @photo.jpg

4Confirm the Upload

POST /api/v1/files/confirm
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" }'
Response
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": 0
16 },
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.

02

Authentication

All /api/v1/* routes authenticate via Bearer token: a project's API key, or an organization key naming the project.

Authorization header
1Authorization: Bearer xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012
Formatxf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012 — 35 characters total
Created viaDashboard — the project menu at the top of the sidebar — New project. The key is shown once; copy it immediately
RotationDashboard — 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.
ErrorsMissing or invalid key returns 401 Unauthorized
03

API Reference

File EndpointsAPI Key Auth

MethodPathDescription
POST/api/v1/files/upload-intentGet presigned upload URL
POST/api/v1/files/confirmConfirm upload after S3 PUT
GET/api/v1/filesList 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/filesBulk delete by entity filters — also reversible
GET/api/v1/files/deletedThe trash: what can still be restored
POST/api/v1/files/{id}/restoreUndo a delete
POST/api/v1/files/{id}/urlGenerate fresh CDN URLs
POST/api/v1/files/upload-intent

Creates 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.

Request Body
1{
2 "filename": "photo.jpg", // Required — original filename
3 "contentType": "image/jpeg", // Required — locked in presigned URL
4 "size": 204800, // Required — locked in presigned URL
5 "visibility": "public", // Optional — default "private"
6 "ownerUserId": "user_123", // Optional — track who uploaded
7 "entity": { // Optional — attach to an entity
8 "type": "post", // Polymorphic entity type
9 "id": "post_abc123", // Polymorphic entity ID
10 "role": "gallery", // Optional — avatar, logo, gallery, document, etc.
11 "position": 0 // Optional — display order (0 = primary, default: 0)
12 },
13 "transformations": { // Optional — image variant behavior
14 "image": {
15 "enabled": true, // Enable image variant generation (default: false)
16 "visibility": "public" // "public" or "private" (default: "private")
17 }
18 }
19}
Response
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": 900
6}
POST/api/v1/files/confirm

Verifies the file exists in storage, updates status to confirmed, increments storage usage, and auto-creates a file attachment if entity was provided at upload.

Request Body
1{
2 "fileId": "abc123def456"
3}
Response
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": 0
16 },
17 "transformations": {
18 "image": { "enabled": true, "visibility": "public" }
19 }
20 }
21}
GET/api/v1/files

List 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.

Example
1# List all files — no filters needed
2curl https://www.xfiles.dev/api/v1/files \
3 -H "Authorization: Bearer xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012"
4
5# Page 2
6curl "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 product
10curl "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 owner
14curl "https://www.xfiles.dev/api/v1/files?visibility=public&ownerUserId=user_123" \
15 -H "Authorization: Bearer xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012"
Response
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": 0
17 },
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": 0
42 },
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}
GET/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.

Example
1curl https://www.xfiles.dev/api/v1/files/abc123def456 \
2 -H "Authorization: Bearer xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012"
Response
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": 0
16 },
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}
PATCH/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.

Request Body
1{
2 "visibility": "public", // Optional — original file access
3 "ownerUserId": "user_456", // Optional — reassign owner
4 "position": 2, // Optional — display order (0 = primary, max 10000)
5 "transformations": { // Optional — image variant behavior
6 "image": {
7 "enabled": true, // Toggle variant generation on/off
8 "visibility": "public" // "public" or "private" (default: "private")
9 }
10 }
11}
Response
1{
2 "file": { ... }
3}
DELETE/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.

Example
1curl -X DELETE https://www.xfiles.dev/api/v1/files/abc123def456 \
2 -H "Authorization: Bearer xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012"
Response
1{
2 "success": true,
3 "restorable": true
4}
DELETE/api/v1/files

Bulk 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.

Example
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 documents
5curl -X DELETE "https://www.xfiles.dev/api/v1/files?entityType=product&entityId=prod_456&role=gallery" \
6 -H "Authorization: Bearer xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012"
Response
1{
2 "deleted": 5,
3 "restorable": true
4}
GET/api/v1/files/deleted

The 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.

Example
1curl https://www.xfiles.dev/api/v1/files/deleted \
2 -H "Authorization: Bearer xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012"
Response
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": 30
16}
POST/api/v1/files/{id}/restore

Undo 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.

Example
1curl -X POST https://www.xfiles.dev/api/v1/files/abc123def456/restore \
2 -H "Authorization: Bearer xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012"
Response
1{
2 "file": { ... },
3 "url": "https://cdn.example.com/files/originals/public/.../contract.pdf",
4 "variants": [ ... ],
5 "privateLinks": { "paused": false }
6}
POST/api/v1/files/{id}/url

Generate 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.

Example
1curl -X POST https://www.xfiles.dev/api/v1/files/abc123def456/url \
2 -H "Authorization: Bearer xf_AbC12dEfGhIjKlMnOpQrStUvWxYz9012"
Response
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": 300
19}
20
21// SVGs and non-image files — original URL only, no variants:
22{
23 "url": "https://cdn.example.com/...?Signature=...",
24 "expiresIn": 300
25}
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}
04

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 FieldWhat It Prevents
Content-TypeMust match the contentType declared at intent — server rejects mismatches
Content-LengthMust match the size declared at intent — prevents uploading larger files
VisibilityCannot tamper with visibility flag
Project IDCannot assign file to a different project
File IDCannot reassign to a different database record
ExpiryURL 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.

05

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").

 PublicPrivate (default)
Original filePermanent CDN URL — no signing neededSigned CDN URL (5 min expiry)
Image variantsPermanent CDN URL — no signing neededSigned 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.

06

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.

Variant URL structure
1# Raster images — resized + reformatted, available at predefined widths
2https://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}/url

Supported Widths

100px300px400px600px800px1000px1200px

Supported Formats

webpjpegjpgpngavif

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.

07

Filename Rules

Filenames you provide are sanitized before being used as storage keys. The original filename is preserved in the database for display.

#Rule
1Convert to lowercase
2Remove special characters (keep alphanumeric, spaces, hyphens)
3Replace spaces with hyphens
4Collapse multiple hyphens
5Preserve the original extension
6Append a unique 6-character suffix to avoid collisions
7Truncate base name to 100 characters max

Example

Input: "Best Ever Photo (2024).JPG"

Output: "best-ever-photo-2024-a7x9k2.jpg"

08

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

09

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.

1

DELETE hides the file at once. Its URLs stop working the moment the call returns — a deleted file is never still being served.

2

GET /api/v1/files/deleted lists what can still come back, each with a restorableUntil date you can show your users.

3

POST /api/v1/files/{id}/restore puts one back. It starts serving again and reappears in listings.

4

After 30 days the stored copy expires and restore answers 410. The record is then removed by a cleanup job.

5

Variants are not restored — they regenerate on demand the first time a variant URL is requested, so there is nothing to wait for.

A trash your users can actually use
1// Show what can still be recovered
2const { 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 button
8 daysLeft: Math.ceil(
9 (new Date(f.restorableUntil) - Date.now()) / 86400000
10 ),
11}));
12
13// Put one back
14const 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 than
21 // 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.

10

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.

FilesBundles
ForOne upload at a time: an avatar, an invoice, a product photoA whole folder at once: a game's maps, an asset pack, a static site
Belongs toA record in your app, and the person who uploaded itYour release: it has a name and versions
Changing itReplace or delete the filePublish a new version; roll back by making an old one live
ImagesThumbnails at any width, made on first requestServed exactly as built
PrivateA signed URL per file, for minutesOne token opens a whole bundle, per player, for up to a day
RepeatsEach upload is storedUnchanged content is uploaded and stored once — across every public version and bundle; a private bundle keeps its own
Served fromAWS (CloudFront)Cloudflare, built for files downloaded again and again
BilledStorage and downloadsStorage (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.

1

Each version gets a manifest — every file's path, SHA-256, size and type — written once when the version is committed, and never changed.

2

A small pointer, live.json, names the live version. Making a version live, or rolling back, moves only the pointer.

3

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.

4

Protected versions can't be deleted until unprotected. Deleted versions can be made live again for 7 days; then content nothing uses is removed.

5

An interrupted upload can be run again: content that already arrived is skipped, and nothing is committed until every file is there.

Publish a folder — one command
1curl -O https://www.xfiles.dev/xfiles-sync.mjs
2
3XFILES_API_KEY=xf_… node xfiles-sync.mjs ./build/city-600 --bundle city-600 \
4 --protect --message "East district" --json
5# {"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.

Read it in your app — the manifest, then plain CDN URLs
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.json
3const 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

1

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.

2

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.

3

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.

4

Drafts for testers in a private bundle; release by publishing the same folder to the public one.

A game playing sounds from the shared library
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.

The calls, in order
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 call
3 → missing: [{ sha256, url, headers }]
4PUT {url} each missing file, with exactly those headers
5 (412 = already stored: success)
6POST /api/v1/bundles/{name}/versions/{n}/commit { message?, live?, protect? } → the version
7POST /api/v1/bundles/{name}/live { version } — make live, or roll back

Every 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.

11

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 searchesEach search, from a browser or your server; a multi-search counts each query in it.
Search$0.10/1k documents/moDocuments 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 eventsEach 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-minutesEvery minute a WebSocket stays open — at least one per connection.
Chat$0.01/1k messagesEach message sent in a conversation.
Notifications$0.10/1k notificationsEach notification, to each user — in-app and web push included, however many devices.
Multiplayer$0.10/1k player-minutesEach player's minutes in a match, counted when it ends.
Email$0.50/mailbox/moEach mailbox, charged by the day while it exists: receiving, spam filtering, mail apps and the API included. A deleted mailbox stops costing at once.
Email$0.10/GB/moThe mail your mailboxes keep, measured every hour and charged by the day.
Email$0.30/1k recipientsEach 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.

privateLinks — on list, get, url and restore
1{ "paused": false } with credit
2
3{ "paused": false, "reason": "out_of_credit", at zero: links still issued,
4 "outOfCreditSince": "2026-11-04T09:00:00.000Z", until pausesAt
5 "pausesAt": "2026-11-11T09:00:00.000Z" }
6
7{ "paused": true, "reason": "out_of_credit", after: private urls are null
8 "outOfCreditSince": "2026-11-04T09:00:00.000Z", (both dates null if the account
9 "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

StatusMeaning
400Invalid request — missing fields, disallowed content type, file too large
401Missing or invalid API key
402Out 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
403A 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
404File not found — or, with an organization key, a project that is not in the organization
500Server error — safe to retry with backoff
12

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:

An organization key, acting as one project
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.

Projects API — organization key only
1POST /api/v1/projects { name, externalId?, allowedOrigins?, limits? }
2 → 201 { project, created: true } · 200 when the externalId exists
3GET /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 after
9POST /api/v1/projects/{id}/revoke-tokens
10 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
limitsconnections (≤ 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.
allowedOriginsA list (or comma-separated string) of exact origins, as on Keys & access.
KeysProjects 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.
DeleteKeys 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.
BillingEvery 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.