> Documentation index: https://docs.zernio.com/llms.txt. Every page is also Markdown: add .md to its URL.

# Locations & music

Search TikTok locations and Commercial Music Library tracks and attach them to a post.

## Location tags

TikTok video posts can optionally attach a location tag (place).

First search for a location tag. Then send the chosen result’s `id` and `name` as `tiktokSettings.locationId` and `tiktokSettings.locationName` when creating the post.

TikTok returns up to 20 results. It fills the list with fuzzy matches when nothing matches closely, so an unrelated result does not mean the place is missing.

### Search locations

Call `GET /v1/accounts/{accountId}/tiktok/locations` with a `query` string.

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="curl">
```bash
curl "https://zernio.com/api/v1/accounts/66b2e19d8c3f5a7e9d0b1c2d/tiktok/locations?query=Barcelona" \
  -H "Authorization: Bearer $ZERNIO_API_KEY"
```
</Tab>
<Tab value="Node.js">
```javascript
import Zernio from '@zernio/node';

const zernio = new Zernio();

const { data } = await zernio.request({
  method: 'GET',
  path: '/v1/accounts/66b2e19d8c3f5a7e9d0b1c2d/tiktok/locations',
  query: { query: 'Barcelona' }
});

console.log(data.locations[0]);
```
</Tab>
<Tab value="Python">
```python
from zernio import Zernio

client = Zernio()

data = client.request(
    method="GET",
    path="/v1/accounts/66b2e19d8c3f5a7e9d0b1c2d/tiktok/locations",
    query={"query": "Barcelona"},
)

print(data["locations"][0])
```
</Tab>
</Tabs>

Response (`200`):

```json
{
  "locations": [
    {
      "id": "1234567890",
      "name": "Barcelona",
      "address": "Catalonia, Spain"
    }
  ]
}
```

### Attach a location to a post

Send both `locationId` and `locationName` in `tiktokSettings`.

<Callout type="warn">
Location tags are supported for accounts connected through the TikTok for Business app and video posts only. A developer-app account rejects the post at publish time, and a direct photo post is rejected at creation.
</Callout>

Location fields are ignored on drafts (`tiktokSettings.draft: true`), because TikTok ignores `post_info` fields in the Creator Inbox flow.

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="curl">
```bash
curl -X POST https://zernio.com/api/v1/posts \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Coffee stop before the show",
    "mediaItems": [
      {"type": "video", "url": "https://cdn.example.com/video.mp4"}
    ],
    "platforms": [
      {"platform": "tiktok", "accountId": "66b2e19d8c3f5a7e9d0b1c2d"}
    ],
    "tiktokSettings": {
      "privacy_level": "PUBLIC_TO_EVERYONE",
      "allow_comment": true,
      "allow_duet": true,
      "allow_stitch": true,
      "locationId": "1234567890",
      "locationName": "Barcelona",
      "content_preview_confirmed": true,
      "express_consent_given": true
    },
    "publishNow": true
  }'
```
</Tab>
<Tab value="Node.js">
```javascript
import Zernio from '@zernio/node';

const zernio = new Zernio();

const { data } = await zernio.posts.createPost({
  body: {
    content: 'Coffee stop before the show',
    mediaItems: [{ type: 'video', url: 'https://cdn.example.com/video.mp4' }],
    platforms: [{ platform: 'tiktok', accountId: '66b2e19d8c3f5a7e9d0b1c2d' }],
    tiktokSettings: {
      privacy_level: 'PUBLIC_TO_EVERYONE',
      allow_comment: true,
      allow_duet: true,
      allow_stitch: true,
      locationId: '1234567890',
      locationName: 'Barcelona',
      content_preview_confirmed: true,
      express_consent_given: true
    },
    publishNow: true
  }
});

console.log(data.post.platforms[0].status);
```
</Tab>
<Tab value="Python">
```python
from zernio import Zernio

client = Zernio()

published = client.posts.create_post(
    content="Coffee stop before the show",
    media_items=[{"type": "video", "url": "https://cdn.example.com/video.mp4"}],
    platforms=[{"platform": "tiktok", "accountId": "66b2e19d8c3f5a7e9d0b1c2d"}],
    tiktok_settings={
        "privacy_level": "PUBLIC_TO_EVERYONE",
        "allow_comment": True,
        "allow_duet": True,
        "allow_stitch": True,
        "locationId": "1234567890",
        "locationName": "Barcelona",
        "content_preview_confirmed": True,
        "express_consent_given": True,
    },
    publish_now=True,
)

print(published["post"]["platforms"][0]["status"])
```
</Tab>
</Tabs>

## Commercial Music Library (Business app accounts)

Accounts connected through the TikTok for Business app can attach a Commercial Music Library (CML) track to a post by setting `tiktokSettings.musicSoundInfo`.

Use this when you need a specific track (instead of `auto_add_music`).

`musicSoundInfo` is ignored on drafts (`tiktokSettings.draft: true`), because TikTok ignores `post_info` fields in the Creator Inbox flow.

### List trending tracks

Call `GET /v1/accounts/{accountId}/tiktok/commercial-music` to fetch the 100 currently trending CML tracks for the account.

