Skip to content

Send Read ​

POST /read

Mark the messages of a chat as read. The other person sees them as read, just like when you open the chat in the Telegram app. Mark them up to one message with messageId, or every message when you leave it out.

Endpoint Details ​

  • Base URL: https://api-zate.azickri.com
  • Headers: id, session-id, and Content-Type: application/json
  • Requirement: the session must be connected (isConnected: true)

Headers ​

HeaderTypeRequiredDescription
idstringYesid from Create Session.
session-idstringYessessionId from Create Session.

Request Body ​

FieldTypeRequiredDescription
groupstringOne of*Group ID or a public group's username.
channelstringOne of*Channel ID or a public channel's username.
userstringOne of*Telegram user ID, for example the chatId of a webhook event.
usernamestringOne of*Recipient username, with or without @, or a t.me link.
phonestringOne of*Phone number in international format. Only works if the person's privacy allows it.
messageIdstringNoMark messages as read up to this one (a number). Left out, every message of the chat.

* Fill in one of group, channel, user, username, or phone. The priority order is the same as Send Message.

Example Request ​

bash
curl -X POST "https://api-zate.azickri.com/read" \
  -H "id: YOUR_ID" \
  -H "session-id: YOUR_SESSION_ID" \
  -H "Content-Type: application/json" \
  -d '{"user":"111222333"}'
javascript
import axios from 'axios';

const response = await axios.post(
  'https://api-zate.azickri.com/read',
  {
    user: '111222333',
  },
  {
    headers: {
      'id': 'YOUR_ID',
      'session-id': 'YOUR_SESSION_ID',
    },
  },
);

console.log(response.data);
javascript
const response = await fetch('https://api-zate.azickri.com/read', {
  method: 'POST',
  headers: {
    'id': 'YOUR_ID',
    'session-id': 'YOUR_SESSION_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    user: '111222333',
  }),
});

const data = await response.json();
console.log(data);

Response ​

json
{
  "id": "68b3f0a2c1d4e5f6a7b8c9d0"
}
json
// No receiver
{
  "statusCode": 400,
  "message": "invalid phone, username, user, group or channel"
}

// messageId is not a number
{
  "statusCode": 400,
  "message": "messageId must be a number string"
}

// Username or ID not found
{
  "statusCode": 400,
  "message": "chat not found"
}
json
{
  "statusCode": 404,
  "message": "session not found"
}
json
{
  "statusCode": 500,
  "message": "session not connected"
}
FieldTypeDescription
idstringSession ID.

Read, Type, Reply ​

When a message comes in through the webhook, mark it as read, show "typing...", then send the reply:

javascript
const BASE_URL = 'https://api-zate.azickri.com';
const headers = {
  'id': 'YOUR_ID',
  'session-id': 'YOUR_SESSION_ID',
  'Content-Type': 'application/json',
};
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

async function reply(chatId, messageId, text) {
  await fetch(`${BASE_URL}/read`, {
    method: 'POST',
    headers,
    body: JSON.stringify({ user: chatId, messageId }),
  });

  await fetch(`${BASE_URL}/typing`, {
    method: 'POST',
    headers,
    body: JSON.stringify({ user: chatId, type: 'text' }),
  });

  await sleep(3000);

  await fetch(`${BASE_URL}/message`, {
    method: 'POST',
    headers,
    body: JSON.stringify({ user: chatId, type: 'text', text }),
  });
}

When the person reads your messages, a message.read webhook event with byMe: false comes in.