Use the YouTube Data API v3 playlistItems.update method to move a video within a playlist from Bash. The script needs OAuth authorization, the playlist-item ID (not just the video ID), and a playlist set to Manual ordering. YouTube playlist editing is separate from Live Streaming API controls: changing a playlist does not itself change a live broadcast.
What the script changes—and what it does not
YouTube’s playlistItems methods manage playlist contents: list, insert, update, and delete. To reorder an existing video, update its playlist-item resource. A playlist-item identifies a video’s occurrence in a particular playlist; the video ID identifies the video itself. A video can therefore have a different playlist-item ID in each playlist.
Live broadcast and stream operations belong to the separate YouTube Live Streaming API. Do not use liveBroadcasts.update as a playlist-edit endpoint. The playlist-item update request changes playlist order; it does not change what a running broadcast is currently playing.
What you need before running a Bash request
- A Google Cloud project with the YouTube Data API v3 enabled and an OAuth client configured for an application that can obtain user authorization.
- An OAuth access token authorized to manage the target playlist. The update method accepts scopes including
https://www.googleapis.com/auth/youtubeandhttps://www.googleapis.com/auth/youtube.force-ssl. Use a token for an account that can edit that playlist. - The playlist ID, the video ID, the playlist-item ID for that video in that playlist, and the zero-based position you want.
curlandjqavailable in your shell if you use the examples below.
Keep access tokens out of scripts committed to source control, terminal transcripts, and shared logs. The examples assume you already have an authorized token in the YOUTUBE_ACCESS_TOKEN environment variable; obtaining OAuth consent and refreshing tokens depend on your application’s OAuth setup.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Find the playlist item and its current position
First get the playlist ID, then list its items and locate the target video. The API’s playlist implementation guide describes retrieving playlist information before updating an item. For a small playlist, a single page may be sufficient; for a larger one, follow the response’s nextPageToken until you have checked every page.
Example list request:
export YOUTUBE_ACCESS_TOKEN='YOUR_OAUTH_ACCESS_TOKEN'
PLAYLIST_ID='YOUR_PLAYLIST_ID'
VIDEO_ID='YOUR_VIDEO_ID'
curl --fail-with-body --silent --show-error --get
'https://www.googleapis.com/youtube/v3/playlistItems'
--data-urlencode 'part=snippet'
--data-urlencode "playlistId=$PLAYLIST_ID"
--data-urlencode 'maxResults=50'
--header "Authorization: Bearer $YOUTUBE_ACCESS_TOKEN"
--header 'Accept: application/json'
| jq -r --arg video "$VIDEO_ID"
'.items[] | select(.snippet.resourceId.videoId == $video) | {playlistItemId: .id, videoId: .snippet.resourceId.videoId, position: .snippet.position}'
The important value in the result is playlistItemId. Use the item’s id for the update; do not substitute VIDEO_ID. If the video does not appear, check that the playlist ID is correct, that you listed all pages, and that the authorized account can access the playlist. A video may occur more than once, so choose the specific occurrence you intend to move.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Set the playlist to Manual ordering
An explicit snippet.position requires the playlist’s Ordering setting to be Manual. In YouTube Studio, open the playlist and use its ordering control to select Manual before making a position update. Automatically sorted playlists may reject a requested position with a manual-sort error. The playlist update API reference also documents the ordering setting.
Move the item with playlistItems.update
The update endpoint is PUT https://www.googleapis.com/youtube/v3/playlistItems. Set the target index to a zero-based number: 0 is the first position, 1 the second, and so on. YouTube’s documented request structure includes the playlist-item ID, playlist ID, video resource ID, and position.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Build the update body from the item returned by the list request so the identifiers correspond to the exact occurrence being changed. For example, this Bash adaptation moves the selected item to the first position:
PLAYLIST_ITEM_ID='THE_PLAYLIST_ITEM_ID_FROM_THE_LIST_RESPONSE'
TARGET_POSITION=0
jq -n
--arg itemId "$PLAYLIST_ITEM_ID"
--arg playlistId "$PLAYLIST_ID"
--arg videoId "$VIDEO_ID"
--argjson position "$TARGET_POSITION"
'{id: $itemId,
snippet: {
playlistId: $playlistId,
resourceId: {kind: "youtube#video", videoId: $videoId},
position: $position
}}'
| curl --fail-with-body --silent --show-error
--request PUT
'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet'
--header "Authorization: Bearer $YOUTUBE_ACCESS_TOKEN"
--header 'Accept: application/json'
--header 'Content-Type: application/json'
--data-binary @-
| jq '{id, playlistId: .snippet.playlistId, videoId: .snippet.resourceId.videoId, position: .snippet.position}'
This is an example assembled from the documented HTTP API contract, not a claim that the code has been run or tested. A successful response should identify the updated playlist item and its resulting position. List the playlist again if you need to verify the resulting order from YouTube’s current response.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Preserve fields when updating
Updates need care because the selected part identifies mutable properties being updated. If you send a part but omit mutable values within it, those omitted values may be reset or deleted. The example includes the identifiers and position needed for the documented update; if your application relies on other mutable snippet values, retrieve and preserve the values that must remain before sending the update. Do not blindly reuse a partial request body for unrelated changes.
Automate repeated changes safely
For a one-time move, run the list-and-update sequence manually. For recurring automation, keep configuration separate from code and resolve the current playlist-item ID at run time rather than assuming it never changes.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
- Store the playlist ID, video ID, and intended zero-based position in a configuration file or environment variables.
- Obtain or refresh an OAuth token through your application’s approved OAuth flow; do not treat a short-lived access token as permanent.
- List the playlist items, following pagination as needed, and match both the playlist and video to find the correct playlist-item ID.
- Check that the playlist is manually ordered and that the requested position is valid for the current playlist.
- Send the update, inspect the HTTP status and API response, and log a concise result without logging the bearer token.
- On failure, stop and report the API error instead of repeatedly resending the same mutation without resolving its cause.
Google’s current method reference lists quota costs of 1 unit for playlistItems.list and 50 units per playlistItems.update, playlistItems.insert, or playlistItems.delete call. These are documented API quota costs, not a guarantee of your project’s quota allocation; check Google’s current quota documentation before building a high-volume job.
Troubleshoot common failures
- Manual-sort error: The playlist’s Ordering setting is not Manual. Change its ordering to Manual and retry.
- Item not found or inaccessible: Confirm that you used the playlist-item ID for this occurrence, not the video ID, and that the OAuth account can manage the playlist.
- Invalid position: Use a zero-based index within the playlist’s valid range and confirm the item is still present. If the playlist changed since it was listed, retrieve its current contents and recalculate.
- Authorization or scope error: Reauthorize the account with an accepted YouTube scope and confirm the account has permission to edit the playlist. A valid token without sufficient access is not enough.
- Unexpected metadata change: Review the fields sent in the selected
part; omitted mutable values can be reset or deleted. Fetch and preserve values your workflow needs. - Quota exhaustion: Reduce unnecessary list and update calls, paginate carefully, and check the project’s quota status. Updating every item individually can consume substantially more quota than a single update.
- Playlist changes but live playback does not: Playlist ordering and live broadcast state are separate API concerns. An update to a playlist item is not a command to switch the current content of a running broadcast.
Or let it run in the cloud
If the larger goal is keeping uploaded videos live on YouTube around the clock, StreamNeo is a cloud option rather than a Bash playlist-editing tool. Upload a recording or build a playlist, add your YouTube stream key, and go live. Nothing has to stay on at home; it streams the uploads as made, up to 4K 60fps, at one price per slot, and can recover automatically if YouTube drops the stream. The first day is free with no card. Monthly is $9.99 per month. StreamNeo is for YouTube uploads and playlists, not camera-based live streaming. Learn about StreamNeo, or start the free first day.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

