Agents × jobs · LangChain

Seed a music sound on TikTok with LangChain

Seed a TikTok sound from LangChain: many geo-targeted accounts posting with tiktok_sound_url on the same track, staggered dates, per-video analytics for…

Sound seeding from LangChain means getting a track used by many accounts in the launch market in the same week. TokPortal turns it into API calls: create_bundles_bulk opens the accounts in the country the label cares about, every slot's tiktok_sound_url points at the official sound page so the manager posts with that sound (volume fields let you balance original vs. added audio), dates are staggered, and list_account_video_analytics reports plays per post. Accounts are human-created and operated, so the wave reads as adoption rather than as one uploader.

Connect TokPortal to LangChain

LangChain is an agent framework (code): LangChain / LangGraph agents load MCP tools with langchain-mcp-adapters (MultiServerMCPClient).

pip install langchain-mcp-adapters langchain
from langchain_mcp_adapters.client import MultiServerMCPClient
from langchain.agents import create_agent

client = MultiServerMCPClient(
    {
        "tokportal": {
            "transport": "http",
            "url": "https://app.tokportal.com/api/ext/mcp",
            "headers": {"X-API-Key": "sk_..."},
        },
    }
)
tools = await client.get_tools()
agent = create_agent("anthropic:claude-sonnet-4-5", tools)
response = await agent.ainvoke(
    {"messages": "What is my TokPortal credit balance and how many bundles are published?"}
)

Only http and sse transports support headers; the stdio alternative is {"transport": "stdio", "command": "npx", "args": ["-y", "tokportal-mcp"], "env": {"TOKPORTAL_API_KEY": "sk_..."}}.

Snippet status: verified against LangChain's documentation (source).

Once connected, sanity-check the setup with a read-only call — "What is my TokPortal credit balance?" should trigger tokportal_get_credit_balance. Every tool runs as your TokPortal account and spends your credits; read-only tools (get_*, list_*, export_*) never do.

How it works

The unit that matters for a sound campaign is uses: distinct accounts posting with the sound. So the agent sizes accounts first — 20 to 50 is a typical first wave — with create_bundles_bulk in the target country (US, GB, BR, MX…), videos_per_account 2–3 so each account posts a couple of times during the week. Advanced Warming on music/dance/genre terms (generate_warming_terms from "bedroom pop fans, indie playlists") gives the accounts a plausible listening history before the drop.

Each video slot needs a clip (dance, lip-sync, POV, transition — the label usually supplies a brief and creatives), a caption and the sound. configure_bundle_video fields: video_url, description (caption with the artist's hashtags), target_publish_date (spread across the week, ≤3/day/bundle), tiktok_sound_url (the tiktok.com/music/... URL), and optionally volume_original_sound / volume_added_sound (0–200; using them costs 1 credit per video) when the clip's own audio must stay audible under the track. Add disclose_as_ads: true if it is a paid placement. Then publish_bundle for each bundle.

For measurement the agent reads list_account_video_analytics per account and export_analytics_videos for the whole wave; sound-level use counts live on TikTok's sound page, so the agent reports its own contribution (posts, views, likes per post) alongside. A second wave on the same accounts is just videos_only bundles with account_id.

Run it from LangChain

With LangChain the sequence is driven by your code: give the agent the tools from the TokPortal MCP server and the prompt below as the user message (or split it into tasks). Log every tokportal_* call and its arguments in development — the tool list is large (91 tools), so consider filtering to the ones this job needs.

Tool sequence

  1. tokportal_get_credit_costs — Accounts + slots + 1 credit per video using volume control.
  2. tokportal_generate_warming_terms — Genre/fan-culture terms so accounts look like listeners.
  3. tokportal_create_bundles_bulkplatforms:["tiktok"], country, accounts_count, videos_per_account, warming terms.
  4. tokportal_configure_bundle_account — Fan-style personas, not label handles.
  5. tokportal_configure_bundle_videotiktok_sound_url, volume_original_sound, volume_added_sound, description, date, video_url.
  6. tokportal_publish_bundle — Per bundle.
  7. tokportal_list_account_video_analytics — Views/likes per seeded post.
  8. tokportal_export_analytics_videos — Wave-level CSV for the label.

Prompt to paste

Use the TokPortal MCP tools. Sound: https://www.tiktok.com/music/Track-Name-7300000000000000000. Market: GB.
Plan a 20-account wave, 2 posts each between 2026-09-12 and 2026-09-18, clip audio at 30% under the track.
Quote it with get_credit_costs, create the fleet with create_bundles_bulk (external_ref "uk-single"),
and print the configure_bundle_video payload for bundle 1 / position 1 before running the rest.

Run inside an async context; log response["messages"] to see the tool calls and results.

REST equivalent (same operations, X-API-Key header, base URL https://app.tokportal.com/api/ext)

curl -X POST https://app.tokportal.com/api/ext/bundles/bulk \
  -H "X-API-Key: sk_..." -H "Content-Type: application/json" -H "Idempotency-Key: $(uuidgen)" \
  -d '{"platforms":["tiktok"],"country":"GB","accounts_count":30,"videos_per_account":2,
       "wants_advanced_warming":true,"advanced_warming_terms":["indie pop 2026","bedroom pop","new music friday"],
       "external_ref":"single-launch-uk"}'

curl -X PUT https://app.tokportal.com/api/ext/bundles/BUNDLE_ID/videos/1 \
  -H "X-API-Key: sk_..." -H "Content-Type: application/json" \
  -d '{"video_type":"video","description":"this bridge though 😭 #newmusic #indiepop","target_publish_date":"2026-09-12",
       "video_url":"https://.../pov-1.mp4",
       "tiktok_sound_url":"https://www.tiktok.com/music/Track-Name-7300000000000000000",
       "volume_original_sound":40,"volume_added_sound":100}'

