⚡ AutoHub API

Telegram & WhatsApp Automation — REST API Reference
v1
Base URL: https://tgautomation.org

Authentication

Every API request must include your API key. There are three accepted methods — use whichever suits your client.
MethodHow to sendExample
X-API-Key header RecommendedHTTP headerX-API-Key: your_api_key_here
Authorization headerBearer tokenAuthorization: Bearer your_api_key_here
Query parameterURL param?api_key=your_api_key_here

API keys are issued by an admin. Each key is tied to a specific user account and inherits that account's permissions.

Never share your API key. If compromised, ask an admin to revoke and re-issue it.

Quick Start

# 1. Verify your key and see available endpoints
curl -s "https://tgautomation.org/api/v1/system-info" \
  -H "X-API-Key: YOUR_KEY" | python -m json.tool

# 2. List your accounts
curl -s "https://tgautomation.org/api/v1/accounts" \
  -H "X-API-Key: YOUR_KEY"

# 3. Send a broadcast NOW
curl -s -X POST "https://tgautomation.org/api/v1/broadcast" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "account_id": "YOUR_ACCOUNT_ID",
    "target_keys": ["@channel1", "@channel2"],
    "message": "Hello from the API!",
    "schedule_type": "now"
  }'

All Endpoints

V1 Endpoints

GET /api/v1/system-info

Returns system information and a summary of all available endpoints.

curl "{base}/api/v1/system-info" -H "X-API-Key: KEY"

GET /api/v1/accounts

Returns all Telegram and WhatsApp accounts owned by the API key's user.

curl "{base}/api/v1/accounts" -H "X-API-Key: KEY"

# Response
{
  "success": true,
  "accounts": [
    {
      "id": "abc123",
      "name": "My Account",
      "phone": "+1234567890",
      "platform": "telegram",
      "connected": true,
      "status": "connected"
    }
  ],
  "count": 1
}

GET /api/v1/groups

Returns all groups, channels and contacts available to the user. Supports optional filtering.

Query ParamValuesDescription
platformtelegram, whatsappFilter by platform
account_idaccount IDShow only groups scanned by this account
curl "https://tgautomation.org/api/v1/groups?platform=telegram" -H "X-API-Key: KEY"

GET /api/v1/templates

Returns all message templates owned by the user.

curl "https://tgautomation.org/api/v1/templates" -H "X-API-Key: KEY"

# Response
{
  "success": true,
  "templates": [
    {
      "id": "tpl-uuid",
      "name": "Promo Message",
      "content": "Hello! Check our latest offer..."
    }
  ],
  "count": 1
}

GET /api/v1/broadcasts

Returns all broadcast schedules owned by the user.

Query ParamValuesDescription
platformtelegram, whatsappFilter by platform
enabledtrue, falseFilter by enabled status
curl "https://tgautomation.org/api/v1/broadcasts?platform=telegram&enabled=true" -H "X-API-Key: KEY"

POST /api/v1/broadcast

Create a broadcast. Set schedule_type to now to send immediately, or interval/daily for recurring.

FieldTypeRequiredDescription
account_idstringYesID of the Telegram or WhatsApp account to send from
target_keysarrayYesArray of group/channel IDs or @usernames (max 50)
messagestringOne ofCustom message text (max 4096 chars)
template_idstringOne ofID of a saved template to use
schedule_typestringNonow (default), interval, or daily
interval_minutesintegerNoMinutes between runs (for interval type)
daily_timestringNoTime in HH:MM format (for daily type)
platformstringNoauto (default — detected from account), telegram, or whatsapp
namestringNoDisplay name for the schedule
# Send now
curl -X POST "https://tgautomation.org/api/v1/broadcast" \
  -H "X-API-Key: KEY" -H "Content-Type: application/json" \
  -d '{
    "account_id": "abc123",
    "target_keys": ["@channel1", "-1001234567890"],
    "message": "Hello from AutoHub!",
    "schedule_type": "now"
  }'

