English
English
Appearance
English
English
Appearance
/public/account/telegram/connect/{accountId}Restore a Telegram account that has lost its connection, for example because the user ended its session under Settings → Devices in Telegram. Create a new session, have the user scan the QR code with the same Telegram account (and send the Two-Step Verification password if it's asked for), then send the new token here.
Authorization: Basic Base64(AccessKey:SecretKey))| Parameter | Type | Required | Description |
|---|---|---|---|
accountId | string | Yes | The unique ID of the account. |
| Field | Type | Required | Description |
|---|---|---|---|
token | string | Yes | The new session token from Create Session Telegram, after Get Session Telegram reports isConnected: true. |
curl -X POST "https://api.repliz.com/public/account/telegram/connect/680affa5ce12f2f72916f67e" \
-H "Authorization: Basic $(echo -n 'YOUR_ACCESS_KEY:YOUR_SECRET_KEY' | base64)" \
-H "Content-Type: application/json" \
-d '{"token":"SESSION_TOKEN"}'import axios from 'axios';
const accountId = '680affa5ce12f2f72916f67e';
const response = await axios.post(
`https://api.repliz.com/public/account/telegram/connect/${accountId}`,
{
token: 'SESSION_TOKEN',
},
{
auth: {
username: 'YOUR_ACCESS_KEY',
password: 'YOUR_SECRET_KEY',
},
},
);
console.log(response.data);const credentials = btoa('YOUR_ACCESS_KEY:YOUR_SECRET_KEY');
const accountId = '680affa5ce12f2f72916f67e';
const response = await fetch(
`https://api.repliz.com/public/account/telegram/connect/${accountId}`,
{
method: 'POST',
headers: {
Authorization: `Basic ${credentials}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
token: 'SESSION_TOKEN',
}),
},
);
const data = await response.json();
console.log(data);// No content returned on success{
"code": 400,
"message": "incorrect generatedId to reconnect"
}{
"code": 403,
"message": "invalid status session"
}// Account Not Found
{
"code": 404,
"message": "account not found"
}
// Session Not Found
{
"code": 404,
"message": "session not found"
}{
"code": 401,
"message": "unauthorized"
}400 means the QR code was scanned with a different Telegram account than the one this account belongs to. Create a new session and scan with the original account. To add a different account, use Connect Telegram instead.403 invalid status session means the login isn't complete yet: the QR code hasn't been scanned, or the Two-Step Verification password hasn't been sent. Keep polling Get Session Telegram until isConnected is true.404 session not found means the session expired before the call. Create a new session and scan again.