Skip to content

Quick Start

Create a Bot

  1. Find BotFather in the SafeW app
  2. Send the /newbot command
  3. Follow the prompts to set the bot name and username
  4. Obtain your Bot Token

Get Your Token

After successful creation, BotFather will return a Token. Keep this Token safe — it is the sole credential for calling the API.

Security Notice

Never expose your Token publicly or commit it to version control. If the Token is compromised, regenerate it immediately via BotFather.

Send Your First Message

Use the sendMessage method to send a text message:

bash
curl -X POST "https://api.example.com/bot{YOUR_TOKEN}/sendmessage" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": 123456789,
    "text": "Hello, World!"
  }'

Success response:

json
{
  "ok": true,
  "result": {
    "message_id": 1,
    "chat": {
      "id": 123456789,
      "type": "private"
    },
    "text": "Hello, World!"
  }
}

Receive Messages

There are two ways to receive message updates:

Long Polling (getUpdates)

bash
curl "https://api.example.com/bot{YOUR_TOKEN}/getupdates"

Webhook

After setting a Webhook URL, the server will push updates to your specified URL:

bash
curl -X POST "https://api.example.com/bot{YOUR_TOKEN}/setwebhook" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://your-server.com/webhook"
  }'

Next Steps