# Schedule recurring (every 2 hours)
curl -X POST "https://tgautomation.org/api/v1/broadcast" \
  -H "X-API-Key: KEY" -H "Content-Type: application/json" \
  -d '{
    "account_id": "abc123",
    "target_keys": ["@channel1"],
    "template_id": "tpl-uuid",
    "schedule_type": "interval",
    "interval_minutes": 120,
    "name": "My 2hr Campaign"
  }'

# Response
{
  "success": true,
  "schedule_id": "uuid",
  "platform": "telegram",
  "message": "Broadcast triggered for telegram."
}

GET /api/v1/broadcast/{id}

Get status and details for a specific broadcast schedule.

curl "https://tgautomation.org/api/v1/broadcast/SCHEDULE_ID" -H "X-API-Key: KEY"

POST /api/v1/broadcast/{id}/run

Trigger an existing broadcast schedule to run immediately (regardless of its scheduled time).

curl -X POST "https://tgautomation.org/api/v1/broadcast/SCHEDULE_ID/run" -H "X-API-Key: KEY"

DELETE /api/v1/broadcast/{id}

Permanently delete and cancel a broadcast schedule.

curl -X DELETE "https://tgautomation.org/api/v1/broadcast/SCHEDULE_ID" -H "X-API-Key: KEY"

Scan & Search Endpoints

These endpoints expose TG AutoHub's core scanning features — chat discovery, message search, keyword auto-reply, and group discovery — fully accessible via API key.

POST /api/v1/scan

Scan a Telegram account to discover its chats, groups, channels, and contacts. Results are stored and retrievable via GET /api/v1/scan/results.

Body FieldRequiredDescription
account_idYesTelegram account ID to scan (from /api/v1/accounts)
max_age_daysNoOnly include chats active within N days (0 = no filter)
since_tsNoUnix timestamp — only include chats active after this
curl -X POST "https://tgautomation.org/api/v1/scan" \
  -H "X-API-Key: KEY" \
  -H "Content-Type: application/json" \
  -d '{"account_id": "ACCOUNT_ID", "max_age_days": 30}'

# Response
{
  "success": true,
  "account_id": "ACCOUNT_ID",
  "channels": [ {"id": -100123, "title": "Crypto News", "members": 5000} ],
  "groups":   [ {"id": -100456, "title": "Trading Signals", "members": 200} ],
  "contacts": [ {"id": 789, "name": "John", "username": "john_doe"} ],
  "total": 87
}

GET /api/v1/scan/results

Retrieve the stored results from the last scan (dashboard scan or API scan).

Query ParamDescription
account_idFilter to results from a specific account
typeFilter by type: groups, channels, contacts (default: all)
curl "https://tgautomation.org/api/v1/scan/results?type=groups" -H "X-API-Key: KEY"

# Also supports POST with JSON body:
curl -X POST "https://tgautomation.org/api/v1/scan/results" \
  -H "X-API-Key: KEY" \
  -H "Content-Type: application/json" \
  -d '{"account_id": "ACCOUNT_ID", "type": "groups"}'

POST /api/v1/scan/messages

Search for messages matching a keyword/phrase across all chats on a Telegram account. Equivalent to the dashboard "Scan Messages" feature.

Body FieldRequiredDescription
account_idYesTelegram account ID to search with
queryYesKeyword or phrase to search for
target_typeNogroups, channels, contacts, or all (default: all)
per_chat_limitNoMax messages per chat (default: 8)
max_chatsNoMax chats to search (default: 60)
lookback_daysNoHow many days back to search (0 = unlimited)
since_tsNoUnix timestamp lower bound
until_tsNoUnix timestamp upper bound
curl -X POST "https://tgautomation.org/api/v1/scan/messages" \
  -H "X-API-Key: KEY" \
  -H "Content-Type: application/json" \
  -d '{"account_id": "ACCOUNT_ID", "query": "buy crypto", "lookback_days": 7}'

# Response
{
  "success": true,
  "account_id": "ACCOUNT_ID",
  "query": "buy crypto",
  "results": [
    {"chat_id": -100123, "chat_title": "Crypto Group", "message_id": 555,
      "text": "I want to buy crypto", "from_user": "alice", "date": 1700000000}
  ],
  "total": 23,
  "chats_searched": 60
}

