Skip to content

Send Message (Admin)

Send a message from an admin to a store in a claimed session.

Endpoint

POST /v1/chat/admin/message/

Authentication

Required: Admin authentication token

Authorization: Token <admin_token>

Request Body

{
  "session_id": 1,
  "content": "Hello, how can I help you?",
  "attachment_url": "https://example.com/file.pdf",
  "attachment_type": "application/pdf"
}

Parameters

Field Type Required Description
session_id integer Yes ID of the session to send message to
content string Conditional Message text (required if no attachment)
attachment_url string Conditional URL of attachment (required if no content)
attachment_type string No MIME type of attachment (auto-detected if not provided)

Note: Either content or attachment_url must be provided.

Response

Success (200 OK)

Returns the session and created message.

{
  "session": {
    "id": 1,
    "store_id": 5,
    "admin_id": 2,
    "status": "claimed",
    "last_message_at": "2025-12-16T10:35:00Z",
    "created": "2025-12-16T10:00:00Z",
    "updated": "2025-12-16T10:35:00Z"
  },
  "message": {
    "id": 124,
    "session_id": 1,
    "sender_type": "admin",
    "sender_id": 2,
    "content": "Hello, how can I help you?",
    "attachment_url": "",
    "attachment_type": "",
    "status": "sent",
    "created": "2025-12-16T10:35:00Z",
    "updated": "2025-12-16T10:35:00Z"
  }
}

Error Responses

Missing Session ID (400)

{
  "error": "session_id is required"
}

Missing Content or Attachment (400)

{
  "error": "Message content or attachment is required"
}

Session Not Found or Not Assigned (403)

{
  "error": "Session not found or not assigned"
}

Session Is Closed (400)

{
  "error": "Session is closed"
}

Unauthorized (401)

{
  "error": "Unauthorized"
}

Example Request

curl -X POST "https://api.luxmart.site/v1/chat/admin/message/" \
  -H "Authorization: Token your_admin_token" \
  -H "Content-Type: application/json" \
  -d '{
    "session_id": 1,
    "content": "Hello, how can I help you?"
  }'

Notes

  • Admin must have claimed the session (session must be assigned to them)
  • Cannot send messages to closed sessions
  • Message is sent via WebSocket to the store if they are online
  • Message status is set to "delivered" if store is online, otherwise "sent"
  • Use the Upload Attachment endpoint to upload files first
  • Session's last_message_at is updated when message is sent