Чати можна позначати як прочитані клієнтом або агентом за допомогою API.
➡️ Запити
Позначити як прочитане агентом:
| URL | https://api.helpcrunch.com/v1/chats/readByAgent | 
| Method | PUT | 
| Headers | Authorization: Bearer <your_api_key> | 
Позначити як прочитане клієнтом:
| URL | https://api.helpcrunch.com/v1/chats/readByCustomer | 
| Method | PUT | 
| Headers | Authorization: Bearer <your_api_key> | 
Дізнайтеся більше про заголовок авторизації тут.
Ви повинні вказати id чату (обов’язково) і read (обов’язково) у тілі запиту PUT.
{
    "id": 5208,
    "read": true
}- id – це ідентифікатор чату, наданий HelpCrunch.
- read - це прапорець для позначення чату як прочитаного.
✅ Відповідь на успішний запит
Якщо ваш запит пройшов успішно, ви отримаєте код статусу успішного виконання 200 OK разом із наведеним нижче тілом відповіді.
{
  "id": 542335,
  "closedBy": "string",
  "lastCustomerMessageAt": "1603885746",
  "status": "new",
  "closedAt": "1603885746",
  "rating": "perfect",
  "createdAt": "1603885746",
  "lastMessageAt": "1603885746",
  "createdWith": "string",
  "snoozedUntil": "1603885746",
  "lastMessageText": "string",
  "lastMessageId": 542335,
  "applicationId": 542335,
  "readByAgent": true,
  "readByCustomer": true.
  "lastCommunicatedAgentId": 542335,
  "agents": [
    {
      "id": 542335,
      "name": "string",
      "email": "string",
      "role": "string"
    }
  ],
  "customer": {
    "id": 542335,
    "name": "string",
    "email": "string",
    "userId": "string"
  },
  "assignee": {
    "id": 542335,
    "name": "string",
    "email": "string",
    "role": "string"
  },
  "department": {
    "id": 542335,
    "name": "string"
  }
}Ви можете отримати деталі по кожному полю обʼєкту чату у статті Модель даних чату.
🛑 Відповіді з помилками
Ви можете отримати один із наведених нижче кодів статусу помилки та відповіді. Детальніше про коди помилок ви можете прочитати за посиланням.
401 Unauthorized
{
  "errors": [
    {
      "code": "invalid_request",
      "message": "Invalid request"
    },
    {
      "code": "unauthorized",
      "message": "Unauthorized"
    }
  ]
}404 Not Found
{
    "errors": [
        {
            "code": "not_fount",
            "message": "Chat for ID "%s" was not found"
        }
    ]
}429 Too Many Requests
{
  "errors": [
    {
      "code": "invalid_request",
      "message": "Invalid request"
    },
    {
      "code": "too_many_requests",
      "message": "Too many requests"
    }
  ]
}