create_document_upload_url
Step 1 of the recommended flow for a LOCAL file when you (the calling agent) have shell/code-execution access (Bash, a script, curl, etc.): reserves a document record + a one-time signed upload URL, so the actual file bytes travel via a plain HTTP PUT from your shell — never through your own context/output tokens, regardless of file size.
Required: filename. Optional: mime_type, doc_type (default 'file'), title (default filename), description, amount, currency, status, occurred_at.
WHICH OF THE TWO WAYS: pass entity ('lead'|'contact'|'account'|'campaign') AND entity_id for a CRM document — an offer for a lead, an invoice for an account. Pass NEITHER for anything else: a screenshot for a SupportAIze ticket, a spreadsheet you are handing to another system, a file that has no CRM record. Both or neither; one alone is rejected, because a half-filed document appears in no list at all. Find the unfiled ones again with list_documents({unfiled:true}), and file one later with update_document({document_id, entity, entity_id}) once you know where it belongs.
THE STABLE REFERENCE IS THE document_id, not a URL. get_document_link mints a fresh signed URL on demand (default 1 h, max 24 h) and checks the tenant every time. So hand another system the document_id, or have it fetch the bytes once at attach time — never store the signed URL, it expires and then points at nothing while looking like a working attachment.
Optional provenance, for anything imported from somewhere else: source (e.g. 'beeper'), external_id (the id at that source) and source_meta (an object: network, chat_id, chat_title, sender, sender_id, sent_at, message_id — never credentials). Passing source + external_id also makes the call IDEMPOTENT: a second call for the same one returns the document already stored, with duplicate:true and NO upload_url, instead of a second record. That is the only place this can be enforced, because only the database sees both attempts.
Returns { document_id, upload_url, storage_path } — or { document_id, duplicate: true } when it was already stored. Next: from your shell, PUT the raw file to upload_url — e.g. curl -T /path/to/file "$upload_url". No CallPilotAI credential is needed for that PUT; the URL is self-authorizing and expires in ~2 hours. Then call finalize_document_upload with document_id to confirm the upload landed, backfill its size/type, and run AI analysis. If you never complete the PUT, delete_document the reserved document_id to avoid leaving an empty record behind.
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": {
"filename": "<filename>"
},
"name": "create_document_upload_url"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | No | Title of the document | |
| amount | No | Amount | |
| entity | No | Record type for a CRM document: lead, contact, account or campaign; pass with entity_id or omit both | |
| source | No | Source system the file was imported from, e.g. 'beeper'; with external_id makes the call idempotent | |
| status | No | Initial status | |
| currency | No | Currency code (ISO 4217, e.g. EUR) | |
| doc_type | No | Type of document (default 'file') | |
| filename | Yes | File name | |
| entity_id | No | ID of the record | |
| mime_type | No | MIME type of the file | |
| description | No | Description of the document | |
| external_id | No | ID of the external | |
| occurred_at | No | When it happened (ISO 8601) | |
| source_meta | No | Provenance details (network, chat_id, chat_title, sender, sender_id, sent_at, message_id), never credentials |