Cella
← Back to Cella

How to use Cella from other apps

Any app can back up files to your Google Cloud Storage Archive through Cella, list what's there and fetch it back. Choose the approach that fits your app.

You're building…UseEffort
A web page that needs an upload buttonWidget2 lines of HTML
A web or Node.js app with its own interfaceJavaScript clientA few lines
Anything else: Python, PHP, Go, Swift, Kotlin, shell…REST APIPlain HTTP
Scheduled backups of a folder on a server or laptopCommand-line toolOne command

1. Get a key

  1. Sign in to Cella as admin and open Setup → API keys → Create a key for another app.
  2. Give it a name, such as "Photo app", and choose the access level:
    • Backup: upload, list and download. Most apps need this.
    • Read: list and download only.
    • Admin: everything, including deleting and changing settings. Use it only for trusted server-side tools.
  3. Choose which archive the key can use, ideally just one.
  4. Optional, through the API: send "ownFolder": true, "device": "Sarah's iPhone" with POST /api/v1/keys. The key can then only use photos/Sarah's iPhone/ and files/Sarah's iPhone/. Photo uploads are always filed under that name, and everything else returns 403.
  5. Copy the key straight away. It starts with cella_ and is shown only once.

Browser apps on another website must also have their address allowed, for example https://myapp.example.com. Either set CELLA_ALLOWED_ORIGINS=https://myapp.example.com on the server (comma-separated for several), or send POST /api/v1/setup/settings with { "allowedOrigins": ["https://myapp.example.com"] } using an admin key. Server-side programs, mobile apps and scripts don't need this.

Throughout this guide, your Cella address is https://YOUR-CELLA.

2. The widget (no coding)

Add the script and the <cella-backup> tag anywhere on your page. It shows a button, the picker, a progress bar and the results, all in your page.

<script src="https://YOUR-CELLA/embed.js"></script>

<cella-backup
  server="https://YOUR-CELLA"
  api-key="cella_xxxxxxxx_yourBackupKey"
  mode="photos"
  device="My app">
</cella-backup>

Settings

AttributeWhat it does
serverYour Cella address.
api-keyA backup key (see step 1).
bucketWhich archive to use. Optional; if you leave it out, the default archive is used.
modephotos: photos and videos, filed by the date taken and skipped if already archived.
files: any files, stored under prefix.
browse: lets people see and download what's archived.
deviceName used in the folder path, for example photos/My app/2026/11/….
prefixFolder for files mode, or the starting folder for browse mode.
labelButton text.

Show progress in your own interface

The widget sends events that your page can listen for:

const w = document.querySelector('cella-backup');

w.addEventListener('cella-progress', e => {
  // e.detail = { done, total, uploaded, skipped, failed, bytesDone, bytesTotal, current }
  myProgressBar.value = e.detail.bytesDone / e.detail.bytesTotal;
});
w.addEventListener('cella-file',     e => console.log(e.detail.file.name, e.detail.status)); // uploaded | skipped | failed
w.addEventListener('cella-complete', e => alert(`${e.detail.uploaded} backed up`));
w.addEventListener('cella-error',    e => console.error(e.detail.message));

// You can also hand it files yourself, e.g. from your own drag-and-drop area:
await w.backup(fileList);
EventWhen
cella-readyThe widget has connected and is ready.
cella-progressRepeatedly while uploading.
cella-fileEach time a file finishes, is skipped or fails.
cella-completeA backup run has finished, with totals.
cella-downloadSomeone downloaded a file (browse mode).
cella-errorSomething went wrong.

Match your app's look

cella-backup {
  --cella-accent: #3b4cca;   /* button and progress colour */
  --cella-bg: #ffffff;
  --cella-ink: #222222;
  --cella-radius: 10px;
  --cella-font: inherit;
}
cella-backup::part(button) { text-transform: uppercase; }

A complete page is in the repository at examples/widget.html.

3. The JavaScript client

Use this when your app has its own buttons and screens. It's the same upload engine the Cella app uses: resumable uploads, automatic retries, duplicate skipping and photo dates read from the photo. It works in browsers and in Node.js 18 and later.

In a web page