The list is not paged. Use `countryCode` to select a country chart.

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="curl">
```bash
curl "https://zernio.com/api/v1/accounts/66b2e19d8c3f5a7e9d0b1c2d/tiktok/commercial-music?countryCode=ES" \
  -H "Authorization: Bearer $ZERNIO_API_KEY"
```
</Tab>
<Tab value="Node.js">
```javascript
import Zernio from '@zernio/node';

const zernio = new Zernio();

const { data } = await zernio.request({
  method: 'GET',
  path: '/v1/accounts/66b2e19d8c3f5a7e9d0b1c2d/tiktok/commercial-music',
  query: { countryCode: 'ES' }
});

console.log(data.tracks[0]);
```
</Tab>
<Tab value="Python">
```python
from zernio import Zernio

client = Zernio()

data = client.request(
    method="GET",
    path="/v1/accounts/66b2e19d8c3f5a7e9d0b1c2d/tiktok/commercial-music",
    query={"countryCode": "ES"},
)

print(data["tracks"][0])
```
</Tab>
</Tabs>

Response (`200`):

```json
{
  "tracks": [
    {
      "id": "7212345678901234567",
      "commercialMusicId": "7012345678901234567",
      "name": "Track Name",
      "artist": "Artist Name",
      "durationSec": 30,
      "genres": ["pop"],
      "previewUrl": "https://...",
      "thumbnailUrl": "https://...",
      "rank": 1,
      "clip": {
        "id": "7312345678901234567",
        "durationSec": 15,
        "previewUrl": "https://..."
      }
    }
  ]
}
```

### Attach a track to a post

Prefer `tracks[].clip.id` as `tiktokSettings.musicSoundInfo.musicSoundId` when creating a post. Fall back to `tracks[].id` only when the track has no `clip`.

Both ids publish. But posts published with the full-track `id` have shown viewers a sound page saying the song is not available in their country (observed from Germany, 2026-10-06).

The `clip.id` gave a working sound page for the same track.

<Callout type="warn">
Do not use `commercialMusicId` as `musicSoundId`. TikTok rejects it at publish time.
</Callout>

Optionally set track volume and trim points (video posts only).

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="curl">
```bash
curl -X POST https://zernio.com/api/v1/posts \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "New drop with a CML track",
    "mediaItems": [
      {"type": "video", "url": "https://cdn.example.com/video.mp4"}
    ],
    "platforms": [
      {"platform": "tiktok", "accountId": "66b2e19d8c3f5a7e9d0b1c2d"}
    ],
    "tiktokSettings": {
      "privacy_level": "PUBLIC_TO_EVERYONE",
      "allow_comment": true,
      "allow_duet": true,
      "allow_stitch": true,
      "musicSoundInfo": {
        "musicSoundId": "7312345678901234567",
        "musicSoundVolume": 50,
        "musicSoundStart": 0,
        "musicSoundEnd": 15000
      },
      "videoOriginalSoundVolume": 20,
      "content_preview_confirmed": true,
      "express_consent_given": true
    },
    "publishNow": true
  }'
```
</Tab>
<Tab value="Node.js">
```javascript
import Zernio from '@zernio/node';

const zernio = new Zernio();

const { data } = await zernio.posts.createPost({
  body: {
    content: 'New drop with a CML track',
    mediaItems: [{ type: 'video', url: 'https://cdn.example.com/video.mp4' }],
    platforms: [{ platform: 'tiktok', accountId: '66b2e19d8c3f5a7e9d0b1c2d' }],
    tiktokSettings: {
      privacy_level: 'PUBLIC_TO_EVERYONE',
      allow_comment: true,
      allow_duet: true,
      allow_stitch: true,
      musicSoundInfo: {
        musicSoundId: '7312345678901234567',
        musicSoundVolume: 50,
        musicSoundStart: 0,
        musicSoundEnd: 15000
      },
      videoOriginalSoundVolume: 20,
      content_preview_confirmed: true,
      express_consent_given: true
    },
    publishNow: true
  }
});

console.log(data.post.platforms[0].status);
```
</Tab>
<Tab value="Python">
```python
from zernio import Zernio

client = Zernio()

published = client.posts.create_post(
    content="New drop with a CML track",
    media_items=[{"type": "video", "url": "https://cdn.example.com/video.mp4"}],
    platforms=[{"platform": "tiktok", "accountId": "66b2e19d8c3f5a7e9d0b1c2d"}],
    tiktok_settings={
        "privacy_level": "PUBLIC_TO_EVERYONE",
        "allow_comment": True,
        "allow_duet": True,
        "allow_stitch": True,
        "musicSoundInfo": {
            "musicSoundId": "7312345678901234567",
            "musicSoundVolume": 50,
            "musicSoundStart": 0,
            "musicSoundEnd": 15000,
        },
        "videoOriginalSoundVolume": 20,
        "content_preview_confirmed": True,
        "express_consent_given": True,
    },
    publish_now=True,
)

print(published["post"]["platforms"][0]["status"])
```
</Tab>
</Tabs>