Adding music to TikTok posts through the API
TikTok's API for Business adds music from its Commercial Music Library: post_info.music_sound_info takes a track's music_sound_id on video and photo posts, and on videos also the track's volume, its start and end in milliseconds and the volume of the video's own sound. Photo posts can also take auto_add_music for recommended music. Track IDs come from GET /discovery/cml/trending_list/.
easyCoexistence's publish_tiktok_post posts TikTok videos and photo posts, sending no music fields, so a video keeps the soundtrack mixed into its file.
Most popular tracks /discovery/cml/trending_list/ returns, all pre-cleared for organic content and ad creation.
Range of music_sound_volume and video_original_sound_volume; through the API both default to 0, while the TikTok app starts at 50.
Songs in TikTok's Commercial Music Library, the pre-cleared global library businesses use for commercial activity on TikTok.
Where creatives made with music from TikTok's ads music list may be served, unless the rights holders give separate permission.
The only post_mode in which the Content Posting API's photo endpoint applies auto_add_music, on developers.tiktok.com.
Which music fields do TikTok's publish endpoints take?
Both endpoints carry music inside post_info, under music_sound_info, and name a track by its Commercial Music Library ID. Beyond that they differ: the video endpoint adds mixing controls, and the photo endpoint adds a switch that lets TikTok pick the music. Side by side, as TikTok's references list them:
| Video post | Photo post | |
|---|---|---|
| The track | music_sound_info.music_sound_id | music_sound_info.music_sound_id |
| Track volume | music_sound_volume, 0 to 100, required with a track | No field |
| Part of the track | music_sound_start and music_sound_end, in milliseconds | No field |
| The video's own sound | video_original_sound_volume, 0 to 100 | Not applicable |
| Recommended music | No field | auto_add_music, false by default |
| As a draft | upload_to_draft drops the rest of post_info | is_draft keeps only the title and caption |
How do you add a track to a video?
Send music_sound_info inside post_info on POST /business/video/publish/. Once the object is there, music_sound_id and music_sound_volume are required. music_sound_start and music_sound_end choose the part of the track in milliseconds, from the track's beginning to the video's full length by default, so a 2-second video takes the track's first 2,000 milliseconds. Set video_original_sound_volume too whenever the video's own audio matters, since it defaults to 0:
curl -X POST 'https://business-api.tiktok.com/open_api/v1.3/business/video/publish/' \
-H 'Access-Token: <ACCESS_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"business_id": "<OPEN_ID>",
"video_url": "https://media.example.com/tiktok/launch.mp4",
"post_info": {
"caption": "Our new blend is here #coffee",
"is_brand_organic": false,
"is_branded_content": false,
"music_sound_info": {
"music_sound_id": "<SONG_CLIP_ID>",
"music_sound_volume": 40,
"music_sound_start": 15000,
"music_sound_end": 30000,
"video_original_sound_volume": 80
}
}
}'Where do track IDs come from?
From GET /discovery/cml/trending_list/, a Discovery API endpoint that takes a TikTok account's access token and business_id, where the Discovery hashtag endpoints take an advertiser's; TikTok's reference files it under the Discovery permission of Creative Management. It returns up to 100 popular tracks, each with its name, artist, duration, rank, genres, a preview_url that does not expire and up to 30 days of trending_history. full_duration_song_clip and trending_song_clip each hold a song_clip_id, the value TikTok names for music_sound_id:
- genre: ALL by default, or one of over 100 values such as POP, LATIN, LO-FI or SERTANEJO.
country_code: US by default.date_range: 1DAY, 7DAY by default, 30DAY or 90DAY.- /discovery/cml/
video_list/: the top 20 trending videos that use a track, by itscommercial_music_idand acountry_code.
curl -G 'https://business-api.tiktok.com/open_api/v1.3/discovery/cml/trending_list/' \
-H 'Access-Token: <ACCESS_TOKEN>' \
--data-urlencode 'business_id=<OPEN_ID>' \
--data-urlencode 'genre=POP' \
--data-urlencode 'country_code=BR' \
--data-urlencode 'date_range=7DAY'How do photo posts get music?
Two ways on POST /business/photo/publish/. auto_add_music set to true has TikTok add recommended music, which the owner can change later in the TikTok app; music_sound_info.music_sound_id names a specific library track, with no volume, start or end fields on photos. On developers.tiktok.com, the Content Posting API's photo endpoint has its own auto_add_music, applied only when post_mode is DIRECT_POST, and its direct-post video endpoint documents no music field.
What does the Commercial Music Library mean for business accounts?
It is the music they may use. TikTok's Business Help Center describes the library as a pre-cleared global collection of 1 million songs, says businesses cannot use the general music library for commercial use, and points them to the Commercial Music Library for organic content, duets, reacts and stitches included, video ads and branded content. On a Business Account, Add Sound in the app shows library sounds only, and the API draws the same line, since music_sound_id takes a library ID.
What can't the API do with music?
A few things sit outside its fields, as TikTok's references describe them:
- Name a sound from TikTok's general library:
music_sound_idtakes a Commercial Music Library ID. - Search the library by title: /discovery/cml/
trending_list/ filters popular tracks by genre, country and period. - Keep music on a draft:
upload_to_draftmakes TikTok ignore the rest ofpost_info, andis_draftkeeps only the title and caption. - Use your own track in an organic post: /file/music/upload/ adds music for ad creatives under an
advertiser_id, and TikTok's notice there leaves copyright responsibility with the uploader.
What are the workarounds?
Three, each built on what TikTok's references document, plus one risk to weigh:
- Mix the music into the file. TikTok's constraints describe the video as audio-video content, so a soundtrack mixed in goes out with it; use audio you hold the rights to.
- Send a draft. With
upload_to_draftoris_draftand the video.upload scope, the post lands in the creator's TikTok inbox, to edit and post in the app. - Let TikTok choose on photo posts.
auto_add_musicadds recommended music, and the owner can swap it in the TikTok app later. - The risk with mixed audio: TikTok's post list reference names music copyright violations among the likely reasons a post is filtered out.
How do you see whether a sound brought views?
Through impression_sources, a /business/video/list/ field that ranks where a post's viewers found it; one of its values is Sound, for views that came from sound pages. It needs the video.insights scope and, like the other counts, lands 24 to 48 hours late. Through easyCoexistence, get_social_insights returns it for one of the account's 20 most recent posts when impression_sources is named in metrics, with the post's item_id as object_id.
What does easyCoexistence do with music?
It publishes the sound already in your file. publish_tiktok_post, now or with scheduled_at, sends the caption, a photo post's title and the comment setting, with no music_sound_info and no auto_add_music, so a video keeps its own soundtrack and a photo post goes out without music. Your own code can POST to business/video/publish/ with music_sound_info and the token from get_social_credentials, but that body reaches TikTok as written, video_url included, and TikTok fetches media only from domains or URL prefixes verified for the app. /discovery/ paths take an advertiser's token, so the track list is out of the account token's reach.
Common mistakes
- Leaving video_original_sound_volume out when adding a track. Through the API it defaults to 0, while the TikTok app starts both sounds at 50, so set it whenever the video's own audio matters.
- Passing a track's name or preview_url as music_sound_id. TikTok's track reference names song_clip_id, from full_duration_song_clip or trending_song_clip, as the value to pass.
- Calling /discovery/cml/trending_list/ with an advertiser token. The track endpoints take a TikTok account's token and business_id, as the Accounts API does.
- Reading a duration of 0 as a broken track. TikTok notes that a track that is only a clip of a longer piece may show 0, so check its preview before choosing start and end.
easyCoexistence publishes TikTok videos and photo posts with publish_tiktok_post from Claude, ChatGPT or your own code, now or at a set time up to 90 days ahead, and a video goes out with the soundtrack mixed into its file. US$ 9 to US$ 0.75 per connection per month, falling as you add connections, with the first 3 days free.
easyCoexistence is a multichannel API and MCP server that connects AI agents such as Claude and ChatGPT to WhatsApp, Instagram, TikTok, Facebook and more. On WhatsApp it uses Coexistence: the business keeps using its number in the WhatsApp Business app while the AI works through Meta's official API.
Frequently asked questions
Can I add any song to a TikTok post through the API?
Songs in the Commercial Music Library, by ID. Music already mixed into a video file goes out with the file, so it should be music you have the rights to use.
What volume does TikTok's API set for added music?
0 by default. music_sound_volume and video_original_sound_volume run from 0 to 100 and both default to 0 through the API, while the TikTok app starts at 50, so set them on each video with a track.
Does a post's music matter if the post is later used in an ad?
TikTok checks it: /identity/music/authorization/ reports, for the ad's locations and run dates, whether the post's music is fully authorized, missing authorization or without a song ID.
How many songs are in TikTok's Commercial Music Library?
1 million, by TikTok's Business Help Center, all pre-cleared for commercial use. /discovery/cml/trending_list/ returns up to 100 popular ones at a time.
Keep reading
Connect your first channel in two minutes.
No platform reviews to wait for. Connect WhatsApp, Instagram, TikTok or another channel, then ask your AI to post, reply or report, and watch it work.
- 3 days free
- Cancel any time
- Official APIs only
- Monitored 24/7
Verified on