<script src="https://YOUR-CELLA/cella-client.js"></script>
<input type="file" id="pick" accept="image/*,video/*" multiple>
<script>
  const cella = new CellaClient({
    server: 'https://YOUR-CELLA',
    apiKey: 'cella_xxxxxxxx_yourBackupKey'
  });

  document.getElementById('pick').onchange = async e => {
    const result = await cella.backupPhotos(e.target.files, {
      device: 'My app',
      onProgress: p => console.log(Math.round(100 * p.bytesDone / p.bytesTotal) + '%')
    });
    console.log(result.uploaded, 'uploaded,', result.skipped, 'already safe,', result.failed, 'failed');
  };
</script>

In Node.js

// Copy https://YOUR-CELLA/cella-client.js into your project
const fs = require('fs');
const CellaClient = require('./cella-client.js');

const cella = new CellaClient({ server: 'https://YOUR-CELLA', apiKey: process.env.CELLA_KEY });
cella.bucket = (await cella.me()).defaultBucket;

const blob = await fs.openAsBlob('report.pdf');          // Node 20+
await cella.uploadFile(blob, { name: 'reports/2026/report.pdf' });

A complete script is in the repository at examples/node_backup.js.

What it can do

MethodWhat it does
backupPhotos(files, { device, onProgress, onFile, concurrency })Back up photos and videos: skips ones already archived and files them as photos/<device>/<YYYY>/<MM>/.
uploadFile(blob, { name, onProgress })Upload one file to any path. If the same name and size already exist, it is skipped.
listObjects({ prefix, delimiter, pageToken })List files (items) and sub-folders (prefixes).
thumbnailUrl(name), addThumbnail(file, name), CellaClient.makeThumbnail(file)Show a thumbnail (as a local URL for <img>), or make and store one in the browser. backupPhotos does this automatically.
stat(name)Size, date, type and storage class of one file.
usage({ prefix })Files, size and approximate monthly storage cost for a folder and each sub-folder (total, folders).
downloadLink(name, { inline, ttlSeconds })A temporary URL that works without the key. Use it for <a href> links and to show or share a file.
download(name)The file's bytes, as a fetch Response.
remove(name)Delete a file (admin keys only).
deletePreview({ file | prefix }), deleteFolder(prefix), deleteArchive(bucket)Preview and permanently delete a folder or whole archive (admin keys only).
transferPreview({ to, mode, file | prefix }), transfer({ to, mode, file | prefix })Copy or move (mode: 'move') to another archive, with costs first (admin keys only).
pause() / resume()Pause and resume uploads in progress.
me(), listBuckets(), status()Information about the key, the archives and the server.

If a call fails, it throws a CellaClient.CellaError with .status (the HTTP code) and .message.

4. The REST API (any language)

Every request goes to https://YOUR-CELLA/api/v1/… and sends the key in a header:

X-Cella-Key: cella_xxxxxxxx_yourKey

Requests and responses are JSON unless you are sending or receiving file bytes. The full machine-readable description is at /api/v1/openapi.json, which you can import into Postman or Insomnia or use to generate a client.

Upload a file in one request

This is the simplest way, and fine for small files on a good connection. URL-encode the file's path, including the slashes (/ becomes %2F).

curl -X PUT \
  -H "X-Cella-Key: $CELLA_KEY" \
  -H "Content-Type: application/pdf" \
  --data-binary @report.pdf \
  "https://YOUR-CELLA/api/v1/buckets/my-archive/objects/reports%2F2026%2Freport.pdf"

List, download and share

# What's in a folder?
curl -H "X-Cella-Key: $CELLA_KEY" \
  "https://YOUR-CELLA/api/v1/buckets/my-archive/objects?prefix=reports/&delimiter=/"
#  → { "items": [ { "name", "size", "contentType", "storageClass", "updated", "md5" } ],
#      "prefixes": [ "reports/2026/" ], "nextPageToken": null }

# Download
curl -H "X-Cella-Key: $CELLA_KEY" -o report.pdf \
  "https://YOUR-CELLA/api/v1/buckets/my-archive/objects/reports%2F2026%2Freport.pdf"

# A link that works for 5 minutes without a key (good for apps and browsers)
curl -X POST -H "X-Cella-Key: $CELLA_KEY" -H "Content-Type: application/json" \
  -d '{"name":"reports/2026/report.pdf","ttlSeconds":300}' \
  "https://YOUR-CELLA/api/v1/buckets/my-archive/links"
