Skip to content

How to Manage YouTube Comments With an API in 2026

The YouTube comments API workflow in this guide covers the full loop for a connected channel: connect the channel, retrieve the accountId, list comments with pagination, post a top-level comment, reply to a comment, and delete a comment when moderation requires it. Working directly with the YouTube Data API would require a Google Cloud project, OAuth with the right scope, quota management, and care around the commentThreads versus comments distinction that often trips people up. YouTube access tokens also expire every hour, so a long-running workflow needs token refresh and rotation to keep running. The examples here preserve the exact methods, paths, field names, and response shapes for each operation so you can implement the same contract in your own code.

What you need

Before any comment call, you need an access key and a connected YouTube channel. Every request uses the x-access-key header with the value shown as YOUR_API_KEY in the examples. Keep that header on connect, integrations, list, create, reply, and delete requests, and treat a missing or incorrect key as the first failure to check when a call does not succeed.

Step 1: Get your API key

Retrieve your access key from the Access Keys page and send it as the x-access-key header on every request. The header example is shown in the authentication example below. Do not put the key in query parameters or request bodies, because the contract shown in the source uses the header.

Step 2: Connect your YouTube channel

Connect the YouTube channel through the connect endpoint, which returns an authorization URL for the OAuth flow. Comment management needs the youtube.force-ssl scope, which is already requested at connect, so no separate Google Cloud project or API key setup is part of this workflow. After connecting, call the integrations endpoint and take the account ID from the result. That value is the accountId used in every comment call below. If accountId is missing, stop and fix the connection step before attempting to list, post, reply, or delete.

Step 3: List comments on a video

To list comments, send a GET request to /v1/comments with platform=youtube, accountId set to your connected channel ID, and postId set to the video ID. The response contains top-level comments and their replies in one payload, with fields including id, text, author, timestamp, likeCount, hidden, and replies, plus a nextCursor value for pagination. The default page size is 25. You can request a limit from 1 to 100, and you page forward by passing the nextCursor value as after on the next call. Check the decision in the field map below before coding the loop: postId identifies the video whose comments you are reading, while commentId identifies an existing comment you are replying to or deleting.

Step 4: Post a top-level comment

To post a top-level comment, send a POST request to /v1/comments with platform, accountId, postId, and text in the JSON body. The comment posts as the connected channel. The response returns success and a commentId for the new comment. Save that commentId, because it is the identifier you will use later to reply into the thread or to delete the comment. If you send commentId instead of postId, you are not starting a new top-level comment; you are replying, as described in the next step.

Step 5: Reply to a comment

Replying uses the same POST /v1/comments endpoint, but you swap postId for commentId. Send platform, accountId, commentId, and text, and the reply is nested under the existing comment identified by commentId. The response has the same shape as the create response: a success flag and the new commentId for your reply. This list-then-reply sequence is the basis for an auto-responder: read comments with the list operation, match the comments you care about, then reply to a comment for each match. Before replying, verify that the commentId came from a list response or a create response for the same accountId, and do not reuse a commentId from a different channel.

Step 6: Delete a comment

To delete a comment, send a DELETE request to /v1/comments/{commentId} with platform=youtube and accountId as query parameters. The response returns success with no additional comment payload in the example. Removal cannot be undone, so reserve it for moderation decisions, not tidying up. Before deleting, confirm the commentId is the exact comment you intend to remove, because there is no undo step in this contract.

One thing YouTube can't do here

There is no hide or unhide operation for YouTube comments through this API. The moderation options in this contract are reply and delete. Plan your workflow around those two actions: use reply to answer or redirect, and use delete when the comment should be removed. Do not design a hide/unhide step for YouTube based on behavior available for other platforms.

What it costs

Each new comment and each reply costs one credit; list and delete are billed under standard usage, with free-tier credits available for testing. Budget your workflow accordingly: a loop that lists comments and then replies to many of them will spend credits on each reply, even though the list step itself follows standard usage.

What's next

The complete loop is: connect the channel and retrieve accountId, list comments with pagination, post a top-level comment with postId, reply to a comment with commentId, and delete a comment when moderation requires it. That sequence is enough to build a comment inbox or an auto-reply workflow on top of your channel. The full reference is on the YouTube Comments API page, and a no-code version for testing the same flow first is available through the YouTube comment manager. If you also publish the videos you are moderating, see how to upload a YouTube video with an API.

YouTube comments API input contract
OperationMethod and pathRequired inputsResponse fields shown
Connect YouTube channelGET {{API_BASE_URL}}/v1/connect/youtubeHeader: x-access-keyAuthorization URL for OAuth flow (described in source; no JSON example supplied)
List integrations to get accountIdGET {{API_BASE_URL}}/v1/connect/integrationsHeader: x-access-keyIntegration containing accountId (described in source; no JSON example supplied)
List commentsGET {{API_BASE_URL}}/v1/commentsQuery: platform=youtube, accountId, postId; optional: limit (1 to 100, default 25), after (nextCursor value); Header: x-access-keysuccess, comments[] with id, text, author{id, name}, timestamp, likeCount, hidden, replies, nextCursor
Post a top-level commentPOST {{API_BASE_URL}}/v1/commentsHeader: x-access-key; Content-Type: application/json; Body: platform, accountId, postId, textsuccess, commentId
Reply to a commentPOST {{API_BASE_URL}}/v1/commentsHeader: x-access-key; Content-Type: application/json; Body: platform, accountId, commentId, textsuccess, commentId
Delete a commentDELETE {{API_BASE_URL}}/v1/comments/{commentId}Query: platform=youtube, accountId; Header: x-access-keysuccess

Exact source contract; origin shown as {{API_BASE_URL}} in code examples.

Connect YouTube channel
curl {{API_BASE_URL}}/v1/connect/youtube \
  -H "x-access-key: YOUR_API_KEY"
Retrieve accountId from integrations
curl {{API_BASE_URL}}/v1/connect/integrations \
  -H "x-access-key: YOUR_API_KEY"
List comments on a video
curl "{{API_BASE_URL}}/v1/comments?platform=youtube&accountId=your-yt-id&postId=VIDEO_ID" \
  -H "x-access-key: YOUR_API_KEY"
List comments response example
{
  "success": true,
  "comments": [
    {
      "id": "Ugx...AaABAg",
      "text": "An example comment.",
      "author": { "id": "UCabc123", "name": "Sam" },
      "timestamp": "2026-10-05T14:22:10Z",
      "likeCount": 3,
      "hidden": null,
      "replies": []
    }
  ],
  "nextCursor": "QURTSl9..."
}
Post a top-level comment
curl -X POST {{API_BASE_URL}}/v1/comments \
  -H "x-access-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "platform": "youtube",
    "accountId": "your-yt-id",
    "postId": "VIDEO_ID",
    "text": "An example comment."
  }'
Create comment response example
{
  "success": true,
  "commentId": "Ugx...AaABAg"
}
Reply to a comment
curl -X POST {{API_BASE_URL}}/v1/comments \
  -H "x-access-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "platform": "youtube",
    "accountId": "your-yt-id",
    "commentId": "Ugx...AaABAg",
    "text": "An example comment."
  }'
Delete a comment
curl -X DELETE "{{API_BASE_URL}}/v1/comments/Ugx...AaABAg?platform=youtube&accountId=your-yt-id" \
  -H "x-access-key: YOUR_API_KEY"
Delete comment response example
{
  "success": true
}