Key parameters

ParameterValuesNotes
tiktok_sound_urltiktok.com/music/… URLManager posts with this sound.
volume_original_sound / volume_added_sound0–200Balance clip audio vs. track; 1 credit per video when used.
accounts_count1–100Distinct uses of the sound = distinct accounts.
target_publish_dateYYYY-MM-DDSpread across launch week; 3/day/bundle.
disclose_as_adsbooleanPaid placements.
external_ref≤200 charsCampaign tag for list_bundles.

Full schemas: OpenAPI reference · openapi.json.

Example configurations

30-account UK wave

{"platforms":["tiktok"],"country":"GB","accounts_count":30,"videos_per_account":2,"external_ref":"single-launch-uk"}

Slot with sound and mix

{"video_type":"video","description":"walking to this all week #indiepop","target_publish_date":"2026-09-13",
 "video_url":"https://pub-xxx.r2.dev/videos/walk-2.mp4",
 "tiktok_sound_url":"https://www.tiktok.com/music/Track-Name-7300000000000000000",
 "volume_original_sound":0,"volume_added_sound":100}

Second wave on delivered accounts

{"bundle_type":"videos_only","account_id":"ACCOUNT_UUID","videos_quantity":3,"title":"Wave 2"}

Credits

30 accounts × (32 + 2 × 2 + 2 × 1 volume) = 1 140 credits at standard rates for a 30-account, 2-post wave with volume control, plus warming targets at 5 each. Verify with get_credit_costs; see Credits & Pricing.

Why not the official API

The Content Posting API can attach nothing to a sound and cannot create the fan accounts a launch needs; it posts on audited apps to accounts users authorized, privately until audit, with per-token limits (6 requests/minute) and per-user daily caps. A sound launch is many accounts, one track, one week — the opposite shape.

As of August 2026 the first-party routes look like this. TikTok's Content Posting API (Direct Post) requires each account owner to authorize your app with the video.publish scope, limits every user access token to 6 requests per minute, keeps all posts from unaudited apps in private viewing mode until TikTok audits the app, and enforces an unpublished daily post cap per user (spam_risk_too_many_posts) that integrators commonly report at roughly 15–25 posts per account per day. Meta's Instagram Content Publishing API allows 100 API-published posts per professional account in a 24-hour moving window and only for accounts you own and connect via OAuth. Neither creates accounts, warms them, or reports third-party bans. TokPortal is human-operated infrastructure: accounts created and run by managers in the target country, one X-API-Key for all of them, dated slots (max 3 per day per bundle) instead of per-account tokens.

Sources: TikTok Content Posting API – Direct Post, TikTok Content Posting API – Get started, Instagram Platform – Content Publishing.

FAQ

Can the manager use the sound if the track is not on TikTok yet?

No — tiktok_sound_url must resolve to an existing sound page. Have the distributor deliver to TikTok first, then seed.

How do I keep the original clip audio audible?

Set volume_original_sound (e.g. 40) and volume_added_sound (e.g. 100); the manager applies the mix. It costs 1 credit per video.

Does TokPortal report total sound uses?

It reports what its accounts posted (views, likes, comments per video). Total uses are read from the sound page on TikTok; the agent can combine both.

Which countries make sense for music?

Whatever the release strategy says — list_countries shows what is open. Country picks the manager and device, so a BR wave is Brazilian accounts operated in Brazil.

Also works with

All 25 agents for "Seed a music sound on TikTok"

Other jobs with LangChain