#  → { "url": "/api/v1/dl/…", "expiresInSeconds": 300 }

All endpoints

Method and pathPurposeKey needed
GET /statusVersion and whether Cella is set upnone
GET /catalogStorage classes, locations and backup plansnone
POST /estimateRough cost estimate: { gb, restoresPerYear }none
GET /ratesExchange rates per 1 USD for USD, EUR and GBP (European Central Bank daily rates). Costs from the API are in USD; multiply by a rate to convertnone
GET /meThe calling key, its access and the default archiveread
GET /bucketsArchives this key can useread
GET /buckets/{b}/objectsList: ?prefix= &delimiter=/ &pageToken= &maxResults=read
GET /buckets/{b}/objects/{name}Download. Add ?stat=1 for details only, or ?inline=1 to view in a browserread
POST /buckets/{b}/linksTemporary download URLread
GET / PUT /buckets/{b}/thumbs/{name}Get or store a file's JPEG thumbnail (kept in Standard storage, so viewing it has no retrieval fee). List with ?thumbs=1 to see which files have oneread / backup
GET /buckets/{b}/usage?prefix=Files, size and approximate monthly storage cost for a folder and each sub-folder. Worked out from file sizes only, so it costs no retrieval feesread
PUT /buckets/{b}/objects/{name}Upload in one requestbackup
POST /uploads then PUT /uploads/{id}Resumable upload, for large files and mobile (see section 5)backup
GET /buckets/{b}/download-preview?prefix=Files, size and retrieval fee for downloading a folderread
POST /buckets/{b}/zip-linksOne-use link (5 minutes) that downloads a folder as a ZIP: { "prefix": "photos/" }read
GET /buckets/{b}/search?q=&prefix=Find files by any part of their path (all words must match), up to 500read
GET /buckets/{b}/photos?prefix=&offset=&limit=Photo timeline: photos and videos, newest month first, in pagesread
POST /buckets/{b}/download-preview / zip-links with { "names": [...] }Download chosen files as one ZIPread
POST /backups/log, GET /backupsRecord a finished backup; when each phone last backed upbackup / read
POST /buckets/{b}/shares, GET /shares, DELETE /shares/{id}Family share links ({ "prefix" } or { "names" }, days 1-30)admin
GET /costs, POST /costs/alertMonthly cost across archives, history and alert leveladmin
POST /uploads/{id}/finishCheck the stored file matches (size and CRC32C checksum)backup
GET /uploads/{id}How much of an upload the server already hasbackup
POST /photos/checkWhich photos are already archivedbackup
DELETE /buckets/{b}/objects/{name}Delete a file (and its older versions)admin
GET /buckets/{b}/delete-preview, POST /buckets/{b}/delete-folder, DELETE /buckets/{b}Preview and permanently delete a file, folder or whole archive (all versions), with a confirmation valueadmin
GET /buckets/{b}/transfer-preview, POST /buckets/{b}/transferCopy or move a file, folder or whole archive to another archive (and so another plan), inside Google Cloud, with a cost previewadmin
POST /buckets, /keys, /setup/…Create archives and keys, change settingsadmin

5. Large files and mobile apps: resumable uploads

For anything bigger than a few MB, or any upload over a mobile connection, send the file in pieces. If the connection drops, you ask Cella how much it has and carry on from there.

  1. Start: POST /uploads with the file's details.
    POST /api/v1/uploads
    { "name": "videos/holiday.mp4", "size": 734003200, "contentType": "video/mp4" }
    
    → { "uploadId": "5a74e2…", "chunkSize": 8388608, "received": 0 }
    → or { "skipped": true, "object": {…} }   when the same file is already archived
    For photos, send "kind": "photo", "filename": "IMG_1234.JPG", "lastModified": <ms timestamp of when it was taken>, "device": "My app" instead of name. Cella then files it as photos/My app/2026/11/IMG_1234.JPG.
  2. Send pieces in order: PUT /uploads/{uploadId}?offset=N, with the raw bytes from N to N + chunkSize as the body (Content-Type: application/octet-stream). Every piece except the last must be exactly chunkSize bytes.
    → { "received": 8388608, "done": false }
    → … last piece …
    → { "received": 734003200, "done": true, "object": { "name": "videos/holiday.mp4", … } }
    Always use the received value from the reply as your next offset.
  3. If something fails (timeout, no signal or app restarted): call GET /uploads/{uploadId}. It returns { "received": N }, and you resume from offset=N. Save the uploadId if you want to resume after your app restarts. Upload sessions last about 6 days.
  4. Confirm (recommended): POST /uploads/{uploadId}/finish with { "crc32c": "<base64>" }, the CRC32C checksum of the whole file (the same form Google uses). Cella checks the stored file's size and checksum. A match returns { "verified": true }. A mismatch returns 422: the damaged copy has been removed where the archive allows it, so send the file again.