POST /api/v1/scan/search-reply

Search group chats for messages containing keywords and automatically send a reply to those senders. Equivalent to the dashboard "Keyword Auto-Reply" feature.

Body FieldRequiredDescription
account_idYesTelegram account ID to use
keywordsYesComma-separated keywords to match
reply_textYesMessage to send to matched users
target_typeNogroups, channels, contacts, or all (default: all)
max_chatsNoMax chats to scan (default: 120)
per_chat_limitNoMax messages per chat (default: 120)
curl -X POST "https://tgautomation.org/api/v1/scan/search-reply" \
  -H "X-API-Key: KEY" \
  -H "Content-Type: application/json" \
  -d '{"account_id": "ACCOUNT_ID", "keywords": "buy,interested,price", "reply_text": "Hi! Check our offer at t.me/mychannel"}'

# Response
{
  "success": true,
  "account_id": "ACCOUNT_ID",
  "keywords": "buy,interested,price",
  "replied_to": 14,
  "details": [ {"user": "alice", "chat": "Trading Group", "matched_text": "what is the price?"} ]
}

POST /api/v1/scan/discover

Discover new Telegram groups and channels using AI-powered multi-source search (DuckDuckGo, Bing, TGStat, SearcheeBot). Equivalent to the dashboard "Discover Groups" feature.

Body FieldRequiredDescription
account_idYesTelegram account ID to use for discovery
keywordsNoSearch terms (e.g. "crypto trading signals")
categoryNoCategory hint (e.g. finance, tech, marketing)
min_membersNoMinimum member count filter (default: 0)
include_channelsNoInclude channels in results (default: false)
only_newNoSkip already-scanned groups (default: true)
max_resultsNoMax groups to return (default: 40)
use_tgstatNoSearch via TGStat (default: true)
use_webNoSearch via DuckDuckGo/Bing (default: true)
use_searcheeNoSearch via SearcheeBot (default: true)
curl -X POST "https://tgautomation.org/api/v1/scan/discover" \
  -H "X-API-Key: KEY" \
  -H "Content-Type: application/json" \
  -d '{"account_id": "ACCOUNT_ID", "keywords": "crypto trading", "min_members": 500, "max_results": 50}'

# Response
{
  "success": true,
  "account_id": "ACCOUNT_ID",
  "groups": [
    {"title": "Crypto Signals", "username": "cryptosignals", "members": 12000, "link": "t.me/cryptosignals", "relevance_score": 0.92}
  ],
  "total": 38
}

Profile Management Endpoints

GET /api/v1/accounts/{id}/profile

Get the full Telegram profile for an account including name, username, bio, and photo status.

curl "{base}/api/v1/accounts/ACCOUNT_ID/profile" -H "X-API-Key: KEY"

Response:

{"success": true, "ok": true, "profile": {"id": 123456, "first_name": "John", "last_name": "Doe", "username": "johndoe", "phone": "+1234567890", "about": "Bio text here", "photo": true}}

PUT /api/v1/accounts/{id}/profile

Update Telegram profile fields. All fields optional but at least one required.

Body FieldRequiredDescription
first_nameNoFirst name (1-64 chars)
last_nameNoLast name (0-64 chars, empty to clear)
aboutNoBio/about text (0-70 chars, empty to clear)
curl -X PUT "{base}/api/v1/accounts/ACCOUNT_ID/profile" \
  -H "X-API-Key: KEY" \
  -H "Content-Type: application/json" \
  -d '{"first_name": "Muhammad", "last_name": "Khan", "about": "Founder @ 2ndCall"}'

PUT /api/v1/accounts/{id}/username

Set or change the Telegram @username for an account.

Body FieldRequiredDescription
usernameYesNew username (5-32 chars, a-z/0-9/_, without @). Empty string to remove.
curl -X PUT "{base}/api/v1/accounts/ACCOUNT_ID/username" \
  -H "X-API-Key: KEY" \
  -H "Content-Type: application/json" \
  -d '{"username": "MK_2ndcall"}'

