Developers

REST API reference

Every udrive HTTP endpoint: authentication, the presigned upload flow, file management, downloads, provenance verification, earnings, account & API keys, abuse reporting, and public stats.

Conventions

  • Base URL: https://udrive.one (http://localhost:3000 in development).
  • Request and response bodies are JSON. Every input is validated; invalid requests return 400 with { "error": { "code", "message" } }.
  • Auth is the udrive_session cookie from SIWS login. Endpoints marked Auth required return 401 without it.
  • Mutating requests must be same-origin and are rate-limited per IP and per user (429 with Retry-After when exceeded).
  • Responses never include server-only fields (storage keys, IP hashes, raw key material).

Authentication

GET/api/auth/nonce?pubkey=<base58>

Issues a single-use, 5-minute nonce bound to the public key and returns the canonical sign-in message to sign.

POST/api/auth/verify

Verifies the signed message, consumes the nonce, and sets the session cookie. Body:

FieldTypeNotes
pubkeystringbase58, 32-byte ed25519
signaturestringbase58, 64 bytes
noncestringfrom /api/auth/nonce
issuedAtstringISO-8601
GET/api/auth/me

Returns the current AccountDTO, or null when signed out.

POST/api/auth/logout

Clears the session cookie.


Upload

POST/api/upload/presign

Validates the file, creates a pending record, and returns a presigned PUT. Body:

FieldTypeNotes
namestring1–255 chars, sanitized server-side
sizenumberbytes; ≤ 100 MB anon, ≤ 2 GB user
contentTypestringvalid MIME type
visibilityenumpublic · unlisted · private
encryptionenumnone · server · e2e (optional)
allowTrainingbooleanoptional marketplace opt-in
trainingPricenumberoptional
expiresAtstring?ISO-8601 or null

Returns { fileId, key, uploadUrl, headers }.

POST/api/upload/complete

Confirms the object exists, verifies a provenance signature if present, and activates the file. Body:

FieldTypeNotes
fileIduuidfrom presign
sha256string?hex digest, recommended
signedboolean?requires signer + signature
signerPubkeystring?base58
signaturestring?base58
signedStatementstring?the signed provenance text
e2eMetaobject?opaque client encryption metadata

Returns { shortId, shareUrl }.


Files

GET/api/filesAuth required

Lists the caller's files. Query params: q, visibility, status, sort (createdAt · name · size · downloadCount), order, limit (1–100), and cursor.

GET/api/files/:idAuth required

Returns a single owned file as a FileDTO.

PATCH/api/files/:idAuth required

Updates mutable fields: name, visibility, allowTraining, trainingPrice, expiresAt.

DELETE/api/files/:idAuth required

Soft-deletes the record and removes the object from R2.

POST/api/files/:id/shareAuth required

Mints a scoped share link. Optional password, expiresAt, maxDownloads. Returns a ShareLinkDTO.

DELETE/api/files/:id/share/:tokenAuth required

Revokes a share link.


Download & serve

GET/api/f/:shortId/download

Runs the access check, increments the counter, logs an anonymized event, and 302-redirects to a fresh presigned attachment URL. Private files require an owner session or a valid share token (and password, if set).

GET/api/f/:shortId/meta

Returns public-safe metadata for the file view page (name, size, type, date, provenance, visibility) — never private internals.


Provenance

GET/api/verify/:shortId

Re-verifies the stored signature against the file and returns a ProvenanceResult ({ signed, verified, signerPubkey, statement }). See Provenance & signing.


Earnings & marketplace

GET/api/earningsAuth required

Returns an EarningsSummaryDTO (totals + history).

POST/api/earnings/claimAuth required

Claims the claimable balance. Payout is stubbed: records intent and marks balances claimed without an on-chain transfer yet.

GET/api/marketplaceAuth required

Lists opted-in datasets and simulated training activity.

POST/api/marketplace/simulateAuth required

Generates training events and earnings for opted files (used to make the marketplace feel live in non-production environments).


Account & API keys

GET/api/accountAuth required
PATCH/api/accountAuth required

Reads and updates profile + settings: displayName, avatarUrl, bio, and settings (defaultVisibility, dataSharing, trainingPrice).

GET/api/account/keysAuth required
POST/api/account/keysAuth required

Lists keys, or creates one. The full key is returned once at creation as ApiKeyCreatedDTO — store it immediately.

DELETE/api/account/keysAuth required

Revokes a key.

DELETE/api/accountAuth required

Danger zone: deletes the account and its files.

Warning

A created API key is shown exactly once. Only its prefix is retained server-side (the rest is stored as a hash) — if you lose it, revoke and mint a new one.

Reporting & stats

POST/api/report

Files an abuse report against a shortId with a reason (copyright, illegal, malware, spam, csam, other) and optional details. Heavily rate-limited; reports crossing a threshold auto-quarantine the file.

GET/api/stats

Public counts for the landing metrics: total files, stored bytes, users, and downloads (StatsDTO).