Skip to main content
The Files API supports two workflows:
  • Stage local files for ask_stefanbrain and receive temporary upload_... identifiers.
  • List and download the current workspace files produced inside a chat.
Use a full-access 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

Send multipart/form-data to POST /api/developers/v1/files. Add each file as a repeated files field.
One request accepts up to 10 files, each up to 100 MB. Supported types include images, PDFs, Office documents, spreadsheets, text files, and MP4 or MOV videos. Videos are for launching ads. Pass a video’s 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:
Pass the identifiers in file_ids:
Uploads expire after 24 hours and can be reused across asks before they expire. Staging consumes a request-limit unit but does not use the API wallet or plan pool.
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

Use GET /api/developers/v1/files?chat_id=... to retrieve the current workspace file heads from an accessible chat.
Omit 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:
Each logical file appears once, keyed by 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

Use GET /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": true are the matched words.
  • q reads like a web search: "quoted phrase", or, and -word work. The last word matches as a prefix, so positioning bri finds “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 id and path through GET /api/developers/v1/files/{id}/download?chat_id=...&path=....

Download the current file

Request the returned absolute download_url without an authorization header:
Copy 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, or attachment_too_large: change the upload.
  • 400 chat_id_required, invalid_chat, invalid_limit, cursor_not_supported, or invalid_cursor: correct the listing request.
  • 400 query_required or query_too_long: send a q of 1 to 200 characters.
  • 400 invalid_file_id, invalid_chat, or path_required: request the download_url exactly 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.
See StefanBrain MCP for in-client staging and Tools and jobs for ask_stefanbrain addressing.