POST /api/v1/accounts/{id}/photo

Upload and set a profile photo. Accepts multipart file upload or JSON with server-side path.

Option 1: File upload

curl -X POST "{base}/api/v1/accounts/ACCOUNT_ID/photo" \
  -H "X-API-Key: KEY" \
  -F "photo=@profile.jpg"

Option 2: Server path

curl -X POST "{base}/api/v1/accounts/ACCOUNT_ID/photo" \
  -H "X-API-Key: KEY" \
  -H "Content-Type: application/json" \
  -d '{"photo_path": "/path/to/photo.jpg"}'

DELETE /api/v1/accounts/{id}/photo

Delete all profile photos for a Telegram account.

curl -X DELETE "{base}/api/v1/accounts/ACCOUNT_ID/photo" -H "X-API-Key: KEY"

Legacy Session-Compatible Endpoints

These endpoints were originally browser-session-only but now also accept API key authentication. They are fully functional with X-API-Key header or Authorization: Bearer.

GET /api/accounts

Returns raw Telegram account objects for the authenticated user. Admins see all accounts.

curl "https://tgautomation.org/api/accounts" -H "X-API-Key: KEY"

GET /api/templates   POST

List and create message templates.

# List
curl "https://tgautomation.org/api/templates" -H "X-API-Key: KEY"

# Create
curl -X POST "https://tgautomation.org/api/templates" \
  -H "X-API-Key: KEY" -H "Content-Type: application/json" \
  -d '{"name":"My Template","content":"Hello {{name}}!"}'

GET /api/schedules   POST

List and create Telegram broadcast schedules (legacy dashboard format). Prefer /api/v1/broadcast for new integrations.

curl "https://tgautomation.org/api/schedules" -H "X-API-Key: KEY"

GET /api/status

Returns a summary of connected accounts and active automations for the user.

curl "https://tgautomation.org/api/status" -H "X-API-Key: KEY"

Error Responses

