> ## Documentation Index
> Fetch the complete documentation index at: https://docs.social-api.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# YouTube

> Connect and interact with YouTube channels via the YouTube Data API.

<Badge>Available</Badge>

**Managed connector** - SocialAPI handles the Google Cloud project and YouTube Data API access for you. No customer-side Google Cloud setup required. See [Platform credentials](/guides/platform-credentials).

## At a glance

| Field         | Value                                                      |
| ------------- | ---------------------------------------------------------- |
| Platform slug | `youtube`                                                  |
| Auth type     | OAuth 2.0 (Google)                                         |
| API           | YouTube Data API v3                                        |
| Best for      | Comment moderation and metadata on owned YouTube channels. |

## Capabilities

| Feature                        | Supported | Notes                                                        |
| ------------------------------ | --------- | ------------------------------------------------------------ |
| List posts                     | Yes       | Returns uploaded videos                                      |
| Comments                       | Yes       | Scoped to a specific video                                   |
| Reply to comment               | Yes       |                                                              |
| Comment replies (thread)       | Yes       |                                                              |
| Moderate comment (hide/delete) | Yes       | Hide sets moderation status; delete removes permanently      |
| Like comment                   | No        | Not supported by YouTube API                                 |
| Private reply                  | No        | Not applicable                                               |
| DMs                            | No        | Not supported by platform                                    |
| Reviews                        | No        | Not applicable                                               |
| Mentions                       | No        | Not supported via YouTube API                                |
| Create post                    | Yes       | Upload and publish videos                                    |
| Update post                    | Yes       | Update title, description, tags, privacy, and other metadata |
| Delete post                    | Yes       |                                                              |
| Edit own comment               | Yes       | PATCH /v1/platforms/youtube/comments/{commentId}             |

## Connecting

```bash theme={null}
curl -X POST https://api.social-api.ai/v1/accounts/connect \
  -H "Authorization: Bearer $SOCAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "platform": "youtube",
    "redirect_uri": "https://app.example.com/oauth/callback",
    "state": "session_abc123"
  }'
```

Response:

```json theme={null}
{
  "auth_url": "https://accounts.google.com/o/oauth2/v2/auth?client_id=...&state=...",
  "state": "4a8f2c1e9b3d7f06a5c2e8b4d1f3a7e2"
}
```

