- Stage local files for
ask_stefanbrainand receive temporaryupload_...identifiers. - List and download the current workspace files produced inside a chat.
stefan_sk_... key or one scoped to include runs, or any stefan_oat_... OAuth token (OAuth tokens are not scoped). A key that stages files and then calls ask_stefanbrain needs both runs and tools.
Stage files for an ask
Sendmultipart/form-data to POST /api/developers/v1/files. Add each file as a repeated files field.
upload_... id to prepare_launch as file, or to upload_creative as source {kind: "upload", upload_id}. ask_stefanbrain refuses a staged video. For a video over 100 MB, pass a public https link as prepare_launch file or upload_creative source.url. Other video types and all audio are rejected: host the media and put its public URL in the ask_stefanbrain message instead.
The endpoint returns 201:
file_ids:
An MCP client that cannot send multipart HTTP can call
stage_file with a public URL or base64-encoded file. Its upload_id works in the same file_ids field.List a chat’s current workspace files
UseGET /api/developers/v1/files?chat_id=... to retrieve the current workspace file heads from an accessible chat.
limit to get every current workspace file head in one response. To page a large listing, pass limit from 1 to 200 and then send the returned next_cursor with the same limit:
path. Paged responses are sorted by path. Each opaque cursor binds the credential kind, API key or OAuth token, owner, and chat, and expires after 15 minutes. Pages recompute current heads, so an overwrite before a later page returns the newest version without skipping that path. id is the SHA-256 of the current head, so id and sha256 change when the file is edited. Each page mints download URLs only for its files.
Each request checks up to 200 candidates, so pages can be short or empty when files are unavailable.
Continue while complete is false, even when files is empty. The cursor advances past the last examined candidate.
Follow each non-null next_cursor to finish the listing. New paths after the cursor can appear, deleted paths disappear, and paths at or before the cursor are not revisited.
The final page has complete: true and next_cursor: null; an earlier page has complete: false and a cursor.
Search a chat’s workspace files
UseGET /api/developers/v1/files/search?chat_id=...&q=... to find files in an accessible chat by name or by the words inside them. It searches the same files the listing returns.
- Name matches come first, then the best content matches. A content match carries up to two passages; parts with
"match": trueare the matched words. qreads like a web search:"quoted phrase",or, and-wordwork. The last word matches as a prefix, sopositioning brifinds “positioning brief”.- A file matches by name as soon as it is written, and by its contents about a minute later. Text, Markdown, JSON, PDF, Word, PowerPoint, and Excel files are searchable by contents, up to their first 200,000 characters.
- A typed output (an image set, video cuts, a report) holds many files but answers once, as the file in it that matched best. StefanBrain’s scratch (frames, temporary folders, logs) never matches.
- A response holds up to 50 results. Download one with the
idandpaththroughGET /api/developers/v1/files/{id}/download?chat_id=...&path=....
Download the current file
Request the returned absolutedownload_url without an authorization header:
download.uri exactly as returned when a job result provides it; do not reconstruct the path under /files or /artifacts.
Each link expires after 10 minutes. List the files again to obtain a fresh link.
Links are tied to the credential that requested them. Revoking that credential,
removing file access, or deleting the file withdraws access before expiry.
Treat grant URLs as credentials: do not log them or store them in durable records.
The response streams the bytes as an attachment with private, no-store caching.
The authenticated /files/{id}/download?chat_id=...&path=... route remains available
for current workspace heads and supports range requests.
Listing and downloading are reads of existing work. They do not consume request limits or a billing budget.
Handle file errors
400 invalid_multipart_body,no_files,too_many_files,unsupported_attachment, orattachment_too_large: change the upload.400 chat_id_required,invalid_chat,invalid_limit,cursor_not_supported, orinvalid_cursor: correct the listing request.400 query_requiredorquery_too_long: send aqof 1 to 200 characters.400 invalid_file_id,invalid_chat, orpath_required: request thedownload_urlexactly as the listing returned it.404 chat_not_found: the credential cannot access the requested chat.404 file_not_found: the file is unavailable or is not a current workspace file head.
ask_stefanbrain addressing.
