# YouTube

Connect a YouTube channel, schedule an MP4 upload and choose when Postdot can remove the source file.

URL: /docs/providers/youtube

An installation administrator sets up a Google OAuth application once. A project
member who manages a channel then authorizes the YouTube account in Studio.
Use a Google Cloud project you control and a Google account that can publish to
the intended YouTube channel.

## Set up the Google application [#set-up-the-google-application]

1. In Google Cloud Console, select or create a project and enable **YouTube Data
   API v3**. In **Google Auth Platform**, complete **Branding** and choose your
   **Audience**. For an **External** app in **Testing**, add the Google account
   that will connect the channel to **Test users**.
2. In **Data Access**, add the scopes `https://www.googleapis.com/auth/youtube.upload`
   and `https://www.googleapis.com/auth/youtube.readonly`. Postdot uses them to
   upload the file and verify the channel and video status.
3. In Postdot, open **Settings → Installation → Platforms**. Choose **Set up a
   platform**, select **YouTube** and copy the callback URL. It has the form
   `https://postdot.example/api/oauth/youtube/callback`. For a separate Studio
   deployment, use the API callback shown here.
4. In Google's **Clients** page, create a **Web application** client. Paste the
   exact URL into **Authorized redirect URIs**. For a remote installation, use
   HTTPS. Google checks the scheme, host, port and path against the registered
   URI, including any trailing slash.
5. In the Postdot form, enter Google's client ID and client secret, then save an
   **Active** application.

Refresh tokens issued for YouTube to an External app in Testing expire after
seven days. Reconnect before relying on a scheduled upload during testing.
For long-term use, check the verification requirements for your intended
audience.
[OAuth app states](https://developers.google.com/identity/protocols/oauth2/production-readiness/overview)
[Refresh token expiration](https://developers.google.com/identity/protocols/oauth2#expiration)

YouTube allocates 100 video insert calls per day to a project by default. Check
your allocation in Google Cloud. Requests for additional quota require a
YouTube API compliance audit. Public and unlisted uploads are available within
the default allocation, subject to YouTube account and video restrictions.
[YouTube quotas and audits](https://developers.google.com/youtube/data/guides/quota_and_compliance_audits)

## Connect the channel [#connect-the-channel]

Open **Channels**, add a **YouTube** channel and start the connection from that
channel. Sign in to Google, choose the intended YouTube channel if offered a
choice, and grant the requested access. Verify the connected channel shown in
Studio before scheduling. If Studio asks you to reconnect later, choose the
same YouTube channel.

## Schedule a video [#schedule-a-video]

1. Prepare a post and add the connected YouTube channel for **Automatic** delivery.
   Attach one MP4 with H.264 video. If it has an audio track, use AAC-LC. The
   default single-file limit is 100 MB. To allow larger files, the operator
   can raise `POSTDOT_MEDIA_MAX_OBJECT_BYTES` and match it in the
   [reverse proxy](/docs/reverse-proxy/). Upload a local file for videos over
   100 MB. URL imports retain their 100 MB limit.
2. On the YouTube channel tab, review the **Video title** and **Video description**.
   Under the channel options, select **Visibility** and answer **Made for kids**
   and **Altered or synthetic content**. Private is the default.
   **Category** defaults to People & Blogs.
   Turn on **Notify subscribers** if you want to send a notification.
3. Review the upload agreement and choose **I confirm for this video**. If you
   change the video or its publishing details, confirm again. Follow
   [your first publication](/docs/first-publication/) to schedule the post.
4. Inspect the result after the scheduled time. YouTube processes the video
   after transfer, and Postdot waits for confirmation of the channel and
   visibility. If Studio reports an uncertain delivery, check the connected
   channel in YouTube Studio before uploading another copy.

Use the same workflow for Shorts. YouTube classifies eligible square or
vertical videos up to three minutes as Shorts. Check the classification on
YouTube after processing.
[YouTube Shorts eligibility](https://support.google.com/youtube/answer/15424877)

Use [YouTube Studio](https://studio.youtube.com/) for Community posts, comments,
analytics and custom thumbnails. A [manual channel](/docs/first-publication/) can
record a delivery you complete in YouTube Studio.

## Keep or expire the source file [#keep-or-expire-the-source-file]

Postdot keeps uploaded videos in the media library by default. To free space
after a delivery, open the video's **Information** and enable **Move to trash
after publication**. An opted-in source becomes eligible after its YouTube
delivery is confirmed, all publications on that post have finished, and the
retention period has elapsed. Drafts, unfinished delivery and use by another
post can keep the file in the library.

An administrator sets the retention period in **Settings > General > Media
storage**, with `postdot settings media set --video-retention-days <days>`, the API
or MCP. The default is seven days from the last confirmed publication for the post;
`POSTDOT_TEMPORARY_VIDEO_RETENTION_DAYS` only sets the initial value. The separate `POSTDOT_MEDIA_DELETION_GRACE_MS` setting gives you time
to restore from trash before permanent deletion. By default, you have 24 hours.
Restoring an automatically trashed video turns off its automatic expiry. The
video on YouTube and the recorded delivery in Postdot survive source deletion.

Set an installation-wide [media upload budget](/docs/installation/#set-a-budget-for-media-uploads)
to limit originals across projects. Trash counts against this budget until the
file is permanently removed.
