Help Center Chats and Messages

Chats and Messages

API methods for fetching ChatHub conversation metadata, managing statuses, and reviewing historical message chains.

URL: https://chatapi.smsbat.com


1. Get All Chats

Fetch a list of chats with dynamic filtering and pagination.

Request

  • Method: GET
  • URL: /api/chat/chats
  • Authorization: Bearer Token (Required)

Query Parameters

ParameterTypeDescription
pageintegerPage number. Default: 1
per_pageintegerItems per page. Default: 20
searchstringText search (e.g., name, phone)
sourceintegerChat Source Enum (e.g. 1 for Viber Bot, 2 for Telegram)
datedatetimeFetches chats between two dates (requires two identical parameter keys in the URL). Ex: ?date=2026-01-28&date=2026-01-29
tg_user_idintegerTelegram User ID
phonestringPhone Number
statusinteger0 = New, 1 = Open, 2 = Waiting, 3 = OnPause, 4 = Closed
organizationIdintegerNarrow by organization
operatorIdintegerNarrow by assigned operator

Response (200 OK)

{
  "total": 124,
  "items": [
    {
       "id": 123,
       "theme": "Support Ticket #491",
       "operator": {
           "id": 21,
           "name": "Jane",
           "photo": "url_to_photo.png"
       },
       "chatStatus": 1,
       "countUnread": 3
    }
  ]
}

2. Change Chat Status

Updates the assigned status of a specific chat session.

Request

  • Method: PUT
  • URL: /api/chat/status
  • Authorization: Bearer Token
  • Headers: Content-Type: application/json

Body:

{
  "id": 123,
  "status": 1
}

Status Enum Values:

  • 0: New (Newly generated)
  • 1: Open (Actively handled by operator)
  • 2: Waiting (Awaiting user reply)
  • 3: OnPause (Paused state)
  • 4: Closed (Archived)

3. Delete a Chat

Permanently deletes a chat via its unique ID.

Request

  • Method: DELETE
  • URL: /api/chat/chats/{id}
  • Authorization: Bearer Token

Response (200 OK) Returns an HTTP 200 to confirm successful deletion. Body is typically empty or strictly "OK".


4. Retrieve Chat Messages

Dumps all messages historically sent and received within a particular chat.

Request

  • Method: GET
  • URL: /api/chat/chats/{chatId}/messages
  • Authorization: Bearer Token

Response (200 OK)

[
  {
        "id": 1,
        "chatId": 123,
        "message": "Hello, how can I help?",
        "phone": "380936670003",
        "author": 0,
        "status": 3,
        "date": "2025-04-01T09:46:24.687Z",
        "operator": {
          "id": 21,
          "name": "Jane"
        },
        "messageType": 0
  }
]

Authors:

  • 0: Operator
  • 1: Client
  • 2: System Bot
  • 3: Viber Business Account

Message Types:

  • 0: Text
  • 1: Photo
  • 2: File

5. Update Messages Status

Marks a message (or multiple messages) inside an active chat with new delivery statuses.

Request

  • Method: PUT
  • URL: /api/chat/messages/status
  • Authorization: Bearer Token
  • Headers: Content-Type: application/json

Body:

{
  "status": 3,
  "messageIds": [1, 2, 3]
}

(Status 3 marks the sent message IDs as “Read”)