Back to Articles How-to

How to Monitor Your API Uptime with Telegram Alerts

Julio Andres April 12, 2026 7 min read Uptime · Telegram · Monitoring

Your API goes down at 2 AM. Your users start hitting errors. Some of them tweet about it. You find out the next morning when you check Slack and see a thread full of complaints. By then the damage is done — frustrated users, lost transactions, and a reputation hit that takes days to recover from.

The fix is simple: monitor your endpoints and get a Telegram message the moment something stops responding. Your phone buzzes, you SSH in, and you fix it before most users even notice. Here's how to set that up, from a DIY script to a managed solution.

Option 1: A Custom Monitoring Script (The DIY Way)

The simplest approach is a script that pings your API on a schedule and alerts you when it gets a non-200 response or times out. Here's a Python version using the Telegram Bot API directly:

Python — DIY uptime monitor
import time
import requests

API_URL = "https://api.yourapp.com/health"
CHECK_INTERVAL = 60  # seconds
TELEGRAM_TOKEN = "123456:ABC-DEF..."
TELEGRAM_CHAT_ID = "987654321"

def send_telegram(message):
    requests.post(
        f"https://api.telegram.org/bot{TELEGRAM_TOKEN}/sendMessage",
        json={"chat_id": TELEGRAM_CHAT_ID, "text": message},
    )

was_down = False

while True:
    try:
        r = requests.get(API_URL, timeout=10)
        if r.status_code != 200:
            if not was_down:
                send_telegram(f"API is DOWN — status {r.status_code}")
                was_down = True
        else:
            if was_down:
                send_telegram("API is back UP")
                was_down = False
    except requests.RequestException:
        if not was_down:
            send_telegram("API is DOWN — connection failed")
            was_down = True

    time.sleep(CHECK_INTERVAL)

This works for a single endpoint. But once you need to monitor more than one URL, the problems stack up:

For monitoring one personal project, a cron script is fine. For production services where downtime costs money, you need something more reliable.

Option 2: Built-In Health Checks (The Managed Way)

NotificationsBot has a built-in health check feature. You add a URL in the dashboard, and the service polls it every 60 seconds from an external server. When the status changes — up to down, or down to up — it sends an alert to everyone subscribed to that channel, on whatever platform they use.

How it works

The health checker runs on a separate server from your application. It makes an HTTP request to your URL every minute. If the response is not 2xx, or if the connection times out, it marks the URL as down and notifies your subscribers. When the URL starts responding again, it sends a recovery alert. You get both the "it's broken" and the "it's fixed" notifications automatically.

No scripts to write, no bots to create, no servers to maintain for the monitor itself. You just add the URL and choose who gets alerted.

Setting Up Uptime Monitoring with NotificationsBot

That's it. The service starts polling immediately. When your API goes down, your phone buzzes. When it comes back up, you get a second message confirming it's recovered.

What to Monitor

Not every endpoint needs uptime monitoring. Focus on the ones where downtime has real impact:

Good to know

A good health check endpoint doesn't just return 200 — it verifies that the service can actually do work. Check that the database is reachable, that required services are connected, and that the app isn't in a degraded state. A health check that always returns 200 is worse than no health check at all, because it gives you false confidence.

Building a Good Health Check Endpoint

If your API doesn't have a health check endpoint yet, here are quick examples that actually verify your service is working:

Python — FastAPI
from fastapi import FastAPI
from database import get_connection

app = FastAPI()

@app.get("/health")
async def health_check():
    try:
        conn = await get_connection()
        await conn.execute("SELECT 1")
        return {"status": "ok"}
    except Exception as e:
        return JSONResponse(
            status_code=503,
            content={"status": "unhealthy", "error": str(e)},
        )
Node.js — Express
const express = require("express");
const db = require("./database");

const app = express();

app.get("/health", async (req, res) => {
  try {
    await db.query("SELECT 1");
    res.json({ status: "ok" });
  } catch (err) {
    res.status(503).json({
      status: "unhealthy",
      error: err.message,
    });
  }
});

Combining Uptime Alerts with Event Notifications

Health checks catch when your service is completely down. But what about errors that happen while the service is still running? A payment endpoint might return 200 to the health checker but fail silently on specific requests.

The best setup combines both:

Python — Alert on caught errors
import os
import requests

API_KEY = os.environ["NOTIFICATIONSBOT_API_KEY"]

def notify_error(title: str, message: str):
    requests.post(
        "https://api.notificationsbot.com/event",
        headers={"Authorization": f"Bearer {API_KEY}"},
        json={
            "channel": "error-alerts",
            "title": title,
            "message": message,
        },
        timeout=5,
    )

# In your payment handler:
try:
    charge = stripe.Charge.create(amount=amount, ...)
except stripe.error.CardError as e:
    notify_error(
        "Payment failed",
        f"User {user_id} — {e.user_message}",
    )

Now you have two layers of monitoring: the health checker catches total outages, and your code catches business logic failures. Both go to the same notification system, reaching the right people on the right platform.

DIY Monitoring vs NotificationsBot

Bonus: Alert the Right People at the Right Time

The most effective uptime monitoring setup separates who gets notified based on severity. A common pattern:

Your health check sends to uptime-alerts. The on-call engineer gets woken up and fixes it. Then they manually send an update to team-updates with context on what happened. No one gets paged unnecessarily, and the team still stays informed.

Know When Your API Goes Down — Before Your Users Do

Set up a free account, add your API URL, and start getting Telegram alerts within minutes. No scripts, no bots, no maintenance.

Start for free

Related Articles