Upload and manage content
Turn on Read files and search and Add and update content for the connection. Changing content needs Add and update content, and reading files and following processing needs Read files and search. Deleting needs Delete content. See permissions.
Every change takes an idempotency_key, and a change to an existing item takes the version you last read. A stale_version answer means someone changed it meanwhile and nothing was written. See rules for every change.
Work on files where they are
Large, binary and media files (video, audio, images, archives, models) are best changed where they live, not downloaded and uploaded again. Ask the assistant to use, in this order:
- A mount. With the CLI installed where the assistant runs,
flashdrive mountshows the drive as a local folder, so any program can open, edit and save its files.flashdrive pullandflashdrive pushgive the same result without mounting. See mount, pull and push. - Edits in place.
edit_textreplaces exact text in a text file.write_byteswrites up to 32,768 bytes from the conversation, andedit_filegives a URL that your shell sends up to 64 MiB per request to. Each makes a new version from the current one plus your change, for example to append to a log or fix a header. - A stream, for programs that only read.
get_filereturns a URL that answers HTTPRange, soffmpeg,ffprobe, DuckDB,curl -rand video players seek and read only what they need.read_bytesreturns a few raw bytes, such as a file header. - Download and upload again only when a program can use none of these, and have the assistant say why.
Run URLs from get_file, edit_file and upload_transfer in your shell, outside the conversation. They need no Authorization header, so treat them like a password: never paste one into a tool argument, a file or a message.
Edit text in place
edit_text changes a text file (TXT, Markdown, or code and other UTF-8 files) as one new version. Each entry in edits replaces old with new, where old is exact text that occurs exactly once in the file as the earlier edits left it:
{
"drive_id": "DRIVE_ID",
"document_id": "DOCUMENT_ID",
"version": "7",
"idempotency_key": "fix-install-step-1",
"edits": [{"old": "Refunds are available within 14 days.", "new": "Refunds are available within 30 days."}]
}
The edits apply in order, all or nothing, to text up to 8 MiB. On edit_text_not_found or edit_text_not_unique, nothing was written and details.index names the edit: read the file again and make old exact, with enough surrounding lines to be unique.
Upload a file
- In your shell, find the file's size and SHA-256 (
stat,shasum -a 256). prepare_uploadreserves the upload with itsexternal_id,filename,format,size_bytesandsha256, and optionallyfolder_idandmetadata. Usepdf,docx,txtormdfor files to read for text, andfilefor anything else (photos, video, audio, archives, models). A file can be up to 10 GB.upload_transferreturns a URL, a method and headers.- Your shell sends the original bytes to that URL with exactly those headers and no Authorization header, for example
curl -T file.mp4 -H 'Content-Type: application/octet-stream' "$URL". The URL works for this one upload only. complete_uploadstarts processing: send{"transport": "direct"}after a direct transfer,{}otherwise.get_uploadandget_operationfollow progress until processing finishes.
A PDF or DOCX with no text layer, such as a scan, is kept rather than failed, with text_status none on the document.
To replace an uploaded file, read it with get_document, then send its document_id, external_id and latest_revision (as expected_revision) to prepare_upload.
The client needs access to the local file and a shell to hash and send its bytes. Without one, upload through the Console, the CLI or the SDK. Never paste file contents into the conversation.
Add text
For text that has no file of its own, add_documents takes a list of documents, each with an external_id and text, and optional metadata and folder_id:
{
"drive_id": "DRIVE_ID",
"idempotency_key": "refund-policy-edition-1",
"body": {"documents": [{"external_id": "refund-policy", "text": "Refunds are available within 30 days.", "metadata": {"topic": "support"}}]}
}
The answer includes an operation ID; follow it with get_operation, the workspace ID and the drive ID (drive_id, which the answer names).
update_document replaces the text of a document added this way. Send every metadata field and the folder you want to keep; omitted values are not merged with the previous version. Never use it on an uploaded file: it would drop the file's bytes and name.
Conflict copies
Nothing is overwritten. When a file changed on the drive while someone was working on it in a mount, the drive keeps its version under the file's name and saves the other version beside it as a recovery copy such as name (conflict 20261114T010203Z a1b2c3d4).ext. flashdrive push keeps such a copy in the local working copy instead. See mount, pull and push.
Ask the assistant to resolve each copy and leave none behind:
- Find them with the
recoverytool. - Compare the copy with the original:
read_filefor text; for media,get_documentmetadata andsize_bytes. - Text whose changes do not overlap: merge them into the original, delete the copy, and tell you in one line what was merged.
- Anything else, and any video or other binary file unless their checksums match: the assistant asks what to keep (the original, the copy, a merge, or both).
- Write the result over the original. For an uploaded file, use
prepare_uploadwith the original'sdocument_id,external_idandexpected_revision, neverupdate_document, and never delete the original and rename the copy. Then delete the copy, or rename it withmove_fileif you keep both.
Without write access or a shell, the assistant tells you about the copies instead of resolving them.
Organize or remove content
move_filemoves a file to another folder and renames it, or both.move_foldermoves a folder with everything in it.ensure_folderscreates a folder tree in one call before an upload.- Read the folder, file or drive before changing or deleting it, and pass its version.
delete_folderdeletes an empty folder. Withrecursive: trueit deletes the folder and everything in it: the folders go at once, and the assistant callscontinue_folder_deletionuntilstateisfinished.delete_drivedeletes a drive that holds no files or folders and is not the workspace's default. Choose another default before deleting the default drive.
Review what will be deleted with the assistant before it deletes anything. See the tool reference for every tool and its inputs.