PixB.
Docs GitHub
Documentation

API

Authenticate, upload and manage your library over HTTP.

Overview

Everything lives under /api/v1 on your PUBLIC_URL.

  • Auth: Authorization: Bearer <key> or the session cookie. A bearer key always sets the scope, even when a cookie is also sent.
  • Types: IDs and file sizes are JSON strings.
  • Privacy: responses never include storage paths or saved credentials.

Errors

Errors have an HTTP status and a JSON body with a message and a stable code, for example {"message":"Unauthorized","code":"unauthorized"}. Errors about specific fields add items, keyed by field, for example {"message":"Invalid name","code":"invalidName","items":{"name":["is invalid"]}}.

Match on code, not message. Library routes (files, uploads, sharing, collections) can return a more specific code such as fileTooLarge; otherwise the code follows the status:

Status code
400 badRequest
401 unauthorized
403 forbidden
404 notFound
409 conflict
422 invalidInput
429 rateLimited
5xx requestFailed

API quick start

  1. Create a key in Settings → API keys. Give it read and write scope, and copy it: it is shown once. More on keys.
  2. Send it as Authorization: Bearer YOUR_KEY to /api/v1 on your PUBLIC_URL.

Upload a file


                  curl -H 'Authorization: Bearer YOUR_KEY' \
                    -F 'file=@notes.txt' \
                    https://files.example.com/api/v1/uploads
                

It returns HTTP 201 with {file, shareUrl, rawUrl}; uploads are private, so shareUrl is null. See File objects for the file fields.

Add -F 'share=true' to publish it at once.

Share an existing file


                  curl -X POST -H 'Authorization: Bearer YOUR_KEY' \
                    https://files.example.com/api/v1/medias/FILE_ID/share
                

It returns the same {file, shareUrl, rawUrl} with shared: true and a real shareUrl. DELETE on the same path turns sharing off and breaks the old links.

List your files


                  curl -H 'Authorization: Bearer YOUR_KEY' \
                    'https://files.example.com/api/v1/medias?page=1'
                

It returns {"files":[…],"total":1,"page":1,"hasMore":false}, up to 40 files per page. See Paginate for more than one page.

Library

Your own files: list them, read one, rename or favorite it, delete it.

List files

GET /medias read

Returns {files, total, page, hasMore}, up to 40 owner files per page. The optional query fields combine on the server.

Field Details Description
q text Case-insensitive filename search
type all, image, video, audio, document, other
order newest (default), oldest
favorite true Include only favorites
shared true Include only files with active share links
collection collection ID Owner collection ID
page 1, 2, … Positive page number, starting at 1

An unknown type or a page below 1 is not rejected: the request still succeeds with HTTP 200.

File objects

Every file is returned in the same shape (IDs and sizes are strings):


                  {
                    "id": "1",
                    "name": "notes.txt",
                    "mime": "text/plain",
                    "size": "17",
                    "createdAt": "2026-12-02T17:42:44.559Z",
                    "kind": "document",
                    "favorite": false,
                    "shared": false,
                    "collections": [],
                    "links": {
                      "original": "/raw/…", "download": "/dl/…", "thumbnail": null,
                      "poster": null, "preview": null, "share": "/s/…"
                    }
                  }
                

In upload responses links are full URLs; everywhere else, including share responses, they are paths on your server (add your address in front). Upload and share responses also return shareUrl and rawUrl as full URLs. links.share is filled in even for a private file, but it only works once sharing is enabled: use shareUrl to tell whether a file is shared.

Paginate

Keep requesting the next page while hasMore is true. A shell example with jq (to adapt):


                  page=1
                  while :; do
                    body=$(curl -s -H 'Authorization: Bearer YOUR_KEY' "https://files.example.com/api/v1/medias?page=$page")
                    echo "$body" | jq -r '.files[].name'
                    [ "$(echo "$body" | jq .hasMore)" = true ] || break
                    page=$((page + 1))
                  done
                

Read, update and delete a file

Endpoint Scope What it does
GET /medias/:id read Returns one file.
PATCH /medias/:id write Updates the file. Accepts {name?, favorite?}.
DELETE /medias/:id delete Removes the original, generated derivatives and memberships. There is no recycle bin.

Upload

POST /uploads write

Send multipart form data. Uploads are private by default. Example: see Upload a file.

Field Details Description
filerequired file The file to upload
collection string An owned collection ID
share string Send share=true to publish the upload; omit for private

Success returns HTTP 201 with {file, shareUrl, rawUrl}. shareUrl is null for a private upload, and rawUrl still needs owner authentication until sharing is enabled, so don’t treat it as a public link.

Limits

  • File type: there is no allowlist. Content validation still applies.
  • Upload size: an administrator can set a maximum in MB (0 for unlimited) under Settings → Instance → Advanced. A larger file gets HTTP 413 and {"message":"File too large","code":"fileTooLarge"}.
  • Quota: an administrator can give each user a storage quota in GB; 0 means unlimited, the default.

Resumable uploads

The web app uses resumable uploads at /files; API clients send a normal multipart upload.

Storage errors

