English
Send Read
POST/readMark 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, andContent-Type: application/json - Requirement: the session must be connected (
isConnected: true)
Headers
| Header | Type | Required | Description |
|---|---|---|---|
id | string | Yes | id from Create Session. |
session-id | string | Yes | sessionId from Create Session. |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
group | string | One of* | Group ID or a public group's username. |
channel | string | One of* | Channel ID or a public channel's username. |
user | string | One of* | Telegram user ID, for example the chatId of a webhook event. |
username | string | One of* | Recipient username, with or without @, or a t.me link. |
phone | string | One of* | Phone number in international format. Only works if the person's privacy allows it. |
messageId | string | No | Mark 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"
}| Field | Type | Description |
|---|---|---|
id | string | Session 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.