API use cases
What you can build with the API
TG Members does not just remove lapsed and disruptive members — it records why. Every decision is a row you can read, filter and export as evidence. These are working recipes, each one a command you can paste into a terminal with your own key substituted.
https://tgmembers.co/api/decisionshttps://tgmembers.co/moderate- 01
Mirror removals into your own moderation app
Pro users running a community or a custom moderation panel
TG Members removes lapsed and disruptive members from your groups, but your own tooling never learns what happened. Pull the decision log, filter to removals in the window you care about, and feed it into your dashboard, audit trail or support workflow.
Every removal across all groups in the last window
bashcurl -s -H "Authorization: Bearer YOUR_KEY" \ "https://tgmembers.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,blocklist:urls:openphish", "text": "verify your wallet to claim your membership" }- 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 handling a report
A member says they were removed by mistake. 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://tgmembers.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://tgmembers.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
Evidence export for chargebacks and appeals
Communities with reporting, payment or platform-appeal obligations
When a payment processor disputes a chargeback or Telegram reviews an appeal, you need a durable, timestamped record of every membership action — not screenshots. Page through the decision log in 200-record slices and write it to CSV or your warehouse as a signed evidence export.
Append a signed slice to a CSV
bashcurl -s -H "Authorization: Bearer YOUR_KEY" \ "https://tgmembers.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' \ >> evidence-export.csv
Keep the export verifiable — hash each slice as you write it
bashcurl -s -H "Authorization: Bearer YOUR_KEY" \ "https://tgmembers.co/api/decisions?limit=200" \ > slice.json sha256sum slice.json >> evidence-export.sha256
- The endpoint returns newest first and caps at 200 records per call — loop with a delay that keeps you under 60 requests/minute.
- Store the per-slice hashes alongside the CSV so an auditor can confirm the export was not edited after the fact.
- 04
Stream decisions into a SIEM
Security teams forwarding moderation events to Splunk, Elastic or a data lake
Your SIEM is where security and abuse events are correlated. Poll the decision log on a schedule and forward each verdict to your collector's HTTP endpoint — Splunk HEC, an Elastic bulk ingest or a generic webhook — so moderation events sit beside the rest of your telemetry.
Shape decisions into SIEM events and post them to your collector
bashcurl -s -H "Authorization: Bearer YOUR_KEY" \ "https://tgmembers.co/api/decisions?limit=200" \ | jq '[.decisions[] | {time: .ts, host: .groupId, sourcetype: "tgmembers:decision", event: {verdict, score, reasons, text}}]' \ | curl -s -X POST -H "Authorization: Splunk YOUR_KEY" \ --data-binary @- "https://siem.example.com/services/collector/event"One event per line for a bulk ingest (Elastic, Loki, Kafka)
bashcurl -s -H "Authorization: Bearer YOUR_KEY" \ "https://tgmembers.co/api/decisions?limit=200" \ | jq -c '.decisions[] | {ts, groupId, verdict, score, reasons, text}' \ >> tgmembers-decisions.ndjson- Track the highest `id` you have forwarded and use it as a cursor so a retry does not duplicate events in the SIEM.
- Keep the request rate under 60/minute per key; a one-minute poll of 200-record slices is well inside the limit for most communities.
- 05
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 membership" "https://tgmembers.co/moderate"
Verdict with the reasons behind it
json{ "verdict": "delete", "score": 0.94, "reasons": [ "signature:phishing:verify your wallet", "blocklist: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.
- 06
Keep your bot in sync with removals
Admins running their own Telegram bot in the same groups
When TG Members removes a message or a member, 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 removals your bot can match against its own cache
bashcurl -s -H "Authorization: Bearer YOUR_KEY" \ "https://tgmembers.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://tgmembers.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 removals happened.
- A 429 carries `retryAfterSeconds`; back off for that long and resume, do not retry in a tight loop.
- 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 removals, 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://tgmembers.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://tgmembers.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 Members in observation mode and feed its `review` verdicts into your own moderation console. You decide what is removed, 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://tgmembers.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://tgmembers.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 payout, 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://tgmembers.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://tgmembers.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 raise a notification 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 '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://tgmembers.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 moderation service itself (no key needed)
bashcurl -s -o /dev/null -w "%{http_code}\n" "https://tgmembers.co/healthz"- A `401 INVALID_KEY` in production usually means a plan lapsed, not a bug — report 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.