Attach a file to a ticket, project task, client, contact or asset
Creates a document from an https URL or from base64 and associates it with one entity. One file per call. The server downloads URL sources itself, only from hosts on the workspace's allowed download hosts list (and only public addresses); the list applies to every caller of this endpoint, not only MCP. Validation (size, MIME type allowlist), storage, the document row, the association, previews and DOCUMENT_ASSOCIATED events run in one shared upload core; ticket attachments also write a ticket activity entry. Requires document:create and <entity>:update. Errors: 400 invalid source, host not allowed (code FETCH_HOST_NOT_ALLOWED; nothing is fetched and no document is created), unsafe or unreachable URL (a remote error status is reported in the message, never as our status), oversize, or disallowed type; 403 permission denied; 404 entity not found.
UUID of the ticket, project task, client, contact or asset.
sourceoneOfRequired
Where the file bytes come from: an https URL (preferred) or base64.
oneOf (option 1)object
typestringRequired
Enum: url
urlstringRequired
https URL the server downloads the file from. The host must be on the workspace's allowed download hosts (managed by tenant admins under Settings > MCP Server; the ChatGPT file host is built in), otherwise the call fails with 400 FETCH_HOST_NOT_ALLOWED. Port 443 only, public addresses only, at most 3 redirects (each re-checked against the allowlist), size capped at the storage limit. Signed URLs are used once and never logged.
oneOf (option 2)object
typestringRequired
Enum: base64
contentstringRequired
Standard base64 of the file bytes. Only for small content the caller wrote itself; requires file_name.
file_namestring
File name including extension. Required for base64. For url, defaults to the Content-Disposition name, then the last URL path segment.
mime_typestring
Declared MIME type. The server sniffs the bytes and a recognised type overrides this; the storage allowlist is applied to the resolved type.
Response body
Success response 201 · schema AttachedDocument
dataobjectRequired
The created document row (document_id, document_name, mime_type, file_size, folder_path, ...).
Response codes
201
Document created and attached.
400
Validation failure: bad source, URL host not on the workspace allowlist (code FETCH_HOST_NOT_ALLOWED), unsafe URL, fetch failure, size or type not allowed.
401
API key missing/invalid.
403
Permission denied (document:create or the entity update permission).