upload_document
Attach an actual FILE to a record (lead/contact/account/campaign) — stored in private Supabase Storage, not just a URL reference. Required: entity, entity_id, and EITHER source_url OR content_base64 (not both).
IF YOU HAVE SHELL/CODE-EXECUTION ACCESS (Bash, a script runner, etc.) AND THE FILE IS ONLY ON LOCAL DISK: do NOT use content_base64 here. Use create_document_upload_url + finalize_document_upload instead — that flow lets your shell do a plain HTTP PUT of the raw bytes, which costs you ZERO context/output tokens, no matter the file size. Reserve content_base64 on THIS tool for content so small you already have it as text in your own context anyway (a few KB at most) — generating a large base64 string as your own output defeats the point of having shell access.
PREFER source_url when the file already has a stable URL (the server fetches it directly — also zero cost to you). Use content_base64 only for genuinely tiny content with no reachable URL and no shell access. filename is required with content_base64, optional with source_url (derived from the URL).
Optional either way: mime_type, doc_type (default 'file'), title (default filename), description, amount, currency, status, occurred_at, analyze (default true — runs AI analysis synchronously and writes a summary into description; set false to skip). AI analysis extracts text from PDF, Word (.docx), Excel (.xlsx, one Markdown table per sheet), PowerPoint/OpenDocument and txt/md/csv/json/html, stores it (read it back with get_document_text) and indexes it for search_knowledge — images, scans and old .doc/.xls store fine but return analyzed:false with a reason (use run_document_step vision_ocr for scans). Returns { document_id, storage_path, mime_type, file_size, analyzed, description? }.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"entity": "<entity>",
"entity_id": "<entity_id>"
},
"name": "upload_document"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | No | Title of the document | |
| amount | No | Amount | |
| entity | Yes | Record type the file is attached to: lead, contact, account or campaign | |
| status | No | Initial status | |
| analyze | No | Run AI text-extraction + summary synchronously after upload (default true). | |
| currency | No | Currency code (ISO 4217, e.g. EUR) | |
| doc_type | No | Type of document | |
| filename | No | Required with content_base64; optional with source_url (derived from the URL if omitted). | |
| entity_id | Yes | ID of the record | |
| mime_type | No | MIME type of the file | |
| source_url | No | URL the server fetches directly — no base64/context cost. Preferred when the file already has a stable URL. | |
| description | No | Description of the document | |
| occurred_at | No | When it happened (ISO 8601) | |
| content_base64 | No | Raw file bytes, base64-encoded. Only for tiny content (a few KB) with no reachable URL and no shell access — see create_document_upload_url for local files. |