Platforms / YouTube
YouTube API
Upload videos and Shorts to YouTube channels, edit their details and moderate comments.
At a glance
- Platform id
youtube- Connects
- channel
- Sign-in
- OAuth: the user approves on the platform's own page
- Post types
- Video · Short
Capabilities
| Publishing | Yes |
|---|---|
| Scheduling | Yes |
| Comments | Yes |
| Direct messages | No |
| Mentions | No |
| Reviews | No |
| Analytics | Yes |
Required on every post
- Exactly one video.
- A title: the post's top-level title or platform_data.youtube.title. It is never taken from the text; leaving it out fails with validation.field_required (field title).
Options
Send these in platform_data.youtube on the post, or flat in a target's own platform_data (the target's keys win). See Publishing.
| Key | Type | What it does |
|---|---|---|
titlerequired | string | Video title, up to 100 characters. The post's top-level title wins. |
privacy | public | unlisted | private | Default public, or private when publish_at is set. |
publish_at | RFC 3339 time | YouTube's own schedule: the video uploads now as private and goes public at this time. Needs privacy private. |
tags | string[] or comma list | Video tags, 500 characters in all. |
category_id | string | YouTube category. Default 22 (People & Blogs). |
made_for_kids | boolean | Default false. |
notify_subscribers | boolean | Default true. |
playlist_id | string | Add the video to this playlist after the upload. A failure does not fail the post. |
cover_url | URL | JPG or PNG custom thumbnail up to 2 MB, set after the upload. Verified channels only. |
license | youtube | creativeCommon | The video's licence. |
embeddable, public_stats_viewable, contains_synthetic_media | boolean | Sent only when set. |
default_language | BCP-47 code | Language of the title and description. |
recording_date | YYYY-MM-DD | When the video was recorded. |
Limits
- Description 5,000 bytes, title 100 characters.
- One upload costs about 1,600 quota units: the default 10,000 a day allows about 6 uploads across all users. A used-up quota answers a retryable 429 until midnight Pacific Time.
- Comment replies: at most 5 replies and top-level comments per channel per day. The 6th answers 429 validation.youtube_daily_reply_limit.
- This server caps each channel at 25 posts an hour and 50 a day.
Text over the limit fails validation before anything is sent. The caps of this server are explained in Rate limits.
Good to know
- Each connect adds the one channel picked on Google's consent screen; connect again to add another channel.
- The post text is the description. Shorts need no flag: YouTube classifies short vertical videos itself.
- Scheduling: either this server uploads at the scheduled time, or publish_at uploads now as private and YouTube makes it public later.
- After publishing, the description, title, tags, visibility and thumbnail can be changed; the video file cannot. Deleting removes the video from YouTube.
- Custom thumbnails (cover_url) and playlists (playlist_id) are set after the upload; if either fails the video still publishes. Custom thumbnails need a verified channel.
- Comments: read, reply, comment on a video, moderate and edit your own. Hiding a comment sets it to rejected. Only the channel's own comments can be deleted. YouTube sends no comment webhooks, so comments are polled.
- Accounts connected with youtube.upload only should reconnect: everything now runs on youtube.force-ssl.
- Until verified, users see an 'unverified app' warning and you are capped at 100 users.
Publish with the API
curl https://api.zaynstack.com/v1/posts \
-H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
-d '{
"text": "Hello from SocialWire",
"title": "My first upload",
"media": [{ "type": "video", "source_type": "url", "source": "https://example.com/file.mp4" }],
"targets": [{ "account_id": "<YouTube account id>" }],
"publish_now": true
}'An operation YouTube cannot do answers 501 resource.not_supported. Agents can do the same through the MCP server.
Connection errors
A connection that fails comes back to your redirect_uri with status=error, error=<code> and error_description, or as the error of the connect call. All codes: Connect accounts.
| Code | Meaning |
|---|---|
platform.youtube.no_channels | The Google account has no YouTube channel. Create one on youtube.com and connect again. |
account.already_linked | The brand already holds a different account on this platform, or the account belongs to another brand while lock_accounts_to_brand is on. |
billing.brands_limit | No brand_id was sent, so a new brand was needed, and the plan has no room for another brand. |
Webhook events
Every platform sends the post.* and account.* events. YouTube also sends:
comment.received(from polling)
Not supported yet
- Connecting several channels in one sign-in: connect once per channel.
- DMs, mentions and comment likes: YouTube has no API for them.
- Replacing the video file of a published video.
Developer setup (self-hosting)
Only the operator of this server does this, once. Users then just click Connect.
- Google Cloud console → new project → enable YouTube Data API v3.
- OAuth consent screen: External, add app name, logo, support email, homepage, Privacy Policy and Terms URLs, and your authorised domain.
- Credentials → OAuth client ID → Web application; add the Callback address below.
- Put the client ID and secret into GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET (shared with Google Business).
- Callback address
https://api.zaynstack.com/api/connect/youtube/callback- Webhook address
https://api.zaynstack.com/api/hooks/youtube- Server variables
GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET- Developer console
- YouTube developer console
Permissions requested
https://www.googleapis.com/auth/youtube.force-ssl
When a reconnect grants fewer permissions than before, an account.updated event with change permissions_reduced is sent. Accounts connected before a permission was added keep working but must reconnect to use the features it unlocks.
Before anyone can connect (review)
- Verify the domain in Google Search Console.
- Publish the consent screen and submit for OAuth verification: youtube.force-ssl is a sensitive scope, so Google asks for a demo video and justification.
- YouTube API Services audit: unverified projects upload videos as private only; request the audit (and more quota than 10,000 units/day) via the YouTube API compliance form.
Typical wait: OAuth verification 1-4 weeks; YouTube audit 2-6 weeks. Until then the app works for your own accounts and the testers you add in the console.