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:3000in development). - Request and response bodies are JSON. Every input is validated; invalid requests return
400with{ "error": { "code", "message" } }. - Auth is the
udrive_sessioncookie from SIWS login. Endpoints marked Auth required return401without it. - Mutating requests must be same-origin and are rate-limited per IP and per user (
429withRetry-Afterwhen exceeded). - Responses never include server-only fields (storage keys, IP hashes, raw key material).
Authentication
/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.
/api/auth/verifyVerifies the signed message, consumes the nonce, and sets the session cookie. Body:
| Field | Type | Notes |
|---|---|---|
pubkey | string | base58, 32-byte ed25519 |
signature | string | base58, 64 bytes |
nonce | string | from /api/auth/nonce |
issuedAt | string | ISO-8601 |
/api/auth/meReturns the current AccountDTO, or null when signed out.
/api/auth/logoutClears the session cookie.
Upload
/api/upload/presignValidates the file, creates a pending record, and returns a presigned PUT. Body:
| Field | Type | Notes |
|---|---|---|
name | string | 1–255 chars, sanitized server-side |
size | number | bytes; ≤ 100 MB anon, ≤ 2 GB user |
contentType | string | valid MIME type |
visibility | enum | public · unlisted · private |
encryption | enum | none · server · e2e (optional) |
allowTraining | boolean | optional marketplace opt-in |
trainingPrice | number | optional |
expiresAt | string? | ISO-8601 or null |
Returns { fileId, key, uploadUrl, headers }.
/api/upload/completeConfirms the object exists, verifies a provenance signature if present, and activates the file. Body:
| Field | Type | Notes |
|---|---|---|
fileId | uuid | from presign |
sha256 | string? | hex digest, recommended |
signed | boolean? | requires signer + signature |
signerPubkey | string? | base58 |
signature | string? | base58 |
signedStatement | string? | the signed provenance text |
e2eMeta | object? | opaque client encryption metadata |
Returns { shortId, shareUrl }.
Files
/api/filesAuth requiredLists the caller's files. Query params: q, visibility, status, sort (createdAt · name · size · downloadCount), order, limit (1–100), and cursor.
/api/files/:idAuth requiredReturns a single owned file as a FileDTO.
/api/files/:idAuth requiredUpdates mutable fields: name, visibility, allowTraining, trainingPrice, expiresAt.
/api/files/:idAuth requiredSoft-deletes the record and removes the object from R2.
/api/files/:id/shareAuth requiredMints a scoped share link. Optional password, expiresAt, maxDownloads. Returns a ShareLinkDTO.
/api/files/:id/share/:tokenAuth requiredRevokes a share link.
Download & serve
/api/f/:shortId/downloadRuns 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).
/api/f/:shortId/metaReturns public-safe metadata for the file view page (name, size, type, date, provenance, visibility) — never private internals.
Provenance
/api/verify/:shortIdRe-verifies the stored signature against the file and returns a ProvenanceResult ({ signed, verified, signerPubkey, statement }). See Provenance & signing.
Earnings & marketplace
/api/earningsAuth requiredReturns an EarningsSummaryDTO (totals + history).
/api/earnings/claimAuth requiredClaims the claimable balance. Payout is stubbed: records intent and marks balances claimed without an on-chain transfer yet.
/api/marketplaceAuth requiredLists opted-in datasets and simulated training activity.
/api/marketplace/simulateAuth requiredGenerates training events and earnings for opted files (used to make the marketplace feel live in non-production environments).
Account & API keys
/api/accountAuth required/api/accountAuth requiredReads and updates profile + settings: displayName, avatarUrl, bio, and settings (defaultVisibility, dataSharing, trainingPrice).
/api/account/keysAuth required/api/account/keysAuth requiredLists keys, or creates one. The full key is returned once at creation as ApiKeyCreatedDTO — store it immediately.
/api/account/keysAuth requiredRevokes a key.
/api/accountAuth requiredDanger zone: deletes the account and its files.
Warning
prefix is retained server-side (the rest is stored as a hash) — if you lose it, revoke and mint a new one.Reporting & stats
/api/reportFiles 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.
/api/statsPublic counts for the landing metrics: total files, stored bytes, users, and downloads (StatsDTO).
