Minimal chain: getMe (verify token) → getUpdates (get chat_id) → sendMessage (send). Read the token from an environment variable; never hardcode it.
Overview
This is the developer main path on any desktop OS. Base URL:
https://call.mp.net/bot/bot{MPCHAT_BOT_TOKEN}/{methodName}
Store credentials in environment variables or a .env that is git-ignored:
MPCHAT_BOT_TOKEN=your_mpbot_token_here MPCHAT_CHAT_ID=your_chat_id_here
1. getMe (verify the token)
curl -s "https://call.mp.net/bot/bot${MPCHAT_BOT_TOKEN}/getMe"
const token = process.env.MPCHAT_BOT_TOKEN;
const res = await fetch(`https://call.mp.net/bot/bot${token}/getMe`);
const data = await res.json();
if (!data.ok) throw new Error(`${data.error_code}: ${data.description}`);
console.log(data.result); // { id, is_bot, username }
A 401 means the token is invalid or revoked.
2. getUpdates (get a chat_id)
curl -s -X POST "https://call.mp.net/bot/bot${MPCHAT_BOT_TOKEN}/getUpdates" \
-H "Content-Type: application/json" \
-d '{"timeout":30,"limit":50,"allowed_updates":["message"]}'
const res = await fetch(`https://call.mp.net/bot/bot${token}/getUpdates`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ timeout: 30, limit: 50, allowed_updates: ["message"] }),
});
const data = await res.json();
if (!data.ok) throw new Error(`${data.error_code}: ${data.description}`);
const chatId = data.result?.find((u) => u.message)?.message?.chat?.id;
A successful response consumes that batch of updates; for a continuous loop, pass offset = last update_id + 1. A 409 means a webhook is enabled.
3. sendMessage (send your first message)
curl -s -X POST "https://call.mp.net/bot/bot${MPCHAT_BOT_TOKEN}/sendMessage" \
-H "Content-Type: application/json" \
-d "{\"chat_id\":\"${MPCHAT_CHAT_ID}\",\"text\":\"Hello from mpbot\"}"
const res = await fetch(`https://call.mp.net/bot/bot${token}/sendMessage`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ chat_id: process.env.MPCHAT_CHAT_ID, text: "Hello from mpbot" }),
});
const data = await res.json();
if (!data.ok) throw new Error(`${data.error_code}: ${data.description}`);
Pre-flight checklist
Token read from an environment variable, never hardcoded or committed.
IDs follow the documented type rules (safe integer or decimal string).
POST bodies are valid JSON with
Content-Type: application/json.Media methods use a public URL or multipart (no
file_idreuse).
Related
Default rate limit is 30 requests/second per token; exceeding it returns 429. Add exponential backoff before going to production.