Redirect your user to `auth_url`. After they authorize, SocialAPI exchanges the code with YouTube and redirects the user to your `redirect_uri` with the connection result. See [OAuth flows](/guides/oauth#step-3-receive-the-result-at-your-redirect_uri) for the redirect parameters.

## Reading samples

### List posts

```bash theme={null}
curl "https://api.social-api.ai/v1/posts?account_ids=acc_01HZ9X3Q4R5M6N7P8V2K0W1J" \
  -H "Authorization: Bearer $SOCAPI_KEY"
```

### List comments on a post

```bash theme={null}
curl "https://api.social-api.ai/v1/inbox/comments/{videoId}" \
  -H "Authorization: Bearer $SOCAPI_KEY"
```

Sample response:

```json theme={null}
{
  "data": [
    {
      "id": "sapi_cmt_eW91dHViZTpVZ3h...",
      "platform": "youtube",
      "type": "comment",
      "author": {
        "id": "UCxyz123",
        "name": "Jane Smith",
        "avatar_url": "https://yt3.ggpht.com/..."
      },
      "content": {
        "text": "Great video!"
      },
      "metadata": {
        "post_id": "dQw4w9WgXcQ",
        "like_count": 5,
        "has_replies": true
      },
      "created_at": "2026-03-15T10:30:00Z",
      "account_id": "acc_01HZ9X3Q4R5M6N7P8V2K0W1J",
      "platform_id": "Ugxyz..."
    }
  ],
  "count": 1
}
```

## Publishing

Create a video post by providing a video URL and optional metadata via `platform_data`. See the [API reference](/api-reference/introduction) for the full request schema.

```bash theme={null}
curl -X POST https://api.social-api.ai/v1/posts \
  -H "Authorization: Bearer $SOCAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Check out our latest video!",
    "media_ids": ["f47ac10b-58cc-4372-a567-0e02b2c3d479"],
    "visibility": "public",
    "targets": [
      {
        "account_id": "acc_01HZ9X3Q4R5M6N7P8V2K0W1J",
        "platform_data": {
          "category_id": "22",
          "tags": ["tutorial", "demo"],
          "made_for_kids": false,
          "embeddable": true,
          "notify_subscribers": true
        }
      }
    ]
  }'
```

### PlatformData fields

YouTube platform data can be supplied in two forms, which are merged before delivery (per-target values override top-level values on conflict):

* **Top-level:** `platform_data.youtube.<key>` applies to all YouTube targets in the request.
* **Per-target:** `targets[].platform_data.<key>` (flat keys, no nesting) overrides the top-level value for that target only. The example above uses this form.

Fields supported in either form:

| Field                      | Type      | Default                 | Description                                                                                                                 |
| -------------------------- | --------- | ----------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| `title`                    | string    | none                    | Video title. If omitted, the title is inferred from the filename or URL.                                                    |
| `category_id`              | string    | `"22"` (People & Blogs) | YouTube video category ID. See [YouTube category list](https://developers.google.com/youtube/v3/docs/videoCategories/list). |
| `tags`                     | string\[] | none                    | Video tags for discoverability.                                                                                             |
| `default_language`         | string    | none                    | BCP-47 language code (e.g. `"en"`, `"fr"`).                                                                                 |
| `made_for_kids`            | bool      | `false`                 | Whether the video is made for children (COPPA).                                                                             |
| `embeddable`               | bool      | `true`                  | Whether the video can be embedded on other sites.                                                                           |
| `license`                  | string    | `"youtube"`             | `"youtube"` for standard YouTube license, `"creativeCommon"` for CC BY.                                                     |
| `public_stats_viewable`    | bool      | `true`                  | Whether view counts and likes are publicly visible.                                                                         |
| `publish_at`               | string    | none                    | RFC 3339 timestamp for scheduled publish (e.g. `"2026-04-10T15:00:00Z"`). Only applies when `visibility` is `"private"`.    |
| `recording_date`           | string    | none                    | Date the video was recorded, in `YYYY-MM-DD` format.                                                                        |
| `contains_synthetic_media` | bool      | `false`                 | Whether the video contains AI-generated or synthetic content.                                                               |
| `notify_subscribers`       | bool      | `true`                  | Whether to send a notification to channel subscribers.                                                                      |
| `playlist_id`              | string    | none                    | YouTube playlist ID. The video is added to this playlist after publishing.                                                  |

## Channel summary

Retrieve aggregate stats for a connected YouTube channel.

```bash theme={null}
curl "https://api.social-api.ai/v1/platforms/youtube/accounts/{id}/summary" \
  -H "Authorization: Bearer $SOCAPI_KEY"
```

Response:

```json theme={null}
{
  "title": "Acme Corp",
  "handle": "@acmecorp",
  "thumbnail_url": "https://yt3.ggpht.com/...",
  "subscriber_count": 12400,
  "view_count": 980000,
  "video_count": 47
}
```

## Force sync

Force an immediate re-sync of uploaded videos for an account.

```bash theme={null}
curl -X POST "https://api.social-api.ai/v1/platforms/youtube/accounts/{id}/sync" \
  -H "Authorization: Bearer $SOCAPI_KEY"
```

Returns `{"success": true}` on success.

## Edit own comment

To edit a comment you own, use the YouTube-specific PATCH endpoint. All three body fields are required.

```bash theme={null}
curl -X PATCH "https://api.social-api.ai/v1/platforms/youtube/comments/{commentId}" \
  -H "Authorization: Bearer $SOCAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "account_id": "acc_01HZ9X3Q4R5M6N7P8V2K0W1J",
    "post_id": "dQw4w9WgXcQ",
    "text": "Updated comment text"
  }'
```

## Limitations and gotchas

* **No DMs or mentions.** YouTube does not expose a messaging or mention API. These endpoints return `501`.
* **No webhook handler.** YouTube does not push real-time events. Posts and comments are fetched on demand.
* **Comment moderation.** Hide sets the comment moderation status to rejected (removes it from public view). Delete removes it permanently. The dedicated moderation endpoint (`POST /v1/platforms/youtube/comments/{commentId}/moderate`) can also set `held_for_review` explicitly. Like is not supported.
* **Token refresh.** Google OAuth tokens expire. SocialAPI handles refresh automatically. If you receive `401` with `code: "platform.youtube.auth"`, reconnect the account.

## Permissions

SocialAPI's managed Google Cloud OAuth app already requests YouTube Data API v3 scopes for reading and managing comments on your owned channels. You don't need to set up a Google Cloud project. See [Platform credentials](/guides/platform-credentials).

## Related

* [Platform credentials](/guides/platform-credentials)
* [OAuth flows](/guides/oauth)
* [Errors](/guides/errors)
* [Interaction IDs](/guides/interaction-ids)
