Attachments API
The Attachments API manages file attachments associated with conversations and tickets.
Attachment Object
{
id: string; // UUID
conversation_id: string; // UUID of parent conversation
organization_id: string; // UUID of the organization
filename: string; // Original filename
content_type: string; // MIME type (e.g., 'image/png')
size: number; // File size in bytes
storage_path: string; // Internal storage path
created_at: string; // ISO timestamp
deleted_at?: string; // Soft delete timestamp
}
List Attachments
Retrieve all attachments for a conversation.
Procedure: attachments.list
Authentication: Required
Input:
{
conversationId: string; // UUID of the conversation
}
Example:
curl -X GET "https://your-domain.com/api/trpc/attachments.list?input=%7B%22conversationId%22:%22conversation-uuid%22%7D" \
-H "Cookie: your-session-cookie"
Response:
{
"result": {
"data": {
"json": [
{
"id": "uuid",
"conversation_id": "conversation-uuid",
"filename": "screenshot.png",
"content_type": "image/png",
"size": 245678,
"created_at": "2024-01-15T10:30:00.000Z"
},
{
"id": "uuid-2",
"conversation_id": "conversation-uuid",
"filename": "document.pdf",
"content_type": "application/pdf",
"size": 1024000,
"created_at": "2024-01-15T10:31:00.000Z"
}
]
}
}
}
Get Attachment
Retrieve a single attachment by ID.
Procedure: attachments.get
Authentication: Required
Input:
{
id: string; // Attachment UUID
}
Example:
curl -X GET "https://your-domain.com/api/trpc/attachments.get?input=%7B%22id%22:%22attachment-uuid%22%7D" \
-H "Cookie: your-session-cookie"
Response:
{
"result": {
"data": {
"json": {
"id": "uuid",
"conversation_id": "conversation-uuid",
"filename": "screenshot.png",
"content_type": "image/png",
"size": 245678,
"storage_path": "attachments/org-uuid/file-uuid",
"created_at": "2024-01-15T10:30:00.000Z"
}
}
}
}
Delete Attachment
Soft delete an attachment. Only the attachment owner or admins can delete.
Procedure: attachments.delete
Authentication: Required
Input:
{
id: string; // Attachment UUID
}
Example:
curl -X POST "https://your-domain.com/api/trpc/attachments.delete" \
-H "Content-Type: application/json" \
-H "Cookie: your-session-cookie" \
-d '{"json":{"id":"attachment-uuid"}}'
Response:
{
"result": {
"data": {
"json": {
"success": true
}
}
}
}
Upload Attachment (REST)
File uploads use a REST endpoint, not tRPC.
Endpoint: POST /api/upload
Authentication: Required (session cookie)
Request:
- Content-Type:
multipart/form-data - Body: Form data with
filefield
Example:
curl -X POST "https://your-domain.com/api/upload" \
-H "Cookie: your-session-cookie" \
-F "file=@/path/to/file.pdf"
Response:
{
"id": "attachment-uuid",
"filename": "file.pdf",
"content_type": "application/pdf",
"size": 102400,
"url": "/api/attachments/attachment-uuid/download"
}
Download Attachment (REST)
Download an attachment file.
Endpoint: GET /api/attachments/[id]/download
Authentication: Required (session cookie)
Example:
curl -X GET "https://your-domain.com/api/attachments/attachment-uuid/download" \
-H "Cookie: your-session-cookie" \
-o downloaded-file.pdf
Response: Binary file data with appropriate Content-Type and Content-Disposition headers.
Supported File Types
| Category | Types |
|---|---|
| Images | PNG, JPEG, GIF, WebP |
| Documents | PDF, DOC, DOCX, XLS, XLSX, TXT |
| Archives | ZIP, RAR |
| Other | CSV, JSON |
File Size Limits
| Type | Max Size |
|---|---|
| Images | 10 MB |
| Documents | 25 MB |
| All files | 25 MB |
Error Codes
| Code | Description |
|---|---|
NOT_FOUND | Attachment not found |
FORBIDDEN | User doesn't have permission |
ATTACHMENT_TOO_LARGE | File exceeds size limit |
INVALID_ATTACHMENT_TYPE | File type not allowed |