A full disk returns HTTP 507 (storageFull) and unavailable storage returns 503 (storageUnavailable), both with {message, code}. Free space or fix the mount, then retry; see storage errors for recovery.

Sharing

Enable sharing

POST /medias/:id/share write

Enables sharing and returns {file, shareUrl, rawUrl}. Repeating it returns the existing link. The recipient page and the raw URL are separate.

Disable sharing

DELETE /medias/:id/share write

Disables sharing and gives the file a new link ID, so old links stop working; sharing again creates new links. Collection membership has no influence on public access.

Who can see what

  • Private files: asset requests by non-owners return 404. That covers metadata, originals, downloads, thumbnails, video posters and PDF previews.
  • Owners can authenticate asset reads with a session or a read-scoped key.
  • Media responses support byte ranges.
  • Previews: /preview/:uid works for PDFs only.

Collections

Group files without moving them. Deleting a collection never deletes its files.

Endpoint Scope What it does
GET /collections read Returns {collections}.
POST /collections write Creates a collection. Accepts {name}.
PATCH /collections/:id write Renames it with {name}.
DELETE /collections/:id delete Removes the collection and its memberships, preserving files.
POST /collections/:id/members write Adds files to the collection.
DELETE /collections/:id/members write Removes files from the collection.

Change members

Both member endpoints accept {ids: ["file-id", ...]}, 1 to 200 IDs.

  • Idempotent: repeating a request changes nothing more.
  • Ownership: the collection and every selected file must belong to the authenticated user.
  • All or nothing: a mixed-owner request fails without applying partial changes.

Account and instance

These need a signed-in session, not a scoped key.

  • Account: profile, sessions, passkeys, TOTP, recovery and /api_keys.
  • Administration: /instance, user administration and /settings/smtp need an administrator signed in with a session. An API key, even an administrator’s, gets 401.

Instance settings

GET /instance admin

Returns {"settings":{"publicUrl","publicUrlOverride","installationUrl","maxUploadSize"}}. publicUrl is the effective address, publicUrlOverride the explicitly saved one (empty when inherited) and installationUrl the PUBLIC_URL from .env. The override is read-only here.

PATCH /instance admin

Field Details Description
settings.publicUrl string A plain origin, or an empty string to clear the override. A path is refused with 422.
settings.maxUploadSize number Whole MB; 0 for unlimited

Which address PixB uses, in order:

  1. The stored override.
  2. The installation PUBLIC_URL.
  3. The request origin, for ordinary links only.

SMTP settings

GET /settings/smtp admin

Returns {host, port, user, from, secure, configured} and never the password.

PUT /settings/smtp admin

Field Details Description
host string
port number 587 if empty
user string
pass string Leave out to keep the saved password
from string
secure boolean

It answers {"message":"SMTP settings saved."}.

API keys

Create keys under Settings → API keys or over the API with a session. Copy the secret right away: it is shown only once.

Create a key

POST /api_keys session

Field Details Description
namerequired string Up to 20 characters
description string Up to 80 characters
expirationrequired number 0 is 1 day, 1 is 7 days, 2 is 30 days, 3 is 365 days, 4 never expires
scopesrequired string[] Any of read, write, delete

                  {"api_key":{"name":"backup","expiration":1,"scopes":["read"]}}
                

The response is HTTP 201 with {"encoded_token":"…"}.

List and revoke

Endpoint Scope What it does
GET /api_keys session Lists only keys that haven’t expired, 10 per page. Use page, and query to filter by name.
DELETE /api_keys/:id session Revokes a key.

Scopes

Scope Allows
read List and read files and collections; read originals and downloads of your own files.
write Upload, rename and favorite files, enable and disable sharing, create and rename collections, change collection members.
delete Delete files and collections.

A key without the scope an endpoint needs gets 403 with forbidden.

Setup, sign-in and health

Set up the first administrator

POST /api/v1/setup

For scripted installs. It works only while no administrator exists, and signs you in with the session cookie.

Field Details Description
admin.usernamerequired string
admin.emailrequired string
admin.passwordrequired string
admin.password_confirmationrequired string
settings.public_url string Saved as the custom address
  • Success: HTTP 201 with {token, expires_at}.
  • Already set up: HTTP 409, Setup already completed.
  • Limit: 10 attempts per 15 minutes per address.

                  curl -c cookies.txt -H 'Content-Type: application/json' \
                    -d '{"admin":{"username":"admin","email":"you@example.com","password":"YOUR_PASSWORD","password_confirmation":"YOUR_PASSWORD"}}' \
                    https://files.example.com/api/v1/setup
                

Sign in

POST /api/v1/sessions

Signs in and sets the session cookie.

Field Details Description
user.loginrequired string Username or email
user.passwordrequired string

                  curl -c cookies.txt -H 'Content-Type: application/json' \
                    -d '{"user":{"login":"admin","password":"YOUR_PASSWORD"}}' \
                    https://files.example.com/api/v1/sessions
                

Health

GET /api/health or /api/v1/health

No authentication needed. It reports whether the app can reach its database.

  • Healthy:
    
                          {"status":"ok","db":"up","latency_ms":2}
                        
  • Database down: HTTP 500
    
                          {"status":"error","db":"down"}