API use cases
What you can build with the API
TG Filter does not just delete spam — it records why. Every decision is a row you can read, filter and export. These are working recipes, each one a command you can paste into a terminal with your own key substituted.
https://tgfilter.co/api/decisionshttps://bot.tgfilter.co/moderate- 01
Mirror deletions into your own moderation app
Pro users running a community or a custom moderation panel
TG Filter removes spam from your groups, but your own tooling never learns what was removed. Pull the decision log, filter to deletes in the window you care about, and feed it into your dashboard, audit trail or support workflow.
Every deletion across all groups in the last window
bashcurl -s -H "Authorization: Bearer YOUR_KEY" \ "https://tgfilter.co/api/decisions?verdict=delete&limit=200" \ | jq '.decisions[] | {group: .groupId, score, reasons, text}'Shape of each record — reasons tell you which layer fired
json{ "id": 5, "ts": 1796131250, "groupId": "-1005936987759", "verdict": "delete", "score": 0.94, "reasons": "signature:phishing:verify your wallet,signal:urls:openphish", "text": "verify your wallet to claim your airdrop" }- Entries carrying an `override` were reversed by a human — use `override ?? verdict` as the effective outcome, exactly as the API already applies it when you pass `verdict=`.
- Poll on a timer (60 requests/minute per key) or store the highest `id` you have seen and dedupe client-side.
- 02
Drill into one group after a complaint
Group owners and moderators investigating a report
A member says a message was wrongly removed. Filter the log to that group and verdict, then read the reason codes and score before deciding whether to override in the dashboard.
Everything removed in a specific group
bashcurl -s -H "X-API-Key: YOUR_KEY" \ "https://tgfilter.co/api/decisions?group=-1005936987759&verdict=delete&limit=50"
What was merely sent to review (not removed)
bashcurl -s -H "X-API-Key: YOUR_KEY" \ "https://tgfilter.co/api/decisions?group=-1005936987759&verdict=review"
- `verdict=review` is the grey-zone queue — these messages were flagged but not acted on, which is usually the first place to look when someone disputes a removal.
- 03
Find only high-confidence removals
Teams that want alerts on their worst offenders, not every decision
Exporting every delete is noisy. Sort by score in your own code and escalate only the confident ones, or build a weekly digest of the groups generating the most removals.
Top-scoring removals, grouped for a report
bashcurl -s -H "Authorization: Bearer YOUR_KEY" \ "https://tgfilter.co/api/decisions?verdict=delete&limit=200" \ | jq -r '.decisions | sort_by(-.score) | .[] | "\(.score|tostring[0:4]) \(.groupId) \(.reasons | split(",")[0])"' \ | head -20Per-group removal counts
bashcurl -s -H "Authorization: Bearer YOUR_KEY" \ "https://tgfilter.co/api/decisions?verdict=delete&limit=200" \ | jq -r '[.decisions[].groupId] | group_by(.) | map({group: .[0], deletes: length}) | sort_by(-.deletes)' - 04
Check a message before it reaches the group
Anyone running a bot that posts on behalf of users
If your own bot relays user-submitted content, classify it first. Send the raw text to the moderation endpoint and hold anything that comes back `review` or `delete` instead of posting it.
Classify raw text (body is text/plain, not JSON)
bashcurl -s -X POST -H "Authorization: Bearer YOUR_KEY" -H "Content-Type: text/plain" --data "verify your wallet to claim your airdrop" "https://bot.tgfilter.co/moderate"
Verdict with the reasons behind it
json{ "verdict": "delete", "score": 0.94, "reasons": [ "signature:phishing:verify your wallet", "signal:urls:openphish" ] }- Branch on `verdict`, not `score`: thresholds are tuned per deployment, so the verdict is the stable contract.
- A `review` verdict means the grey-zone judge was not confident either way — queue it for a human rather than dropping it.
- 05
Keep your bot in sync with deletions
Admins running their own Telegram bot in the same groups
When TG Filter deletes a message, your own bot may still hold a reference to it. Have your bot listen for Telegram's deleted-message updates and use the decision log to confirm whether the removal was ours (and why) before deleting your copy.
Recent deletes your bot can match against its own cache
bashcurl -s -H "Authorization: Bearer YOUR_KEY" \ "https://tgfilter.co/api/decisions?verdict=delete&limit=100" \ | jq -r '.decisions[] | [.ts, .groupId, .text] | @tsv'
Check your key and remaining quota before a bulk pass
bashcurl -s -H "Authorization: Bearer YOUR_KEY" \ "https://tgfilter.co/api/decisions?limit=1" \ | jq '{rateLimit}'- A 401 with code `INVALID_KEY` means the key was revoked or the account's plan lapsed — fall back to your own heuristics rather than assuming no deletions happened.
- A 429 carries `retryAfterSeconds`; back off for that long and resume, do not retry in a tight loop.
- 06
Build a monthly audit export
Communities with reporting or compliance obligations
Page through the log in 200-record slices and write it to CSV or your warehouse, so you have a durable record of every moderation action independent of Telegram's own history.
Append a slice to a CSV
bashcurl -s -H "Authorization: Bearer YOUR_KEY" \ "https://tgfilter.co/api/decisions?limit=200" \ | jq -r '["ts","group","verdict","score","reasons"], (.decisions[] | [.ts, .groupId, (if .override != null then .override else .verdict end), .score, .reasons]) | @csv' \ >> moderation-export.csv
- The endpoint returns newest first and caps at 200 records per call — loop with a delay that keeps you under 60 requests/minute.
- 07
Spot a campaign spreading across groups
Admins of several related groups watching for coordinated blasts
A scam blast rarely hits one group. Pull recent deletes, reduce each `reasons` string to its signature codes, and count how many distinct groups share the same one inside a short window — that is a campaign in progress, before it reaches the rest of your groups.
Signatures seen in more than one group
bashcurl -s -H "Authorization: Bearer YOUR_KEY" \ "https://tgfilter.co/api/decisions?verdict=delete&limit=200" \ | jq -r '.decisions[] | {g: .groupId, sig: (.reasons | split(",") | map(select(startswith("signature:"))) | .[0])} | select(.sig != null) | "\(.sig)\t\(.g)"' \ | sort -u | cut -f1 | uniq -c | sort -rn | headSame thing as a table of group ids per signature
bashcurl -s -H "Authorization: Bearer YOUR_KEY" \ "https://tgfilter.co/api/decisions?verdict=delete&limit=200" \ | jq -r '[.decisions[] | {sig: (.reasons | split(",") | map(select(startswith("signature:"))) | .[0]), g: .groupId}] | group_by(.sig) | map(select(([.[].g] | unique | length) > 1) | {signature: .[0].sig, groups: ([.[].g] | unique)})'- `sort -u` collapses repeated (signature, group) pairs first, so the count is distinct groups rather than distinct messages — one noisy group cannot fake a campaign.
- The window is whatever your `limit` reaches. For short campaigns poll every few minutes and keep the last N rows in your own store.
- 08
Build a review queue for the grey zone
Moderators who prefer to confirm before anything is removed
Run TG Filter in observation mode and feed its `review` verdicts into your own moderation console. You decide what is deleted, and the reason codes give your moderators context instead of just a message.
Newest grey-zone messages, oldest first for a queue
bashcurl -s -H "Authorization: Bearer YOUR_KEY" \ "https://tgfilter.co/api/decisions?verdict=review&limit=50" \ | jq -r '.decisions | sort_by(.ts) | .[] | "\(.ts) score=\(.score|tostring[0:4]) \(.groupId) \(.reasons)"'
Only the ones the judge escalated, not plain signature hits
bashcurl -s -H "Authorization: Bearer YOUR_KEY" \ "https://tgfilter.co/api/decisions?verdict=review&limit=100" \ | jq -r '.decisions[] | select(.judge != null) | {group: .groupId, score, judge, text}'- `review` means the engine was not confident either way — it is the highest-value queue to read, and the reason codes usually make the call obvious within seconds.
- Overrides you apply in the dashboard come back in this same feed with `override` set, so your console can show 'already decided' without a second store.
- 09
Watch for one specific scam pattern
Teams that know what is targeting their community
If a particular scam keeps coming back — a phishing phrase, a fake airdrop, a job offer script — filter the log by that signature's reason code and count how often it fires, across every group, without reading every message.
All decisions carrying one signature, with timestamps
bashcurl -s -H "Authorization: Bearer YOUR_KEY" \ "https://tgfilter.co/api/decisions?limit=200" \ | jq -r '.decisions[] | select(.reasons | contains("signature:phishing")) | [.ts, .groupId, .verdict, .score] | @tsv'Daily hit count for that signature
bashcurl -s -H "Authorization: Bearer YOUR_KEY" \ "https://tgfilter.co/api/decisions?limit=200" \ | jq -r '.decisions[] | select(.reasons | contains("signature:phishing")) | .ts | strftime("%Y-%m-%d")' \ | sort | uniq -c- Reason codes are stable, human-readable identifiers (`signature:phishing:verify your wallet`) — match on the prefix, not the whole string, and you survive wording tweaks.
- Pair this with a daily cron and alert when the count jumps; a sudden rise is your early warning that a campaign has started.
- 10
Health-check your integration
Anyone with the API in a production pipeline
Before blaming your code, check whether the API is reachable and your key is still valid. The decision log returns a distinct status for each failure, so a monitoring probe can tell 'filter service down' from 'key revoked' from 'we are being throttled'.
Distinguish the three failure modes
bashcurl -s -o /dev/null -w "%{http_code}\n" \ -H "Authorization: Bearer YOUR_KEY" \ "https://tgfilter.co/api/decisions?limit=1" # 200 = healthy # 401 MISSING_KEY = no key sent # 401 INVALID_KEY = key revoked, expired, or the plan lapsed # 429 RATE_LIMITED = back off retryAfterSeconds, then resume # 503 UNAVAILABLE = decision log down on this nodeLiveness of the filter service itself (no key needed)
bashcurl -s -o /dev/null -w "%{http_code}\n" "https://bot.tgfilter.co/healthz"- A `401 INVALID_KEY` in production usually means a plan lapsed, not a bug — alert on it separately from 5xx so you do not wake someone up for a billing event.
- Poll no faster than you need: a probe every minute plus your real traffic stays well inside 60 requests/minute.
Ready to try it?
API access is included with Pro. Generate a key from your dashboard and run any of the recipes above.