Faster: send straight to Google. Add "direct": true to POST /uploads. The reply then also has a directUrl, and you send the pieces there instead, with a Content-Range: bytes N-M/TOTAL header. Google replies 308 while there's more to send, and 200 at the end. The address only works for that one file. In a browser, it only accepts requests from the page that started the upload. If it fails, check GET /uploads/{uploadId}, then carry on with either route: both use the same upload. The JavaScript client does all of this for you, and falls back to sending through Cella if a network blocks Google.

Uploads are create-only: an upload never replaces a file that's already stored. If a file with the same name appears while you're uploading, the last piece is refused with 412.

If you send a piece at the wrong offset, Cella doesn't store it and replies { "resync": true, "received": N }. Just carry on from N.

6. Python example

This uses the standard library only. A complete version with retries is in the repository at examples/python_backup.py.

import json, os, urllib.request

SERVER, KEY = "https://YOUR-CELLA", os.environ["CELLA_KEY"]

def call(method, path, body=None, raw=None):
    headers = {"X-Cella-Key": KEY}
    data = json.dumps(body).encode() if body is not None else raw
    headers["Content-Type"] = "application/json" if body is not None else "application/octet-stream"
    req = urllib.request.Request(SERVER + "/api/v1" + path, data=data, method=method, headers=headers)
    with urllib.request.urlopen(req) as res:
        return json.loads(res.read() or b"null")

path = "holiday.mp4"
up = call("POST", "/uploads", {"name": "videos/" + path, "size": os.path.getsize(path)})
if not up.get("skipped"):
    offset = 0
    with open(path, "rb") as f:
        while True:
            f.seek(offset)
            r = call("PUT", f"/uploads/{up['uploadId']}?offset={offset}", raw=f.read(up["chunkSize"]))
            offset = r["received"]
            if r["done"]:
                print("stored", r["object"]["name"])
                break

7. Command-line tool

The tool is bin/cella-backup.js in the repository and needs Node.js 18 or later. It's useful for cron jobs, NAS boxes and servers.

export CELLA_SERVER=https://YOUR-CELLA CELLA_KEY=cella_...

node bin/cella-backup.js ~/Documents                          # → files/<hostname>/Documents/…
node bin/cella-backup.js --prefix files/office-pc ~/Documents
node bin/cella-backup.js --photos --device "Camera SD" /media/DCIM   # filed by date taken
node bin/cella-backup.js --dry-run ~/Documents                # list what would be sent

# Every night at 02:30 (crontab -e)
30 2 * * *  CELLA_SERVER=https://YOUR-CELLA CELLA_KEY=cella_... node /opt/cella/bin/cella-backup.js /srv/data

Files already archived with the same name and size are skipped, so repeat runs only send what's new or changed. The exit code is 0 when everything succeeds, 2 when some files failed and 1 for other errors.

8. Errors

Errors come back as { "error": "message", "status": 403 } with the matching HTTP status code.

CodeMeaningWhat to do
400Something in the request is wrongRead the message, for example a missing size or a bad name.
401No key, or the key was revokedCheck the X-Cella-Key header.
403The key isn't allowed to do this, or the file is locked by a retention policyUse a key with more access, or the right archive.
404No such file, archive or uploadCheck the name. Remember to URL-encode slashes.
409Cella isn't set up yet, or the archive name is takenFinish setup, or pick another name.
413Piece too largeSend exactly chunkSize bytes.
429, 5xx, network errorsTemporary problemWait and retry. For uploads, check GET /uploads/{id} first.

9. Security tips