{ "openapi": "3.1.0", "info": { "title": "agent-fs API", "version": "0.18.39", "description": "A persistent, searchable filesystem for AI agents. agent-fs is to files what agentmail is to email.", "license": { "name": "MIT", "url": "https://github.com/desplega-ai/agent-fs/blob/main/LICENSE" } }, "servers": [ { "url": "http://localhost:7433", "description": "Local development server" } ], "paths": { "/health": { "get": { "summary": "Health check", "operationId": "health", "tags": [ "System" ], "security": [], "responses": { "200": { "description": "Server is healthy", "content": { "application/json": { "schema": { "type": "object", "properties": { "ok": { "type": "boolean", "const": true }, "version": { "type": "string" }, "maxUploadBytes": { "type": "integer", "minimum": 1, "description": "Maximum raw upload size in bytes" }, "features": { "type": "array", "items": { "type": "string" }, "description": "Optional capabilities this server supports (e.g. \"share-links\"). Absent on older servers." } }, "required": [ "ok", "version", "maxUploadBytes" ] } } } } } } }, "/share/{token}": { "get": { "summary": "Public share page", "description": "Unauthenticated HTML preview of a file shared with the share-create op, with a Download button. The token is the only credential. Expired, revoked and used-up links return the same 'link expired' page (404 for an unknown token, 410 otherwise). Each successful page view counts against maxViews.", "operationId": "sharePage", "tags": [ "Share" ], "security": [], "parameters": [ { "name": "token", "in": "path", "required": true, "schema": { "type": "string", "minLength": 43, "maxLength": 43 } } ], "responses": { "200": { "description": "The share page", "content": { "text/html": { "schema": { "type": "string" } } } }, "302": { "description": "The share is a folder (kind \"site\"): redirect to /site/{token}/" }, "404": { "description": "Unknown token or file no longer available", "content": { "text/html": { "schema": { "type": "string" } } } }, "410": { "description": "Link expired, revoked or used up", "content": { "text/html": { "schema": { "type": "string" } } } }, "429": { "description": "Too many requests from this address" } } } }, "/share/{token}/raw": { "get": { "summary": "Inline bytes for a share embed", "description": "Serves (or redirects to a short-lived presigned URL for) the shared file inline. Only images, PDF, audio, video and HTML; SVG is never served inline. An HTML page is always proxied (never presigned), at most 25 MB, with `Content-Security-Policy: sandbox allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-modals; frame-ancestors 'self'`, so it runs in an opaque origin whether framed by the share page or opened on its own. Does not count as a view.", "operationId": "shareRaw", "tags": [ "Share" ], "security": [], "parameters": [ { "name": "token", "in": "path", "required": true, "schema": { "type": "string", "minLength": 43, "maxLength": 43 } } ], "responses": { "200": { "description": "File bytes" }, "302": { "description": "Redirect to a short-lived presigned URL" }, "404": { "description": "Not found or not embeddable" }, "410": { "description": "Link expired, revoked or used up" } } } }, "/share/{token}/download": { "get": { "summary": "Download a shared file", "description": "Serves (or redirects to a short-lived presigned URL for) the shared file with Content-Disposition: attachment. Does not count as a view.", "operationId": "shareDownload", "tags": [ "Share" ], "security": [], "parameters": [ { "name": "token", "in": "path", "required": true, "schema": { "type": "string", "minLength": 43, "maxLength": 43 } } ], "responses": { "200": { "description": "File bytes as an attachment" }, "302": { "description": "Redirect to a short-lived presigned URL" }, "404": { "description": "File no longer available" }, "410": { "description": "Link expired, revoked or used up" } } } }, "/site/{token}/{path}": { "get": { "summary": "File of a shared folder (site share)", "description": "Serves a file from a folder shared with the share-create op (kind \"site\"). An empty path or one ending in '/' serves that folder's index.html. A folder without index.html redirects (302) to its only .html/.htm file, or else returns an HTML listing of its HTML pages (other files and sub-folders are never listed); a folder with no HTML page is 404. A folder named without its trailing slash redirects (301) to the slash form when that serves a page. `/site/{token}` redirects to `/site/{token}/`. The token is the only credential. Every response is proxied through this server (no presigned redirects) and carries `Content-Security-Policy: sandbox allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-modals; frame-ancestors *` (an opaque origin: no cookies or storage), `Referrer-Policy: no-referrer`, `X-Content-Type-Options: nosniff`, `Cache-Control: no-store` and `Access-Control-Allow-Origin: *`. Files over 25 MB are refused. Does not count views. `/site/*` has its own per-IP rate limit (`AGENT_FS_SITE_RATE_LIMIT`, default 600/min).", "operationId": "siteFile", "tags": [ "Share" ], "security": [], "parameters": [ { "name": "token", "in": "path", "required": true, "schema": { "type": "string", "minLength": 43, "maxLength": 43 } }, { "name": "path", "in": "path", "required": true, "description": "Path inside the shared folder; may contain '/'. Empty for index.html.", "schema": { "type": "string" } } ], "responses": { "200": { "description": "File bytes, with the content type of the file name" }, "301": { "description": "Redirect to the folder form with a trailing slash" }, "400": { "description": "Path is not valid inside the folder ('.', '..', NUL, bad encoding)" }, "404": { "description": "Unknown token, not a site share, or no such file" }, "410": { "description": "Link expired or revoked" }, "413": { "description": "File is larger than 25 MB" }, "429": { "description": "Too many requests from this address" } } } }, "/auth/register": { "post": { "summary": "Register a new user", "operationId": "register", "tags": [ "Auth" ], "security": [], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "email": { "type": "string", "format": "email" } }, "required": [ "email" ] } } } }, "responses": { "200": { "description": "User registered", "content": { "application/json": { "schema": { "type": "object", "properties": { "userId": { "type": "string" }, "orgId": { "type": "string" }, "driveId": { "type": "string" }, "apiKey": { "type": "string" } }, "required": [ "userId", "orgId", "driveId", "apiKey" ] } } } }, "400": { "description": "VALIDATION_ERROR: email missing, or has no domain while AGENT_FS_REGISTER_ALLOWED_DOMAINS is set", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "403": { "description": "REGISTRATION_DOMAIN_NOT_ALLOWED: email domain is not in AGENT_FS_REGISTER_ALLOWED_DOMAINS", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/auth/me": { "get": { "summary": "Get current user info", "description": "The one /auth route an org-scoped key (minted by an org admin) may call. For such a key the answer is identity only: `userId`, `email`, `displayName` and `scopedOrgId`, without the personal `defaultOrgId`/`defaultDriveId`. Every other key gets the defaults and `scopedOrgId: null`.", "operationId": "me", "tags": [ "Auth" ], "responses": { "200": { "description": "Current user", "content": { "application/json": { "schema": { "type": "object", "properties": { "userId": { "type": "string" }, "email": { "type": "string" }, "displayName": { "type": [ "string", "null" ] }, "defaultOrgId": { "type": [ "string", "null" ], "description": "Absent for an org-scoped key" }, "defaultDriveId": { "type": [ "string", "null" ], "description": "Absent for an org-scoped key" }, "scopedOrgId": { "type": [ "string", "null" ], "description": "Org the calling key is limited to; null for an unscoped key" } }, "required": [ "userId", "email", "displayName", "scopedOrgId" ] } } } } } } }, "/auth/profile": { "get": { "summary": "Get your own profile", "operationId": "getProfile", "tags": [ "Auth" ], "responses": { "200": { "description": "Authenticated user's profile", "content": { "application/json": { "schema": { "type": "object", "required": [ "userId", "email", "displayName" ], "properties": { "userId": { "type": "string" }, "email": { "type": "string" }, "displayName": { "type": [ "string", "null" ] } } } } } }, "401": { "description": "Unauthorized" } } }, "patch": { "summary": "Update your own display name", "description": "Names are trimmed and limited to 1–100 characters. Send null to clear. No target user ID is accepted.", "operationId": "updateProfile", "tags": [ "Auth" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "displayName": { "type": "string", "minLength": 1, "maxLength": 100, "nullable": true } }, "required": [ "displayName" ], "additionalProperties": false } } } }, "responses": { "200": { "description": "Updated profile (same shape as GET /auth/profile)" }, "400": { "description": "Invalid profile fields" }, "401": { "description": "Unauthorized" } } } }, "/auth/reset-key": { "post": { "summary": "Reset your own API key", "description": "Rotates the caller's primary API key. The old key stops working immediately. Also revokes every org-scoped key of the caller (keys org admins minted); keys from POST /auth/keys keep working. Records an api_key_reset audit event.", "operationId": "resetApiKey", "tags": [ "Auth" ], "responses": { "200": { "description": "API key reset", "content": { "application/json": { "schema": { "type": "object", "properties": { "apiKey": { "type": "string" } }, "required": [ "apiKey" ] } } } }, "401": { "description": "Unauthorized", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/orgs/{orgId}": { "patch": { "summary": "Set the org's swarm URL (org admin only)", "description": "Sets or clears the agent-swarm dashboard this org trusts for sign-in. The live UI shows a key-less visitor of an org deep link a \"Continue with \" action that opens /fs/continue. The value must be an absolute http or https URL without credentials, query or fragment; a trailing slash is dropped. Sending the stored value again is a no-op, so a swarm can set it on every boot. Members below admin get 403, non-members 404.", "operationId": "updateOrg", "tags": [ "Orgs" ], "parameters": [ { "name": "orgId", "in": "path", "required": true, "schema": { "type": "string" }, "description": "Organization ID" } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": [ "swarmUrl" ], "properties": { "swarmUrl": { "type": [ "string", "null" ], "format": "uri", "maxLength": 2048, "description": "http(s) URL, or null to clear" } } } } } }, "responses": { "200": { "description": "The org after the update", "content": { "application/json": { "schema": { "type": "object", "required": [ "id", "name", "isPersonal", "swarmUrl" ], "properties": { "id": { "type": "string" }, "name": { "type": "string" }, "isPersonal": { "type": "boolean" }, "swarmUrl": { "type": [ "string", "null" ] } } } } } }, "400": { "description": "Missing or invalid swarmUrl", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Unauthorized", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "403": { "description": "Caller is not an org admin", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Org not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/orgs/{orgId}/public": { "get": { "summary": "Where to sign in to an org (no auth)", "description": "Public, for a browser with no key on an org deep link. Returns only the org's swarm URL. Unknown orgs get the same null as orgs without one, so the route reveals no org names and does not confirm that an org exists. Per-IP rate limit (120/min).", "operationId": "getOrgPublic", "tags": [ "Orgs" ], "security": [], "parameters": [ { "name": "orgId", "in": "path", "required": true, "schema": { "type": "string" }, "description": "Organization ID" } ], "responses": { "200": { "description": "The org's swarm URL, or null", "content": { "application/json": { "schema": { "type": "object", "required": [ "swarmUrl" ], "properties": { "swarmUrl": { "type": [ "string", "null" ] } } } } } }, "429": { "description": "Too many requests from this address" } } } }, "/orgs/{orgId}/members/{userId}/reset-key": { "post": { "summary": "Reset a member's API key (org admin only)", "description": "For another member, mints a new API key scoped to this org (it reaches only /orgs/{orgId}/...) and revokes the member's other keys scoped to it; their primary key and their own unscoped keys keep working. For the caller's own userId, rotates the caller's primary key like POST /auth/reset-key. Org-scoped keys get 403 here. Records an api_key_reset audit event with the admin as actor.", "operationId": "resetMemberApiKey", "tags": [ "Auth" ], "parameters": [ { "name": "orgId", "in": "path", "required": true, "schema": { "type": "string" }, "description": "Organization ID" }, { "name": "userId", "in": "path", "required": true, "schema": { "type": "string" }, "description": "ID of the member whose key to reset" } ], "responses": { "200": { "description": "Member's API key reset", "content": { "application/json": { "schema": { "type": "object", "properties": { "apiKey": { "type": "string" }, "userId": { "type": "string" }, "email": { "type": "string" }, "keyId": { "type": "string", "description": "Id of the new org-scoped key (another member only)" }, "orgId": { "type": "string", "description": "Org the new key is limited to (another member only)" } }, "required": [ "apiKey", "userId", "email" ] } } } }, "401": { "description": "Unauthorized", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "403": { "description": "Caller is not an org admin", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Org not found, or userId is not a member of the org", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/auth/keys": { "get": { "summary": "List your API keys", "description": "Lists the caller's active keys: the primary key (id `primary`, the one register and reset-key hand out) and every non-revoked additional key, including org-scoped keys an org admin minted for the caller. Never returns hashes or plaintext. `createdAt` and `lastUsedAt` are null for the primary key. `lastUsedAt` is refreshed at most once per minute per key. Org-scoped keys get 403 here.", "operationId": "listApiKeys", "tags": [ "Auth" ], "responses": { "200": { "description": "Active keys, primary first", "content": { "application/json": { "schema": { "type": "object", "properties": { "keys": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string", "description": "`primary` for the legacy primary key" }, "label": { "type": "string" }, "createdAt": { "type": [ "string", "null" ], "format": "date-time" }, "lastUsedAt": { "type": [ "string", "null" ], "format": "date-time" }, "primary": { "type": "boolean" }, "orgId": { "type": [ "string", "null" ], "description": "Org the key is limited to; null for a key that reaches the whole account" }, "createdByUserId": { "type": "string", "description": "Who minted the key: the user, or the org admin who did" }, "current": { "type": "boolean", "description": "True for the key that authenticated this request" } }, "required": [ "id", "label", "createdAt", "lastUsedAt", "primary", "orgId", "createdByUserId", "current" ] } } }, "required": [ "keys" ] } } } }, "401": { "description": "Unauthorized", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } }, "post": { "summary": "Create an additional API key", "description": "Mints a new key for the caller next to the existing ones; no other key changes. The key reaches the whole account, like the primary. The plaintext key is returned once and never stored. Records an api_key_created audit event in the caller's personal org. Org-scoped keys get 403 here.", "operationId": "createApiKey", "tags": [ "Auth" ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "label": { "type": "string", "minLength": 1, "maxLength": 100, "description": "Trimmed; shown in GET /auth/keys" } }, "required": [ "label" ] } } } }, "responses": { "201": { "description": "Key created", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "label": { "type": "string" }, "createdAt": { "type": "string", "format": "date-time" }, "apiKey": { "type": "string", "description": "Plaintext `af_` key, returned once" } }, "required": [ "id", "label", "createdAt", "apiKey" ] } } } }, "400": { "description": "Missing or invalid label", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Unauthorized", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/auth/keys/{keyId}": { "delete": { "summary": "Revoke one of your API keys", "description": "Revokes the key immediately. Any key may be revoked, including `primary`, the key making the request, and the last remaining key. A user with no keys left is locked out until an org admin runs POST /orgs/{orgId}/members/{userId}/reset-key, which mints a new primary key. Records an api_key_revoked audit event in the caller's personal org.", "operationId": "revokeApiKey", "tags": [ "Auth" ], "parameters": [ { "name": "keyId", "in": "path", "required": true, "schema": { "type": "string" }, "description": "Key id from GET /auth/keys, or `primary`" } ], "responses": { "200": { "description": "Key revoked", "content": { "application/json": { "schema": { "type": "object", "properties": { "ok": { "type": "boolean" } }, "required": [ "ok" ] } } } }, "401": { "description": "Unauthorized", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "No active key with this id belongs to the caller", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/orgs/{orgId}/members/{userId}/keys": { "post": { "summary": "Create an additional API key for a member (org admin only)", "description": "Org admins can mint an extra key for a member of the org without touching the member's existing keys (reset-key, by contrast, rotates the primary key). The key is scoped to this org: it authenticates as the member only on /orgs/{orgId} and the routes under it, with the member's current role; every other path returns 403, and so does POST /orgs/{orgId}/members/{userId}/reset-key. It is revoked when the member leaves the org, when the minting admin leaves the org or loses admin there, and when the member runs their own POST /auth/reset-key. The plaintext key is returned once and never stored. Records an api_key_created audit event in this org with the admin as actor.", "operationId": "createMemberApiKey", "tags": [ "Auth" ], "parameters": [ { "name": "orgId", "in": "path", "required": true, "schema": { "type": "string" }, "description": "Organization ID" }, { "name": "userId", "in": "path", "required": true, "schema": { "type": "string" }, "description": "ID of the member to mint a key for" } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "label": { "type": "string", "minLength": 1, "maxLength": 100, "description": "Trimmed; shown in GET /auth/keys" } }, "required": [ "label" ] } } } }, "responses": { "201": { "description": "Key created", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "string" }, "label": { "type": "string" }, "createdAt": { "type": "string", "format": "date-time" }, "apiKey": { "type": "string", "description": "Plaintext `af_` key, returned once" }, "userId": { "type": "string" }, "orgId": { "type": "string", "description": "The org the key is limited to" } }, "required": [ "id", "label", "createdAt", "apiKey", "userId", "orgId" ] } } } }, "400": { "description": "Missing or invalid label", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Unauthorized", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "403": { "description": "Caller is not an org admin", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Org not found, or userId is not a member of the org", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/orgs/{orgId}/drives/{driveId}/presence": { "get": { "summary": "Get drive presence", "operationId": "getPresence", "tags": [ "Drives" ], "description": "Any drive member can read the in-memory snapshot. Presence expires after 45 seconds without a PUT.", "parameters": [ { "name": "orgId", "in": "path", "required": true, "schema": { "type": "string" } }, { "name": "driveId", "in": "path", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Presence snapshot", "content": { "application/json": { "schema": { "type": "object", "required": [ "driveId", "sessions", "at" ], "properties": { "driveId": { "type": "string" }, "sessions": { "type": "array", "items": { "type": "object", "required": [ "path", "mode", "sessionId", "userId", "email", "displayName", "updatedAt" ], "properties": { "path": { "type": "string", "maxLength": 4096, "nullable": true }, "mode": { "type": "string", "enum": [ "view", "edit" ] }, "selection": { "type": "object", "properties": { "quote": { "type": "object", "properties": { "exact": { "type": "string", "maxLength": 256 }, "prefix": { "type": "string", "maxLength": 64 }, "suffix": { "type": "string", "maxLength": 64 } }, "required": [ "exact" ], "additionalProperties": false }, "lineStart": { "type": "integer", "minimum": 0 }, "lineEnd": { "$ref": "#/properties/selection/properties/lineStart" }, "fileVersion": { "type": "number", "nullable": true }, "collapsed": { "type": "boolean" } }, "required": [ "quote", "lineStart", "lineEnd", "collapsed" ], "additionalProperties": false, "nullable": true }, "pointer": { "type": "object", "properties": { "quote": { "$ref": "#/properties/selection/properties/quote" }, "charOffset": { "$ref": "#/properties/selection/properties/lineStart" }, "lineStart": { "$ref": "#/properties/selection/properties/lineStart" }, "fileVersion": { "$ref": "#/properties/selection/properties/fileVersion" } }, "required": [ "quote", "charOffset", "lineStart" ], "additionalProperties": false, "nullable": true }, "commentId": { "type": "string", "maxLength": 128, "nullable": true }, "commentState": { "type": "string", "enum": [ "viewing", "replying" ], "nullable": true }, "sessionId": { "type": "string", "pattern": "^[A-Za-z0-9_-]{8,64}$" }, "userId": { "type": "string" }, "email": { "type": "string" }, "displayName": { "type": "string", "nullable": true }, "updatedAt": { "type": "string", "format": "date-time", "description": "Last state change" } } } }, "at": { "type": "string", "format": "date-time" } } } } } }, "401": { "description": "Missing or invalid Bearer key" }, "404": { "description": "Drive not found or the user is not a member" }, "429": { "description": "RATE_LIMITED: presence request limit or 32 sessions per user per drive exceeded" } } } }, "/orgs/{orgId}/drives/{driveId}/presence/{sessionId}": { "parameters": [ { "name": "orgId", "in": "path", "required": true, "schema": { "type": "string" } }, { "name": "driveId", "in": "path", "required": true, "schema": { "type": "string" } }, { "name": "sessionId", "in": "path", "required": true, "schema": { "type": "string", "pattern": "^[A-Za-z0-9_-]{8,64}$" } } ], "put": { "summary": "Update a presence session", "operationId": "putPresence", "tags": [ "Drives" ], "description": "Any drive member can insert or replace their session. Unknown body keys are stripped. Equal states refresh TTL without broadcasting.", "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "path": { "type": "string", "maxLength": 4096, "nullable": true }, "mode": { "type": "string", "enum": [ "view", "edit" ] }, "selection": { "type": "object", "properties": { "quote": { "type": "object", "properties": { "exact": { "type": "string", "maxLength": 256 }, "prefix": { "type": "string", "maxLength": 64 }, "suffix": { "type": "string", "maxLength": 64 } }, "required": [ "exact" ], "additionalProperties": false }, "lineStart": { "type": "integer", "minimum": 0 }, "lineEnd": { "$ref": "#/properties/selection/properties/lineStart" }, "fileVersion": { "type": "number", "nullable": true }, "collapsed": { "type": "boolean" } }, "required": [ "quote", "lineStart", "lineEnd", "collapsed" ], "additionalProperties": false, "nullable": true }, "pointer": { "type": "object", "properties": { "quote": { "$ref": "#/properties/selection/properties/quote" }, "charOffset": { "$ref": "#/properties/selection/properties/lineStart" }, "lineStart": { "$ref": "#/properties/selection/properties/lineStart" }, "fileVersion": { "$ref": "#/properties/selection/properties/fileVersion" } }, "required": [ "quote", "charOffset", "lineStart" ], "additionalProperties": false, "nullable": true }, "commentId": { "type": "string", "maxLength": 128, "nullable": true }, "commentState": { "type": "string", "enum": [ "viewing", "replying" ], "nullable": true } }, "required": [ "path", "mode" ], "additionalProperties": false } } } }, "responses": { "200": { "description": "Presence session", "content": { "application/json": { "schema": { "type": "object", "required": [ "session" ], "properties": { "session": { "type": "object", "required": [ "path", "mode", "sessionId", "userId", "email", "displayName", "updatedAt" ], "properties": { "path": { "type": "string", "maxLength": 4096, "nullable": true }, "mode": { "type": "string", "enum": [ "view", "edit" ] }, "selection": { "type": "object", "properties": { "quote": { "type": "object", "properties": { "exact": { "type": "string", "maxLength": 256 }, "prefix": { "type": "string", "maxLength": 64 }, "suffix": { "type": "string", "maxLength": 64 } }, "required": [ "exact" ], "additionalProperties": false }, "lineStart": { "type": "integer", "minimum": 0 }, "lineEnd": { "$ref": "#/properties/selection/properties/lineStart" }, "fileVersion": { "type": "number", "nullable": true }, "collapsed": { "type": "boolean" } }, "required": [ "quote", "lineStart", "lineEnd", "collapsed" ], "additionalProperties": false, "nullable": true }, "pointer": { "type": "object", "properties": { "quote": { "$ref": "#/properties/selection/properties/quote" }, "charOffset": { "$ref": "#/properties/selection/properties/lineStart" }, "lineStart": { "$ref": "#/properties/selection/properties/lineStart" }, "fileVersion": { "$ref": "#/properties/selection/properties/fileVersion" } }, "required": [ "quote", "charOffset", "lineStart" ], "additionalProperties": false, "nullable": true }, "commentId": { "type": "string", "maxLength": 128, "nullable": true }, "commentState": { "type": "string", "enum": [ "viewing", "replying" ], "nullable": true }, "sessionId": { "type": "string", "pattern": "^[A-Za-z0-9_-]{8,64}$" }, "userId": { "type": "string" }, "email": { "type": "string" }, "displayName": { "type": "string", "nullable": true }, "updatedAt": { "type": "string", "format": "date-time", "description": "Last state change" } } } } } } } }, "400": { "description": "VALIDATION_ERROR: invalid sessionId or body" }, "401": { "description": "Missing or invalid Bearer key" }, "404": { "description": "Drive not found or the user is not a member" }, "409": { "description": "EDIT_CONFLICT: sessionId belongs to another user" }, "429": { "description": "RATE_LIMITED: presence request limit or 32 sessions per user per drive exceeded" } } }, "delete": { "summary": "Delete a presence session", "operationId": "deletePresence", "tags": [ "Drives" ], "description": "Only the owner can delete a session. An unknown session also succeeds.", "responses": { "200": { "description": "Session removed or unknown", "content": { "application/json": { "schema": { "type": "object", "required": [ "ok" ], "properties": { "ok": { "type": "boolean", "const": true } } } } } }, "400": { "description": "VALIDATION_ERROR: invalid sessionId" }, "401": { "description": "Missing or invalid Bearer key" }, "404": { "description": "Drive not found or the user is not a member" }, "409": { "description": "EDIT_CONFLICT: sessionId belongs to another user" }, "429": { "description": "RATE_LIMITED: presence request limit or 32 sessions per user per drive exceeded" } } } }, "/orgs/{orgId}/drives/{driveId}/events": { "get": { "summary": "Stream drive changes", "operationId": "watchDrive", "tags": [ "Drives" ], "description": "Drive members can stream committed changes with Bearer authentication. The first event is ready. Heartbeat comments (: ping) arrive every 5 seconds. Each user can open at most 8 concurrent streams. Events are live only, with no replay.", "parameters": [ { "name": "presence", "in": "query", "schema": { "type": "string", "enum": [ "1" ] }, "description": "Opt in to presence frames. Without presence=1 no presence frames are sent." }, { "name": "sessionId", "in": "query", "schema": { "type": "string", "pattern": "^[A-Za-z0-9_-]{8,64}$" }, "description": "With presence=1, bind a valid sessionId. The last stream to close removes its session." }, { "name": "orgId", "in": "path", "required": true, "schema": { "type": "string" } }, { "name": "driveId", "in": "path", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "SSE frames use event: and data: , followed by a blank line.", "content": { "text/event-stream": { "schema": { "type": "string" }, "example": "event: ready\ndata: {\"driveId\":\"drive-id\",\"at\":\"2026-09-30T12:00:00.000Z\"}\n\n: ping\n\n" } }, "x-sse-events": { "presence.snapshot": { "type": "object", "required": [ "driveId", "sessions", "at" ], "properties": { "driveId": { "type": "string" }, "sessions": { "type": "array", "items": { "type": "object", "required": [ "path", "mode", "sessionId", "userId", "email", "displayName", "updatedAt" ], "properties": { "path": { "type": "string", "maxLength": 4096, "nullable": true }, "mode": { "type": "string", "enum": [ "view", "edit" ] }, "selection": { "type": "object", "properties": { "quote": { "type": "object", "properties": { "exact": { "type": "string", "maxLength": 256 }, "prefix": { "type": "string", "maxLength": 64 }, "suffix": { "type": "string", "maxLength": 64 } }, "required": [ "exact" ], "additionalProperties": false }, "lineStart": { "type": "integer", "minimum": 0 }, "lineEnd": { "$ref": "#/properties/selection/properties/lineStart" }, "fileVersion": { "type": "number", "nullable": true }, "collapsed": { "type": "boolean" } }, "required": [ "quote", "lineStart", "lineEnd", "collapsed" ], "additionalProperties": false, "nullable": true }, "pointer": { "type": "object", "properties": { "quote": { "$ref": "#/properties/selection/properties/quote" }, "charOffset": { "$ref": "#/properties/selection/properties/lineStart" }, "lineStart": { "$ref": "#/properties/selection/properties/lineStart" }, "fileVersion": { "$ref": "#/properties/selection/properties/fileVersion" } }, "required": [ "quote", "charOffset", "lineStart" ], "additionalProperties": false, "nullable": true }, "commentId": { "type": "string", "maxLength": 128, "nullable": true }, "commentState": { "type": "string", "enum": [ "viewing", "replying" ], "nullable": true }, "sessionId": { "type": "string", "pattern": "^[A-Za-z0-9_-]{8,64}$" }, "userId": { "type": "string" }, "email": { "type": "string" }, "displayName": { "type": "string", "nullable": true }, "updatedAt": { "type": "string", "format": "date-time", "description": "Last state change" } } } }, "at": { "type": "string", "format": "date-time" } }, "description": "Only sent when presence=1, immediately after ready." }, "presence.updated": { "type": "object", "description": "Only sent when presence=1.", "required": [ "type", "driveId", "session", "at" ], "properties": { "type": { "type": "string", "const": "presence.updated" }, "driveId": { "type": "string" }, "session": { "type": "object", "required": [ "path", "mode", "sessionId", "userId", "email", "displayName", "updatedAt" ], "properties": { "path": { "type": "string", "maxLength": 4096, "nullable": true }, "mode": { "type": "string", "enum": [ "view", "edit" ] }, "selection": { "type": "object", "properties": { "quote": { "type": "object", "properties": { "exact": { "type": "string", "maxLength": 256 }, "prefix": { "type": "string", "maxLength": 64 }, "suffix": { "type": "string", "maxLength": 64 } }, "required": [ "exact" ], "additionalProperties": false }, "lineStart": { "type": "integer", "minimum": 0 }, "lineEnd": { "$ref": "#/properties/selection/properties/lineStart" }, "fileVersion": { "type": "number", "nullable": true }, "collapsed": { "type": "boolean" } }, "required": [ "quote", "lineStart", "lineEnd", "collapsed" ], "additionalProperties": false, "nullable": true }, "pointer": { "type": "object", "properties": { "quote": { "$ref": "#/properties/selection/properties/quote" }, "charOffset": { "$ref": "#/properties/selection/properties/lineStart" }, "lineStart": { "$ref": "#/properties/selection/properties/lineStart" }, "fileVersion": { "$ref": "#/properties/selection/properties/fileVersion" } }, "required": [ "quote", "charOffset", "lineStart" ], "additionalProperties": false, "nullable": true }, "commentId": { "type": "string", "maxLength": 128, "nullable": true }, "commentState": { "type": "string", "enum": [ "viewing", "replying" ], "nullable": true }, "sessionId": { "type": "string", "pattern": "^[A-Za-z0-9_-]{8,64}$" }, "userId": { "type": "string" }, "email": { "type": "string" }, "displayName": { "type": "string", "nullable": true }, "updatedAt": { "type": "string", "format": "date-time", "description": "Last state change" } } }, "at": { "type": "string", "format": "date-time" } } }, "presence.left": { "type": "object", "description": "Only sent when presence=1.", "required": [ "type", "driveId", "sessionId", "userId", "at" ], "properties": { "type": { "type": "string", "const": "presence.left" }, "driveId": { "type": "string" }, "sessionId": { "type": "string" }, "userId": { "type": "string" }, "at": { "type": "string", "format": "date-time" } } }, "ready": { "type": "object", "required": [ "driveId", "at" ], "properties": { "driveId": { "type": "string" }, "at": { "type": "string", "format": "date-time" } } }, "file.changed": { "type": "object", "required": [ "type", "driveId", "path", "version", "operation", "actor", "at" ], "properties": { "type": { "type": "string", "const": "file.changed" }, "driveId": { "type": "string" }, "path": { "type": "string" }, "version": { "type": "integer", "minimum": 1 }, "operation": { "type": "string", "enum": [ "write", "edit", "append", "delete", "revert" ] }, "actor": { "type": "string", "description": "User ID of the actor" }, "at": { "type": "string", "format": "date-time" } } }, "comment.changed": { "type": "object", "required": [ "type", "driveId", "path", "commentId", "parentId", "action", "actor", "at" ], "properties": { "type": { "type": "string", "const": "comment.changed" }, "driveId": { "type": "string" }, "path": { "type": "string" }, "commentId": { "type": "string" }, "parentId": { "type": [ "string", "null" ] }, "action": { "type": "string", "enum": [ "created", "updated", "resolved", "reopened", "deleted" ] }, "actor": { "type": "string", "description": "User ID of the actor" }, "at": { "type": "string", "format": "date-time" } } } } }, "401": { "description": "Missing or invalid Bearer key" }, "404": { "description": "Drive not found or the user is not a member" }, "409": { "description": "EDIT_CONFLICT: with presence=1, the sessionId belongs to another user" }, "429": { "description": "Concurrent stream cap or request rate limit exceeded" } } } }, "/orgs/{orgId}/ops": { "post": { "summary": "Dispatch a file operation", "operationId": "dispatchOp", "tags": [ "Operations" ], "description": "All file operations go through this single endpoint. The `op` field determines which operation to execute.", "parameters": [ { "name": "orgId", "in": "path", "required": true, "schema": { "type": "string" }, "description": "Organization ID" } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "oneOf": [ { "type": "object", "title": "write", "description": "Write or overwrite a file. Creates the file if it doesn't exist, or creates a new version. Use expectedVersion for optimistic concurrency. Returns { version, path, size }.", "required": [ "op", "path", "content" ], "properties": { "op": { "type": "string", "const": "write" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string" }, "content": { "type": "string" }, "message": { "type": "string" }, "expectedVersion": { "type": "integer" } }, "additionalProperties": false }, { "type": "object", "title": "cat", "description": "Read file content with optional pagination via offset/limit; defaults to the first 200 lines when limit is omitted. Returns { content, totalLines, truncated } — always check `truncated` before trusting a row/line count. For a complete, byte-exact read (e.g. before parsing as CSV/JSON), use `download` instead.", "required": [ "op", "path" ], "properties": { "op": { "type": "string", "const": "cat" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string" }, "offset": { "type": "integer", "minimum": 0 }, "limit": { "type": "integer", "minimum": 1 } }, "additionalProperties": false }, { "type": "object", "title": "edit", "description": "Replace a specific string in a file (surgical find-and-replace). Captures the edit intent as a diff summary in version history. Returns { version, path, changes }.", "required": [ "op", "path", "old_string", "new_string" ], "properties": { "op": { "type": "string", "const": "edit" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string" }, "old_string": { "type": "string", "minLength": 1 }, "new_string": { "type": "string" }, "message": { "type": "string" }, "expectedVersion": { "type": "integer" } }, "additionalProperties": false }, { "type": "object", "title": "append", "description": "Append content to the end of an existing file. Creates a new version. Returns { version, size }.", "required": [ "op", "path", "content" ], "properties": { "op": { "type": "string", "const": "append" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string" }, "content": { "type": "string" }, "message": { "type": "string" }, "expectedVersion": { "type": "integer" } }, "additionalProperties": false }, { "type": "object", "title": "ls", "description": "List immediate children of a directory. Returns { entries } where each entry has name, type (file/directory), size, author, modifiedAt.", "required": [ "op" ], "properties": { "op": { "type": "string", "const": "ls" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string" } }, "additionalProperties": false }, { "type": "object", "title": "stat", "description": "Get file metadata without reading content. Returns path, size, contentType, author, currentVersion, createdAt, modifiedAt, isDeleted, embeddingStatus, etag (opaque id of the current bytes, compare for equality). Embedding status is pending, indexed, failed, or skipped.", "required": [ "op", "path" ], "properties": { "op": { "type": "string", "const": "stat" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string" } }, "additionalProperties": false }, { "type": "object", "title": "reveal", "description": "Everything needed to show one file in a tree, in one call: the ls listing of every ancestor directory (root first) plus the file's stat. The path is at most 4096 characters and 128 levels deep. Returns { path, stat, listings } where each listing is { path, entries } with entries shaped exactly like ls.", "required": [ "op", "path" ], "properties": { "op": { "type": "string", "const": "reveal" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string", "maxLength": 4096 } }, "additionalProperties": false }, { "type": "object", "title": "rm", "description": "Delete a file. Removes from S3, cleans up FTS5 index and vector embeddings. Returns { path, deleted }.", "required": [ "op", "path" ], "properties": { "op": { "type": "string", "const": "rm" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string" }, "expectedVersion": { "type": "integer" } }, "additionalProperties": false }, { "type": "object", "title": "mv", "description": "Move or rename a file. Preserves version history at the new path. Returns { from, to, version }.", "required": [ "op", "from", "to" ], "properties": { "op": { "type": "string", "const": "mv" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "from": { "type": "string" }, "to": { "type": "string" }, "message": { "type": "string" }, "expectedVersion": { "type": "integer" } }, "additionalProperties": false }, { "type": "object", "title": "cp", "description": "Copy a file using server-side S3 copy. Creates a new version at the destination. Returns { from, to, version }.", "required": [ "op", "from", "to" ], "properties": { "op": { "type": "string", "const": "cp" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "from": { "type": "string" }, "to": { "type": "string" }, "expectedVersion": { "type": "integer" } }, "additionalProperties": false }, { "type": "object", "title": "tail", "description": "Read the last N lines of a file (default 20). Returns { content, totalLines, truncated }.", "required": [ "op", "path" ], "properties": { "op": { "type": "string", "const": "tail" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string" }, "lines": { "type": "integer", "minimum": 1 } }, "additionalProperties": false }, { "type": "object", "title": "log", "description": "Show version history for a file. Returns { versions } with version number, author, timestamp, operation type, message, and diff summary.", "required": [ "op", "path" ], "properties": { "op": { "type": "string", "const": "log" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string" }, "limit": { "type": "integer", "minimum": 1 } }, "additionalProperties": false }, { "type": "object", "title": "diff", "description": "Show the diff between two versions of a file. Specify v1 and v2 version numbers. Returns { changes, source } as add/remove/context hunks; when file content was diffed each change carries oldLine/newLine. source is 'content' when both versions were compared, 'summary' when changes come from the stored edit summary, or 'none' when the versions were not compared at all. Only source 'content' with empty changes means the versions are identical.", "required": [ "op", "path", "v1", "v2" ], "properties": { "op": { "type": "string", "const": "diff" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string" }, "v1": { "type": "integer" }, "v2": { "type": "integer" } }, "additionalProperties": false }, { "type": "object", "title": "revert", "description": "Revert a file to a previous version. Creates a new version with the old content. Returns { version, revertedTo }.", "required": [ "op", "path", "version" ], "properties": { "op": { "type": "string", "const": "revert" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string" }, "version": { "type": "integer" }, "expectedVersion": { "type": "integer" } }, "additionalProperties": false }, { "type": "object", "title": "recent", "description": "Show recent activity across the drive. Optionally filter by path prefix and time window (since). Returns { entries } with path and version details.", "required": [ "op" ], "properties": { "op": { "type": "string", "const": "recent" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string" }, "since": { "type": "string", "format": "date-time" }, "limit": { "type": "integer", "minimum": 1 } }, "additionalProperties": false }, { "type": "object", "title": "grep", "description": "Search file content using regex pattern within a specific path. Returns matching lines with line numbers. Searches the FTS5 index, not S3 directly.", "required": [ "op", "pattern", "path" ], "properties": { "op": { "type": "string", "const": "grep" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "pattern": { "type": "string" }, "path": { "type": "string" } }, "additionalProperties": false }, { "type": "object", "title": "fts", "description": "Full-text search across all file content using FTS5 tokens. Different from grep (regex) and search (semantic). Returns { matches } with path, snippet, and rank.", "required": [ "op", "pattern" ], "properties": { "op": { "type": "string", "const": "fts" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "pattern": { "type": "string" }, "path": { "type": "string" } }, "additionalProperties": false }, { "type": "object", "title": "search", "description": "Hybrid search combining semantic (vector) and keyword (FTS5) matching. Best for natural language queries. Degrades to keyword-only without an embedding provider.", "required": [ "op", "query" ], "properties": { "op": { "type": "string", "const": "search" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "query": { "type": "string" }, "limit": { "type": "integer", "minimum": 1 } }, "additionalProperties": false }, { "type": "object", "title": "vec-search", "description": "Vector-only semantic search using embeddings. Returns results ranked by cosine similarity. Requires an embedding provider (OPENAI_API_KEY, GEMINI_API_KEY, or local).", "required": [ "op", "query" ], "properties": { "op": { "type": "string", "const": "vec-search" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "query": { "type": "string" }, "limit": { "type": "integer", "minimum": 1 } }, "additionalProperties": false }, { "type": "object", "title": "reindex", "description": "Re-index files with failed or missing FTS5/embedding entries. Skip files with indexed or skipped status. Optionally scope to a path prefix. Use after bulk writes or provider changes.", "required": [ "op" ], "properties": { "op": { "type": "string", "const": "reindex" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string" } }, "additionalProperties": false }, { "type": "object", "title": "tree", "description": "Recursively list all files and directories. Use depth to limit recursion. Returns a nested tree structure with name, type, size, and children.", "required": [ "op" ], "properties": { "op": { "type": "string", "const": "tree" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string" }, "depth": { "type": "integer", "minimum": 1 } }, "additionalProperties": false }, { "type": "object", "title": "glob", "description": "Find files by name pattern. Use `*.md` for root-level files only, `**/*.md` for recursive matching across all subdirectories. Supports `*` (any chars except /), `?` (single char), `**` (any path depth). Optionally scope to a path prefix. Case-sensitive. To look up a file by an approximate name, use find. Returns { matches } with path, size, and modifiedAt.", "required": [ "op", "pattern" ], "properties": { "op": { "type": "string", "const": "glob" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "pattern": { "type": "string" }, "path": { "type": "string" } }, "additionalProperties": false }, { "type": "object", "title": "find", "description": "Find files by approximate name. Matching is case- and accent-insensitive. Every query word must match the path, in any order. The query is at most 256 characters. When no file has every word as typed, letters can be skipped (\"zphr\" finds \"Zephyr.pdf\"). File-name hits rank above folder hits. Optionally scope to a path prefix. Returns { matches, total }: matches holds path, size, modifiedAt, and score, best first, capped at limit (default 50). total counts all matching files.", "required": [ "op", "query" ], "properties": { "op": { "type": "string", "const": "find" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "query": { "type": "string", "minLength": 1, "maxLength": 256 }, "path": { "type": "string" }, "limit": { "type": "integer", "minimum": 1, "maximum": 500 } }, "additionalProperties": false }, { "type": "object", "title": "sql", "description": "Run a DuckDB SQL query over documents stored in the drive. Reference documents directly by path string literal (e.g. SELECT * FROM '/data/sales.csv') or bind them as named tables via `tables` ({ name: path } or { name: { path, format, includeFilename } } to override format detection). A glob in a path (`*`, `?`, `**`, e.g. FROM '/lake/tasks/*.csv' or '/lake/**/*.parquet') reads every matching file of one format as one table, columns unified by name; includeFilename: true adds a filename column with each row's drive path. Supports csv, tsv, parquet, xlsx, json, ndjson/jsonl (each also .gz except parquet/xlsx), sqlite (.db/.sqlite/.sqlite3, tables exposed as name.tablename), and .duckdb files. Queries run sandboxed: no filesystem or network access beyond the bound documents. Returns { columns, rows, rowCount, truncated, files, elapsedMs }; a glob's files entry lists its matches.", "required": [ "op", "query" ], "properties": { "op": { "type": "string", "const": "sql" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "query": { "type": "string" }, "tables": { "type": "object", "additionalProperties": { "anyOf": [ { "type": "string" }, { "type": "object", "properties": { "path": { "type": "string" }, "format": { "type": "string", "enum": [ "csv", "tsv", "parquet", "xlsx", "json", "ndjson", "sqlite", "duckdb" ] }, "includeFilename": { "type": "boolean" } }, "required": [ "path" ], "additionalProperties": false } ] } }, "maxRows": { "type": "integer", "minimum": 1, "maximum": 10000 } }, "additionalProperties": false }, { "type": "object", "title": "signed-url", "description": "Generate a temporary presigned URL for direct file download. Default expiry is 24 hours (86400 seconds). The URL requires no authentication. Set disposition to \"inline\" when the URL will be rendered in the browser (PDF in an iframe, image in a tab); the default \"attachment\" forces a download. Returns { url, path, expiresIn, expiresAt, kind }.", "required": [ "op", "path" ], "properties": { "op": { "type": "string", "const": "signed-url" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string" }, "expiresIn": { "type": "integer", "minimum": 60, "maximum": 604800 }, "disposition": { "type": "string", "enum": [ "inline", "attachment" ] } }, "additionalProperties": false }, { "type": "object", "title": "upload-start", "description": "Start a large upload (for files above the server's raw upload limit, up to 5 GiB) that goes straight to storage. Returns { uploadId, path, size, partSize, partCount, partUrlExpiresIn }. Then, for each partNumber 1..partCount, call upload-part-url and PUT bytes [(partNumber-1)*partSize, partNumber*partSize) to the returned url (no auth header; retry a failed part with a fresh url). Finish with upload-finish, or upload-abort to discard. Only the user who started an upload can sign, finish or abort it. Needs editor. Storage backends without presigned uploads (local disk) answer UNSUPPORTED_OPERATION.", "required": [ "op", "path", "size" ], "properties": { "op": { "type": "string", "const": "upload-start" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string" }, "size": { "type": "integer", "minimum": 1 } }, "additionalProperties": false }, { "type": "object", "title": "upload-part-url", "description": "Get a presigned PUT url for one part of an upload from upload-start. The url needs no auth and expires in 15 minutes; ask again for each retry. Returns { url, method, partNumber, expiresIn, expiresAt }.", "required": [ "op", "path", "uploadId", "partNumber" ], "properties": { "op": { "type": "string", "const": "upload-part-url" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string" }, "uploadId": { "type": "string", "minLength": 1 }, "partNumber": { "type": "integer", "minimum": 1, "maximum": 10000 } }, "additionalProperties": false }, { "type": "object", "title": "upload-finish", "description": "Finish an upload from upload-start: checks that parts 1..N are all there and add up to size, then stores the file as a new version (like write: expectedVersion, message, versioning, search indexing for files up to the raw upload limit). Returns { version, path, size, contentHash }. A rejected finish (EDIT_CONFLICT, QUOTA_EXCEEDED) keeps the parts in storage: retry it, or call upload-abort to discard them.", "required": [ "op", "path", "uploadId", "size" ], "properties": { "op": { "type": "string", "const": "upload-finish" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string" }, "uploadId": { "type": "string", "minLength": 1 }, "size": { "type": "integer", "minimum": 1 }, "message": { "type": "string" }, "expectedVersion": { "type": "integer" } }, "additionalProperties": false }, { "type": "object", "title": "upload-abort", "description": "Discard an unfinished upload from upload-start and the parts already sent. Returns { aborted, path, uploadId }.", "required": [ "op", "path", "uploadId" ], "properties": { "op": { "type": "string", "const": "upload-abort" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string" }, "uploadId": { "type": "string", "minLength": 1 } }, "additionalProperties": false }, { "type": "object", "title": "share-create", "description": "Create a public share link for a file or folder. A file gets an unauthenticated /share/ page on the API host with a preview (markdown, text/code, image, PDF, audio, video, and HTML pages rendered in a sandboxed frame with only that file shared) and a Download button. A folder becomes an HTML site (kind \"site\") at /site//: index.html is the entry page (without one, the only HTML page opens, or else a list of the HTML pages), relative paths resolve inside the folder, and pages run in a sandbox with no cookies or localStorage. A site page can read every file under its folder while the link is valid. Default expiry is 24 hours (max 7 days); expiresIn null makes a link with no time limit, which ends only with share-revoke or at maxViews. Set maxViews to limit how often a file page can be opened (maxViews=1 is a one-off link; folders reject maxViews). Anyone with the link can open it, so share deliberately. Returns { id, kind, url, urlSource, sharePath, path, expiresIn, expiresAt, maxViews } (expiresIn and expiresAt are null for a link that never expires); urlSource (always present) is \"configured\" when url is built on AGENT_FS_PUBLIC_URL, \"request\" when it comes from the request's Host (resolve sharePath against the address you reached the API at). The link is shown only once; keep the id to revoke it.", "required": [ "op", "path" ], "properties": { "op": { "type": "string", "const": "share-create" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string" }, "expiresIn": { "type": "integer", "minimum": 60, "maximum": 604800, "nullable": true }, "maxViews": { "type": "integer", "minimum": 1, "maximum": 1000000 } }, "additionalProperties": false }, { "type": "object", "title": "share-revoke", "description": "Revoke share links so they stop working immediately. Pass exactly one of: id (from share-create), token (the token or the full share URL), or path (revokes every link to that file or folder). Only the link's creator or a drive admin can revoke. Returns { revoked, ids }.", "required": [ "op" ], "properties": { "op": { "type": "string", "const": "share-revoke" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "id": { "type": "string" }, "token": { "type": "string" }, "path": { "type": "string" } }, "additionalProperties": false }, { "type": "object", "title": "comment-add", "description": "Add a comment to a file. Supports line ranges, a text-quote anchor ({ exact, prefix, suffix }), mentions by drive-member user ID or email, and threading via parentId. Replies auto-resolve path from parent. Returns { id, path, body, author, createdAt }.", "required": [ "op", "body" ], "properties": { "op": { "type": "string", "const": "comment-add" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string" }, "body": { "type": "string" }, "parentId": { "type": "string" }, "mentions": { "type": "array", "items": { "type": "string", "minLength": 1 }, "maxItems": 20 }, "lineStart": { "type": "integer" }, "lineEnd": { "type": "integer" }, "quotedContent": { "type": "string" }, "quote": { "type": "object", "properties": { "exact": { "type": "string" }, "prefix": { "type": "string" }, "suffix": { "type": "string" } }, "required": [ "exact" ], "additionalProperties": false, "description": "Text-quote anchor: the exact selected text plus ~32 chars of context before (prefix) and after (suffix). Lets viewers re-find the selection after the file is edited." } }, "additionalProperties": false }, { "type": "object", "title": "comment-list", "description": "List comments on a file or below a path prefix. Filter by path, pathPrefix, resolved state, or parentId. Defaults to unresolved root comments. Returns { comments } with inline replies.", "required": [ "op" ], "properties": { "op": { "type": "string", "const": "comment-list" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string" }, "pathPrefix": { "type": "string" }, "parentId": { "type": "string" }, "resolved": { "type": "boolean" }, "orgId": { "type": "string" }, "limit": { "type": "integer", "minimum": 1 }, "offset": { "type": "integer", "minimum": 0 } }, "additionalProperties": false }, { "type": "object", "title": "comment-get", "description": "Get a single comment by ID with all its replies. Returns { comment, replies }.", "required": [ "op", "id" ], "properties": { "op": { "type": "string", "const": "comment-get" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "id": { "type": "string" } }, "additionalProperties": false }, { "type": "object", "title": "comment-update", "description": "Update a comment's body and optionally replace its mentions. Mentions accept drive-member user IDs or emails. Only the original author can update. Returns { id, body, updatedAt }.", "required": [ "op", "id", "body" ], "properties": { "op": { "type": "string", "const": "comment-update" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "id": { "type": "string" }, "body": { "type": "string" }, "mentions": { "type": "array", "items": { "type": "string", "minLength": 1 }, "maxItems": 20 } }, "additionalProperties": false }, { "type": "object", "title": "comment-delete", "description": "Soft-delete a comment. Only the original author can delete. Deleting a root comment also soft-deletes its replies. Returns { deleted }.", "required": [ "op", "id" ], "properties": { "op": { "type": "string", "const": "comment-delete" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "id": { "type": "string" } }, "additionalProperties": false }, { "type": "object", "title": "comment-resolve", "description": "Resolve or reopen a root comment. Set resolved=true to resolve, resolved=false to reopen. Only root comments can be resolved. Returns { id, resolved, resolvedBy, resolvedAt }.", "required": [ "op", "id", "resolved" ], "properties": { "op": { "type": "string", "const": "comment-resolve" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "id": { "type": "string" }, "resolved": { "type": "boolean" } }, "additionalProperties": false }, { "type": "object", "title": "comment-notification-list", "description": "List comment or mention notifications for the current user in the active drive. Defaults to comment notifications. Returns { notifications, unreadCount }.", "required": [ "op" ], "properties": { "op": { "type": "string", "const": "comment-notification-list" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "unreadOnly": { "type": "boolean" }, "kinds": { "type": "array", "items": { "type": "string", "enum": [ "comment", "mention" ] }, "minItems": 1 }, "limit": { "type": "integer", "minimum": 1, "maximum": 100 }, "offset": { "type": "integer", "minimum": 0 } }, "additionalProperties": false }, { "type": "object", "title": "comment-notification-read", "description": "Mark selected comment or mention notification IDs, or all notifications of the selected kinds in the active drive, as read. All defaults to comment notifications. Returns { markedRead }.", "required": [ "op" ], "properties": { "op": { "type": "string", "const": "comment-notification-read" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "ids": { "type": "array", "items": { "type": "string" }, "minItems": 1, "maxItems": 100 }, "all": { "type": "boolean", "enum": [ true ] }, "kinds": { "type": "array", "items": { "type": "string", "enum": [ "comment", "mention" ] }, "minItems": 1 } }, "additionalProperties": false }, { "type": "object", "title": "drive-members", "description": "List members of the active drive. Returns { members } with userId, email, and displayName. Membership roles are not included.", "required": [ "op" ], "properties": { "op": { "type": "string", "const": "drive-members" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" } }, "additionalProperties": false }, { "type": "object", "title": "favorite-add", "description": "Star a file or folder for the current user. Favorites are personal: no other user sees them. Starring twice is a no-op. Moving or renaming a starred file keeps the star; deleting it removes the star, and a folder's star goes away once the folder is gone. Returns { path, kind, createdAt, favorited }.", "required": [ "op", "path" ], "properties": { "op": { "type": "string", "const": "favorite-add" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string" } }, "additionalProperties": false }, { "type": "object", "title": "favorite-remove", "description": "Remove the current user's star from a file or folder. Works even when the path no longer exists. Returns { path, removed } where removed is false when there was no star.", "required": [ "op", "path" ], "properties": { "op": { "type": "string", "const": "favorite-remove" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "path": { "type": "string" } }, "additionalProperties": false }, { "type": "object", "title": "favorite-list", "description": "List the current user's favorites in the active drive, sorted by path. Returns { favorites } with path, kind (file/directory), and createdAt.", "required": [ "op" ], "properties": { "op": { "type": "string", "const": "favorite-list" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" } }, "additionalProperties": false }, { "type": "object", "title": "webhook-create", "description": "Create an outbound webhook that POSTs signed Standard Webhooks events (comment.created, comment.mentioned, comment.updated, comment.resolved, comment.reopened, comment.deleted, file.changed) to url. Only the listed eventTypes are sent; file.changed (one per new file version: path, version, operation, author, size, etag, never content) must be listed explicitly, and pathPrefix limits it to one directory. scope 'drive' (default) covers the active drive and needs drive admin or org admin; scope 'org' covers every drive in the org and needs org admin. The url must be public https (private/loopback targets only via the server's AGENT_FS_WEBHOOK_ALLOWED_HOSTS). Returns the webhook plus its whsec_ signing secret, shown only this once. Delivery needs AGENT_FS_WEBHOOK_WORKER on the server (see workerEnabled).", "required": [ "op", "url", "eventTypes" ], "properties": { "op": { "type": "string", "const": "webhook-create" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "scope": { "type": "string", "enum": [ "drive", "org" ], "description": "drive (default): the active drive only. org: every drive in the org (org admin only)." }, "url": { "type": "string", "format": "uri", "maxLength": 2048 }, "eventTypes": { "type": "array", "items": { "type": "string", "enum": [ "comment.created", "comment.mentioned", "comment.updated", "comment.resolved", "comment.reopened", "comment.deleted", "file.changed" ] }, "minItems": 1, "maxItems": 7 }, "description": { "type": "string", "maxLength": 500 }, "pathPrefix": { "type": "string", "maxLength": 1024, "description": "Send file.changed only for paths under this directory, e.g. /docs/ (it does not filter comment events). Omit or '/' for every path." } }, "additionalProperties": false }, { "type": "object", "title": "webhook-list", "description": "List outbound webhooks. scope 'drive' needs drive admin or org admin, 'org' needs org admin, and 'all' (default) returns this drive's hooks for a drive admin plus the org's hooks for an org admin. Never returns signing secrets. Returns { webhooks }.", "required": [ "op" ], "properties": { "op": { "type": "string", "const": "webhook-list" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "scope": { "type": "string", "enum": [ "drive", "org", "all" ] } }, "additionalProperties": false }, { "type": "object", "title": "webhook-update", "description": "Update a webhook's url, eventTypes, description or pathPrefix, enable or disable it, or rotate its signing secret. Needs drive admin or org admin for a drive hook, org admin for an org hook. enabled=true clears the disabled state and failure counters; enabled=false fails its pending deliveries. rotateSecret=true returns the new whsec_ secret once; the old secret stops working at once (no grace period). Returns the webhook.", "required": [ "op", "id" ], "properties": { "op": { "type": "string", "const": "webhook-update" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "id": { "type": "string" }, "url": { "type": "string", "format": "uri", "maxLength": 2048 }, "eventTypes": { "type": "array", "items": { "type": "string", "enum": [ "comment.created", "comment.mentioned", "comment.updated", "comment.resolved", "comment.reopened", "comment.deleted", "file.changed" ] }, "minItems": 1, "maxItems": 7 }, "description": { "type": "string", "maxLength": 500, "description": "An empty string clears it." }, "pathPrefix": { "type": "string", "maxLength": 1024, "description": "Directory that limits file.changed, e.g. /docs/. An empty string or '/' clears it." }, "enabled": { "type": "boolean" }, "rotateSecret": { "type": "boolean" } }, "additionalProperties": false }, { "type": "object", "title": "webhook-delete", "description": "Delete a webhook and its delivery history. Needs drive admin or org admin for a drive hook, org admin for an org hook. Returns { deleted }.", "required": [ "op", "id" ], "properties": { "op": { "type": "string", "const": "webhook-delete" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "id": { "type": "string" } }, "additionalProperties": false }, { "type": "object", "title": "webhook-test", "description": "Send a signed ping event to a webhook now, inline, and report the receiver's answer. Works with the delivery worker off and does not count toward failures. Needs drive admin or org admin for a drive hook, org admin for an org hook. Returns { ok, statusCode, error, durationMs, webhookId }.", "required": [ "op", "id" ], "properties": { "op": { "type": "string", "const": "webhook-test" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "id": { "type": "string" } }, "additionalProperties": false }, { "type": "object", "title": "share-list", "description": "List share links without revealing them: the link itself is shown only once, by share-create, and is never listed. scope \"drive\" (default) lists links in the active drive; drive admins see every member's links, everyone else only their own. With path, it returns the links on that file or folder plus folder (site) links on any parent folder that also publish it (relation \"exact\" or \"covering\"). scope \"mine\" lists your own links in every drive of this org you are a member of (one org, never across orgs; path not allowed). Active links only unless includeInactive is true. Newest first; limit (default 100, max 500) and offset page through total. Returns { shares, total, limit, offset, scope, visibility } where each share has id, drive { id, name }, path, kind (file/site), relation, status (active/expired/exhausted/revoked), createdAt, createdBy { userId, email, displayName }, expiresAt (null = never expires), views, maxViews, lastViewedAt, revokedAt, revokedBy { userId, email, displayName } (null when active, revoked before revokers were recorded, or ended by the creator's removal from the drive or org), canRevoke, and appUrl when configured. Revoke a link with share-revoke and its id, on the drive in drive.id.", "required": [ "op" ], "properties": { "op": { "type": "string", "const": "share-list" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "scope": { "type": "string", "enum": [ "drive", "mine" ] }, "path": { "type": "string" }, "includeInactive": { "type": "boolean" }, "limit": { "type": "integer", "minimum": 1, "maximum": 500 }, "offset": { "type": "integer", "minimum": 0 } }, "additionalProperties": false }, { "type": "object", "title": "webhook-deliveries", "description": "List a webhook's delivery log, newest first: status (pending, delivered, failed), attempts, next attempt, last status code and error. Omits each delivery's payload unless includePayload is true (it is then the exact JSON body that was signed and sent). Delivered and failed rows are pruned after 30 days. Needs drive admin or org admin for a drive hook, org admin for an org hook. Returns { deliveries, nextCursor }; pass nextCursor back as cursor for the next page (null on the last page).", "required": [ "op", "id" ], "properties": { "op": { "type": "string", "const": "webhook-deliveries" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "id": { "type": "string", "description": "Webhook id." }, "status": { "type": "string", "enum": [ "pending", "delivered", "failed" ] }, "limit": { "type": "integer", "minimum": 1, "maximum": 200, "description": "Page size, default 50." }, "cursor": { "type": "string", "maxLength": 512, "description": "nextCursor from the previous page." }, "includePayload": { "type": "boolean" } }, "additionalProperties": false }, { "type": "object", "title": "webhook-redeliver", "description": "Queue one delivery to be sent again now with the same webhook-id and body: sets it pending, due now, and keeps its attempt count (a row past the retry schedule gets this one attempt, no further retries). Refused while the webhook is disabled (re-enable it with webhook-update enabled=true first) and while the delivery is being sent. Needs the same role as the webhook. Sent by the delivery worker (AGENT_FS_WEBHOOK_WORKER). Returns the delivery.", "required": [ "op", "deliveryId" ], "properties": { "op": { "type": "string", "const": "webhook-redeliver" }, "driveId": { "type": "string", "description": "Target drive ID (optional, uses default drive)" }, "deliveryId": { "type": "string" } }, "additionalProperties": false } ], "discriminator": { "propertyName": "op" } } } } }, "responses": { "200": { "description": "Operation result (varies by op)", "content": { "application/json": { "schema": { "type": "object", "description": "Response shape depends on the operation. See each op's description for details." } } } }, "400": { "description": "Validation error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "401": { "description": "Unauthorized", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "403": { "description": "Permission denied (RBAC)", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "File or resource not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } } }, "components": { "securitySchemes": { "bearerAuth": { "type": "http", "scheme": "bearer", "description": "API key obtained from /auth/register" } }, "schemas": { "Error": { "type": "object", "properties": { "error": { "type": "string" }, "message": { "type": "string" } }, "required": [ "error", "message" ] } } }, "security": [ { "bearerAuth": [] } ] }