Upload Chat Attachment
Upload a file attachment for use in chat messages. Supports images, documents, and other file types.
Endpoint
Authentication
Required: Admin or Store authentication token
Request Body
The request must be sent as multipart/form-data:
| Field | Type | Required | Description |
|---|---|---|---|
file |
file | Yes | The file to upload |
session_id |
string | No | Optional session ID for organizing files |
Supported File Types
- Images: JPG, JPEG, PNG, GIF, HEIC, HEIF
- Documents: PDF, DOC, DOCX, XLS, XLSX
Response
Success (200 OK)
Response Fields
| Field | Type | Description |
|---|---|---|
url |
string | Public URL of the uploaded file |
type |
string | MIME type of the file (auto-detected) |
Error Responses
Missing File (400)
Unsupported File Type (400)
Unauthorized (401)
Example Request
curl -X POST "https://api.luxmart.site/v1/chat/upload/" \
-H "Authorization: Token your_token" \
-F "file=@/path/to/image.jpg" \
-F "session_id=1"
Using JavaScript (FormData)
const formData = new FormData();
formData.append("file", fileInput.files[0]);
formData.append("session_id", "1");
fetch("https://api.luxmart.site/v1/chat/upload/", {
method: "POST",
headers: {
"Authorization": "Token your_token"
},
body: formData
})
.then(response => response.json())
.then(data => {
console.log("File URL:", data.url);
console.log("File Type:", data.type);
});
Notes
- Files are uploaded to S3 storage
- File organization:
- If
session_idis provided:chat/session-{session_id}/ - If no
session_id:- For stores:
chat/store-{store_id}/ - For admins:
chat/admin-{admin_id}/ - Otherwise:
chat/general/
- For stores:
- MIME type is auto-detected from file extension
- The returned URL can be used in the
attachment_urlfield when sending messages - File size limits depend on server configuration