How to Attach Files to Tickets via API
This article explains how to attach files to tickets using the LiveAgent API. File attachments can be included in ticket messages and notes created through the API.
Overview
Attaching files to tickets via API is a two-step process:
- Upload the file to the system using the file upload endpoint
- Reference the uploaded file when creating a ticket message or note
Step 1: Upload the File
First, you need to upload your file to the LiveAgent system. You can use either of the following endpoints:
Option A: API v1 File Upload
Use the POST /api/files endpoint to upload a file. For detailed information, see the Complete API reference for file upload.
Option B: API v3 File Upload
Alternatively, you can use the POST /files endpoint in API v3. For detailed information, see the API v3 documentation for file upload.
Important: Both endpoints work for uploading files, but you must use API v1 for creating ticket messages with attachments (see Step 2 below).
Step 2: Create a Ticket Message with the File Attachment
After uploading the file, the API response will contain a fileid parameter. This is a unique identifier generated by the system for your uploaded file.
Use this fileid in the attachments parameter when creating a new ticket message or note via the POST /api/conversations/[conversationid]/messages endpoint in API v1.
For detailed information on creating messages with attachments, see the Complete API reference for creating conversation messages.
Important Notes
- File uploads can be performed using either API v1 or API v3
- Ticket messages with attachments must be created using API v1 only
- Always use the
fileidreturned from the file upload response when attaching files to messages - The
conversationidparameter is required when creating messages with attachments
Summary
To attach files to tickets via API:
- Upload your file using POST /api/files (API v1) or POST /files (API v3)
- Extract the
fileidfrom the response - Create a ticket message using POST /api/conversations/[conversationid]/messages (API v1) with the
fileidin the attachments parameter