- PostFast Home
- /
- API Guides
- /
- YouTube
- /
- playlists
How to Add YouTube Videos to Playlists via API
Schedule YouTube videos and Shorts to specific playlists using the PostFast API. Retrieve your playlist IDs and organize content programmatically.
When scheduling YouTube videos or Shorts through the PostFast API, you can automatically add them to a playlist after publishing. This helps organize your content and improve discoverability through playlist-based recommendations.
To add a video to a playlist, you need the playlist ID. Use the GET /social-media/{socialMediaId}/youtube-playlists endpoint to retrieve all playlists for your connected YouTube channel. Then include the playlistId value in the youtubePlaylistId control when creating your post.
Important: The video publishes first, then gets added to the playlist as a secondary operation. If the playlist addition fails (wrong ID, playlist full, etc.), the video is still live on your channel.
API Parameters
| Parameter | Type | Description |
|---|---|---|
youtubePlaylistId | string | YouTube playlist ID to add the video to after publishing. Get available playlists from GET /social-media/{socialMediaId}/youtube-playlists and use the playlistId field. |
youtubeIsShort | boolean | Whether it's a YouTube Short |
youtubeTitle | string | Video title. If not provided, the first 100 characters of content will be used |
youtubePrivacy | string | Video privacy setting PUBLICUNLISTEDPRIVATE |
Code Example
const response = await fetch('https://api.postfa.st/social-posts', {
method: 'POST',
headers: {
'pf-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"posts": [
{
"content": "Part 3 of my React hooks series! Today we cover useCallback and useMemo ⚛️\n\nTimestamps:\n0:00 - useCallback basics\n0:45 - When to use useCallback\n1:30 - useMemo explained\n2:15 - Performance tips\n\n#reactjs #webdev #programming",
"mediaItems": [
{
"key": "video/b3c4d5e6-f7a8-9012-3456-789012bcdefg.mp4",
"type": "VIDEO",
"sortOrder": 0
}
],
"scheduledAt": "2025-01-31T14:00:00.000Z",
"socialMediaId": "880a1722-b5ce-64a7-d049-778988772004"
}
],
"controls": {
"youtubePlaylistId": "PLrAXtmErZgOeiKm4sgNOknGvNjby9efdf",
"youtubeIsShort": true,
"youtubeTitle": "React Hooks: useCallback & useMemo Explained",
"youtubePrivacy": "PUBLIC"
}
})
});
const data = await response.json();
Did You Know?
Tips
First call GET /social-media/{socialMediaId}/youtube-playlists to get your playlist IDs, then cache them - they rarely change
Organize Shorts into themed playlists (tips, tutorials, behind-the-scenes) for better channel structure
Playlist addition happens after video processing, so there may be a short delay before it appears in the playlist
Use playlists to create content series that viewers can binge-watch
If you create a new playlist on YouTube, sync it in the PostFast dashboard (Accounts → your YouTube account → Sync Playlists)
Schedule videos to YouTube with automatic playlist organization
Common Pitfalls
Make sure you use the playlistId field from the API response (e.g., "PLrAXtmErZgOeiKm4sgNOknGvNjby9efdf"), not the internal id field.
The playlist must belong to the same YouTube channel you're posting to. You cannot add videos to playlists from other channels.
Playlist addition happens after the video is fully processed. For long videos, there may be a delay before it appears in the playlist.
The video publishes even if playlist addition fails. Check your YouTube Studio to confirm the video was added to the playlist.
Frequently Asked Questions
How do I get my YouTube playlist IDs?
Call GET /social-media/{socialMediaId}/youtube-playlists with your YouTube account's socialMediaId. This returns all your playlists with their playlistId values (like "PLrAXtmErZgOeiKm4sgNOknGvNjby9efdf"). Use the playlistId field when setting youtubePlaylistId.
Can I add a video to multiple playlists?
The API supports adding to one playlist via youtubePlaylistId. To add to multiple playlists, you'll need to use YouTube Studio manually or the YouTube Data API separately after publishing.
What happens if the playlist addition fails?
The video still publishes successfully to your channel. Playlist addition is a secondary operation - if it fails (wrong ID, playlist full, etc.), the video is still live. Check YouTube Studio to confirm.