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. Supported types include images, PDFs, Office documents, spreadsheets, and text files. Audio and video files 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.
The response is a complete snapshot, not a paginated history:
Each logical file appears once, keyed by path. id is the SHA-256 of the current head, so id, sha256, and download_url change when the file is edited; list again for the current URL. Do not send a cursor. The endpoint returns every current workspace file head in one response.

Download the current file

Request the returned download_url with the same credential:
The response streams the current bytes as an attachment and supports range requests. Workspace heads are mutable, so downloads use private, no-store caching. 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, or cursor_not_supported: correct the listing request.
  • 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.