Automate YouTube comment moderation using commentThreads.list to fetch comments and comments.setModerationStatus to approve, hold, or reject them. The quota constraint is brutal: each setModerationStatus call costs 50 units and listing comments costs 1 unit — moderating 200 comments per day consumes the entire 10,000 unit daily quota. Service accounts do NOT work with YouTube APIs. The youtube.force-ssl scope is required for moderation actions.
| Fact | Value |
|---|---|
| Platform | YouTube |
| Rate limits | 10,000 quota units/day per project (not per user), resets midnight Pacific Time |
| Difficulty | Intermediate |
| Time required | 30–60 minutes |
| Last updated | May 2026 |
API Quick Reference
10,000 quota units/day per project (not per user), resets midnight Pacific Time
REST only
YouTube Data API v3 — Comment Moderation
YouTube comment moderation via API uses two main endpoints: commentThreads.list to retrieve comments from a channel or video, and comments.setModerationStatus to approve (published), hold (heldForReview), or reject with optional permanent ban. The 50-unit cost per setModerationStatus call makes bulk moderation extremely quota-expensive. With a 10,000 unit daily limit, you can moderate at most 200 comments per day before exhausting the quota. A practical strategy is keyword-based filtering: list comments cheaply at 1 unit, apply keyword patterns in your code, and only call setModerationStatus for clear violations — saving the 50-unit cost for true spam.
https://www.googleapis.com/youtube/v3Authentication
Key endpoints
List comment threads (top-level comments and their reply counts) for a channel or video. The primary endpoint for fetching comments to review.
Set the moderation status of one or more comments. Can approve (published), hold (heldForReview), or reject. Optional banAuthor parameter permanently bans the commenter. Costs 50 units per call regardless of how many comment IDs you pass.
List replies to a specific comment thread. Use when you need to moderate replies in addition to top-level comments.
Permanently delete a comment. Alternative to setModerationStatus=rejected. Cannot be undone. Costs 50 units.
Step-by-step automation
Step 1: Set Up OAuth Authentication
Configure OAuth 2.0 with youtube.force-ssl scope for moderation access.
1# Authorization URL — open in browser for user to approve2https://accounts.google.com/o/oauth2/v2/auth?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI&response_type=code&scope=https://www.googleapis.com/auth/youtube.force-ssl&access_type=offline&prompt=consent34# Exchange code for tokens5curl -X POST https://oauth2.googleapis.com/token \6 -d 'code=AUTH_CODE&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&redirect_uri=REDIRECT_URI&grant_type=authorization_code'Step 2: Fetch Comments for Review
List comments held for review or all recent comments. Use moderationStatus=heldForReview to target only comments awaiting approval.
1# Get comments held for review on a specific video2curl -H 'Authorization: Bearer ACCESS_TOKEN' \3 'https://www.googleapis.com/youtube/v3/commentThreads?part=snippet&videoId=VIDEO_ID&moderationStatus=heldForReview&maxResults=100'45# Get all recent comments across the channel6curl -H 'Authorization: Bearer ACCESS_TOKEN' \7 'https://www.googleapis.com/youtube/v3/commentThreads?part=snippet&allThreadsRelatedToChannelId=CHANNEL_ID&order=time&maxResults=100'Step 3: Apply Keyword Filters
Before calling setModerationStatus (50 units each), classify comments with local code. This is free and saves quota for when you're actually sure about the action.
1# No curl example — keyword filtering is local code, not an API call2# The API searchTerms parameter can pre-filter but it's an OR match3# For complex keyword logic, fetch comments first then filter locallyStep 4: Execute Moderation Actions with Quota Awareness
Call setModerationStatus only for comments that clearly need action. Pass multiple comment IDs in one call (single 50-unit cost) to maximize quota efficiency.
1# Reject multiple comments in one call (single 50-unit cost)2curl -X POST \3 -H 'Authorization: Bearer ACCESS_TOKEN' \4 'https://www.googleapis.com/youtube/v3/comments/setModerationStatus?id=comment1%2Ccomment2%2Ccomment3&moderationStatus=rejected'56# Reject with ban7curl -X POST \8 -H 'Authorization: Bearer ACCESS_TOKEN' \9 'https://www.googleapis.com/youtube/v3/comments/setModerationStatus?id=COMMENT_ID&moderationStatus=rejected&banAuthor=true'1011# Approve held comments12curl -X POST \13 -H 'Authorization: Bearer ACCESS_TOKEN' \14 'https://www.googleapis.com/youtube/v3/comments/setModerationStatus?id=comment1%2Ccomment2&moderationStatus=published'Step 5: Schedule Daily Moderation with Quota Tracking
Run moderation as a scheduled job with quota tracking to stay within daily limits. Track how much quota you've used and stop before hitting the ceiling.
1# No direct curl example for scheduling — this is application-level logic2# Run the Python/Node.js script via cron:3# crontab entry: 0 */2 * * * /usr/bin/python3 /path/to/moderate.pyComplete working code
Daily comment moderation bot: fetches held and spam comments, applies keyword classification, batches moderation actions to minimize API calls, and logs results with quota tracking.
Error handling
Each setModerationStatus call costs 50 quota units. Moderating 200 comments consumes the entire 10,000 unit daily quota. If you're also doing other operations (analytics, uploads), the quota is shared.
You passed a thread ID to comments.setModerationStatus instead of the comment ID. Thread IDs and comment IDs are different values — the top-level comment ID is in snippet.topLevelComment.id, not in thread.id.
You're trying to moderate a comment on a video or channel you don't own, or the authenticated user doesn't have channel management permissions.
rejected status removes the comment from public view but doesn't permanently delete it. The comment still exists in the API and can sometimes reappear if the status is changed back.
If comments are turned off on a video in YouTube Studio, the API returns empty results or errors for moderation endpoints on that video.
Rate limits & throttling
Security checklist
- Never auto-ban authors based solely on keyword matching without human review — false positives ban real viewers permanently
- Store OAuth tokens with restricted file permissions and never commit to version control
- Log all moderation actions with comment IDs, authors, text snippets, and timestamps for audit and potential appeals
- Implement a review queue for borderline cases rather than automatic rejection — moderate only clear spam/hate automatically
- Test your keyword patterns on real comment samples before deploying — false positive rates above 5% will damage community trust
- Do not store full comment text beyond what's needed for moderation — comment content may include personal information
- Rate-limit your automation to avoid sudden spikes that might trigger YouTube's anti-abuse systems
- Implement a notification system for human review when comment volume exceeds your automation's confidence threshold
Automation use cases
No-code alternatives
Don't want to write code? These platforms can automate the same workflows visually.
Zapier
YouTube integration in Zapier supports triggers for new comments. Connect to a moderation workflow that can call setModerationStatus via HTTP action. Limited to comment-by-comment processing.
Make (Integromat)
YouTube module supports listing and moderating comments. Can implement keyword filtering logic with Make's built-in text functions. More flexible than Zapier for batch processing with iterators.
n8n
YouTube node combined with Code nodes for keyword filtering. Supports scheduled moderation jobs with quota tracking via n8n variables. Best no-code option for complex moderation logic.
Best practices
- Always use bulk setModerationStatus calls: collect all comment IDs for an action and call once instead of once per comment — same 50-unit cost for 1 or 50 IDs
- Use local keyword classification before API calls — it's free and eliminates unnecessary 50-unit moderation calls for borderline comments
- Target YouTube's own spam detection with moderationStatus=likelySpam in commentThreads.list — these comments are pre-identified spam and safe to bulk-reject
- Track daily quota usage with a persistent file that resets at midnight Pacific Time — unexpected quota exhaustion will stop all YouTube API operations including other automations
- Never auto-ban authors without a pattern of violations — use heldForReview for first-time borderline cases, reject+ban only for clear repeat offenders
- Log all automated moderation decisions with sufficient context (comment text excerpt, classification reason, timestamp) for audit and appeals
- Reserve at least 2,000 quota units per day for non-moderation operations — if other automations share the same GCP project, their quota needs reduce what's available for moderation
- Test keyword patterns offline against historical comments before deploying to avoid false positives that remove legitimate viewer engagement
Ask AI to help
Copy one of these prompts to get a personalized, working implementation.
I'm building a YouTube comment moderation automation using YouTube Data API v3. Key constraints: (1) commentThreads.list = 1 unit, comments.setModerationStatus = 50 units, 10,000 unit daily limit per project, (2) batch multiple comment IDs in single setModerationStatus calls, (3) pre-filter with keyword patterns locally before spending quota on API calls, (4) track daily quota usage in a file that resets at midnight Pacific Time. OAuth only — no service accounts. Use python with google-api-python-client. Include configurable spam patterns and a dry-run mode.
Build a YouTube comment moderation dashboard. After OAuth login with youtube.force-ssl scope, show: list of comments held for review with author, text, and video thumbnail. Each comment has Approve/Reject/Ban buttons. Also show a batch action bar to select multiple comments and moderate in bulk (one API call for multiple IDs). Display daily quota usage as a progress bar (X/10,000 units). Store moderation decisions in Supabase for audit trail.
Frequently asked questions
Why does moderating 200 comments per day exhaust my entire YouTube API quota?
Each comments.setModerationStatus call costs 50 quota units regardless of how many comment IDs you pass. If you call it once per comment, 200 calls × 50 units = 10,000 units = entire daily quota. The optimization is batching: pass up to 50 comment IDs in a single call. 200 comments in batches of 50 = 4 calls = 200 units, leaving 9,800 units for other operations.
What is the difference between rejected, heldForReview, and deleted comments?
heldForReview: comment exists but is hidden from public. The author can still see it. Can be changed to published later. rejected: comment is removed from public view. The author may or may not see it. comments.delete: permanently deletes the comment — cannot be recovered. For spam, reject is usually sufficient. For harassment, delete is more appropriate. Setting banAuthor=true on any moderation action permanently prevents that user from commenting on your channel.
Can I use a service account to run comment moderation on a schedule?
No. Service accounts return NoLinkedYouTubeAccount for all YouTube API calls. For scheduled moderation, you must store the OAuth refresh token from the channel owner and use it to get fresh access tokens in your scheduled script. The refresh token is long-lived (until revoked) and enables headless automated access without requiring the user to re-authorize each time.
How do I moderate comments across all videos on my channel, not just one video?
Use allThreadsRelatedToChannelId instead of videoId in commentThreads.list. Pass your channel ID (UC...) and you'll receive comments from all your videos combined. Combined with moderationStatus=heldForReview, you can process all pending comments channel-wide in one efficient operation.
Will banned users know they've been banned from my channel?
YouTube does not explicitly notify users when they're banned. Banned users typically see their comments appear normally on their end but they're hidden from everyone else (shadow-ban behavior). They may eventually notice their comments get no responses or engagement. The banAuthor=true parameter in setModerationStatus/delete applies a permanent channel-level ban.
Can RapidDev help build a custom moderation system for my YouTube channel?
Yes. If you need more sophisticated moderation — machine learning-based spam detection, multi-language support, appeal workflows, or integration with a customer support system — RapidDev can build a complete moderation platform. We handle the YouTube OAuth integration, quota optimization, and compliance logging so your team focuses on community building, not spam fighting.
What moderation status can I set without channel moderation enabled in YouTube Studio?
With youtube.force-ssl scope, you can set any moderation status (published, heldForReview, rejected) on comments on your own channel's content, regardless of YouTube Studio moderation settings. However, if you have 'hold comments for review' enabled in YouTube Studio, all new comments arrive as heldForReview by default — which is actually useful for automation since you can batch-approve legitimate comments.
Need this automated?
Our team has built 600+ apps with API automations. We can build this for you.
Book a free consultation