HTTP StatusErrorMeaning
401{"error":"unauthorized"}Missing or invalid API key
401{"error":"Invalid or missing API key"}API key not found or expired
403{"error":"forbidden"}Authenticated but not authorized (e.g., accessing another user's data)
400{"error":"..."}Bad request — missing or invalid parameter
404{"error":"not found"}Resource does not exist
500{"error":"..."}Internal server error

Limits

LimitValue
Max targets per broadcast50
Max message length4096 characters
Supported platformstelegram, whatsapp
Schedule typesnow, interval, daily

Python Example

import requests

BASE = "https://tgautomation.org"
API_KEY = "your_api_key_here"
HEADERS = {"X-API-Key": API_KEY, "Content-Type": "application/json"}

# Get accounts
accts = requests.get(f"{BASE}/api/v1/accounts", headers=HEADERS).json()
account_id = accts["accounts"][0]["id"]

# Get groups
groups = requests.get(f"{BASE}/api/v1/groups?platform=telegram", headers=HEADERS).json()
targets = [g["key"] for g in groups["groups"][:5]]

# Send broadcast
resp = requests.post(f"{BASE}/api/v1/broadcast", headers=HEADERS, json={
    "account_id": account_id,
    "target_keys": targets,
    "message": "Hello from Python!",
    "schedule_type": "now",
})
print(resp.json())

Analytics API

GET/api/analytics/summary?hours=24

Get event summary for the last N hours.

GET/api/analytics/groups

Aggregated broadcast stats: total sent, failed, delivery rate, daily breakdown.

GET/api/analytics/accounts

Per-account stats (connected, groups count).

GET/api/analytics/peak-hours

Best hours for broadcasting based on delivery success.

GET/api/analytics/dashboard

Combined analytics dashboard: summary + groups + accounts + peak hours.

GET/api/analytics/export?format=csv

Export daily analytics as CSV.

POST/api/analytics/events

Record a custom analytics event. Body: {"type":"custom","data":{}}

Auto-Reply Engine

GET/api/auto-replies

List all auto-reply rules.

POST/api/auto-replies

Create a rule. Body: {"keyword":"hello","response":"Hi there!","match_mode":"contains","cooldown_seconds":60}

PUT/api/auto-replies/<rule_id>

Update a rule (keyword, response, enabled, match_mode).

DELETE/api/auto-replies/<rule_id>

Delete a rule.

POST/api/auto-replies/test

Test a message against all rules. Body: {"text":"hello world"}

Welcome / Goodbye Messages

GET/api/welcome-messages

Get all welcome/goodbye configs per group.

POST/api/welcome-messages

Set welcome config. Body: {"group_id":"_default","welcome_text":"Welcome {{name}}!","welcome_enabled":true}

DELETE/api/welcome-messages/<group_id>

Remove welcome config for a group.

Anti-Spam Module

GET/api/antispam/config

Get current anti-spam configuration.

PUT/api/antispam/config

Update anti-spam settings (flood_limit, block_links, banned_words, action).

POST/api/antispam/check

Test a message for spam. Body: {"user_id":"123","text":"buy followers cheap"}

GET/api/antispam/banned

List banned users.

POST/api/antispam/banned

Ban a user. Body: {"user_id":"12345"}

DELETE/api/antispam/banned/<user_id>

Unban a user.

A/B Testing

GET/api/ab-tests

List all A/B tests.

POST/api/ab-tests

Create test. Body: {"name":"Test 1","variants":[{"name":"A","template":"..."},{"name":"B","template":"..."}],"groups":["g1","g2"]}

POST/api/ab-tests/<test_id>/start

Start an A/B test.

POST/api/ab-tests/<test_id>/results

Record variant results. Body: {"variant":"A","sent":50,"delivered":45,"failed":5}

POST/api/ab-tests/<test_id>/complete

Complete test and determine winner.

DELETE/api/ab-tests/<test_id>

Delete a test.

Drip Campaigns

GET/api/drip-campaigns

List all drip campaigns.

POST/api/drip-campaigns

Create campaign. Body: {"name":"Onboarding","steps":[{"message":"Welcome!","delay_minutes":0},{"message":"Day 2","delay_minutes":1440}]}

POST/api/drip-campaigns/<camp_id>/start

Activate a campaign.

POST/api/drip-campaigns/<camp_id>/pause

Pause a campaign.

PUT/api/drip-campaigns/<camp_id>

Update campaign name, steps, or targets.

DELETE/api/drip-campaigns/<camp_id>

Delete a campaign.

Contact CRM

GET/api/contacts?search=&tag=&segment=

List contacts with filtering.

POST/api/contacts

Create contact. Body: {"name":"John","phone":"+1234","tags":["vip"],"segment":"lead"}

GET/api/contacts/<id>

Get single contact.

PUT/api/contacts/<id>

Update contact fields.

DELETE/api/contacts/<id>

Delete contact.

POST/api/contacts/<id>/interaction

Log interaction. Body: {"note":"Called, interested","type":"call"}

POST/api/contacts/import

Bulk import. Body: {"contacts":[{"name":"A","phone":"..."},{"name":"B"}]}

GET/api/contacts/export

Export all contacts as CSV.

GET/api/contacts/segments

Get segment counts.

GET/api/contacts/tags

Get tag counts.

Webhooks

GET/api/webhooks

List webhooks.

POST/api/webhooks

Create webhook. Body: {"name":"My Hook","url":"https://...","events":["*"],"secret":"optional"}

PUT/api/webhooks/<id>

Update webhook.

DELETE/api/webhooks/<id>

Delete webhook.

POST/api/webhooks/<id>/test

Fire a test webhook.

GET/api/webhooks/log?limit=50

Recent webhook delivery log.

POST/api/webhooks/inbound/<hook_id>

Inbound receiver — external systems POST events here (no auth required, validates hook ID).

Reports / Export

GET/api/reports/automation-log?format=csv&limit=100

Export automation logs as CSV or JSON.

GET/api/reports/groups?format=csv

Export scanned groups as CSV or JSON.

GET/api/reports/summary

Full system summary: analytics, contacts, campaigns, webhooks.