HTTP API
The routes under the SDKs: sign-in, the file tree, uploads, reads, versions and errors.
The tools and SDKs speak one JSON API. Use an SDK unless you are writing one: a file is stored as verified pieces with a manifest, sealed on your side when encryption is on, and the SDKs do that work.
Requests
curl https://api.phantomdisk.com/v1/account \
-H "Authorization: Bearer $PHANTOMDISK_KEY" \
-H "X-Drive: <drive id>" # leave out for the main drive
File data never passes through this API. An upload or a read asks for short-lived links and the data goes straight to and from storage.
Routes a key can use
| Route | What it does |
|---|---|
GET /v1/account | Whether the key may write, storage used and allowed, encryption state |
GET /v1/drives | The drives the key can use |
POST /v1/drives | A new drive (only a write key for every drive) |
GET /v1/changes?after=<cursor> | Changes to the tree since a cursor, in order. Start from 0 and keep the cursor it returns |
GET /v1/changes/snapshot | The whole tree in pages, when the cursor is too old |
POST /v1/changes | Up to 100 operations: createFolder, copy, rename, move, trash, restore |
POST /v1/uploads | Start an upload; then /uploads/{id}/urls for links and /uploads/{id}/complete to commit |
POST /v1/files/{versionId}/read-urls | Links to read a version’s pieces |
GET /v1/files/{nodeId}/versions | A file’s versions |
POST /v1/files/{nodeId}/versions/{versionId}/restore | Make an old version current |
GET /v1/files/{nodeId}/at?at=<ms> | The version that was current at a moment |
POST /v1/rollback/preview, /v1/rollback | Roll a folder or the drive back to a moment |
GET /v1/trash, POST /v1/trash/{id}/restore | Recently Deleted |
Safe to retry
Every operation carries an id you make (opId, a UUID). Send the same one again and it is applied once: the answer is the original change.
Errors
{ "error": { "code": "QUOTA_EXCEEDED", "message": "Not enough storage left…", "details": {} } }
| Code | Meaning |
|---|---|
401 UNAUTHORIZED | The key is unknown or was turned off |
403 KEY_READ_ONLY | A read key tried to write |
403 KEY_FORBIDDEN | A key may not use this route (a permanent delete, account settings) |
403 READ_ONLY | The plan has ended; the drive can be read, not written |
403 QUOTA_EXCEEDED | Not enough storage left |
404 NOT_FOUND | No such item, or a drive the key may not use |
409 ALREADY_EXISTS | The id is already used |
429 RATE_LIMITED | Too many requests; details.retryAfter says how many seconds to wait |