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

# Create ads

Create a standalone or website conversion campaign on TikTok in one call, and set its bid strategy.

Create a campaign, ad group and video ad in one `POST /v1/ads/create` call. To promote a video that is already live, see [Promote a post](/platforms/tiktok-ads/boost).

## Create a campaign

Call `POST /v1/ads/create`. TikTok's ads endpoint is video-only, so:

- the video URL goes in `imageUrl` (the field keeps its name for cross-platform consistency)
- `body` is the video caption
- `headline` is ignored, because TikTok creatives have no headline slot

Valid `goal` values are `engagement`, `traffic`, `awareness`, `video_views`, `lead_generation`, `conversions` and `app_promotion`.

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="Node.js">
```typescript
import Zernio from '@zernio/node';

const zernio = new Zernio();

const { data: created } = await zernio.adcampaigns.createStandaloneAd({
  body: {
    accountId: '66b2e19d8c3f5a7e9d0b1c2d',
    adAccountId: '7123456789012345678',
    name: 'Spring launch',
    goal: 'traffic',
    budgetAmount: 100,
    budgetType: 'daily',
    body: 'Spring drop is live',
    linkUrl: 'https://example.com/spring',
    imageUrl: 'https://cdn.example.com/launch.mp4',
    callToAction: 'SHOP_NOW',
    countries: ['US'],
    ageMin: 18,
    ageMax: 34
  }
});

console.log(created.ad.platformAdSetId);
```
</Tab>
<Tab value="Python">
```python
from zernio import Zernio

client = Zernio()

created = client.ad_campaigns.create_standalone_ad(
    account_id="66b2e19d8c3f5a7e9d0b1c2d",
    ad_account_id="7123456789012345678",
    name="Spring launch",
    goal="traffic",
    budget_amount=100,
    budget_type="daily",
    body="Spring drop is live",
    link_url="https://example.com/spring",
    image_url="https://cdn.example.com/launch.mp4",
    call_to_action="SHOP_NOW",
    countries=["US"],
    age_min=18,
    age_max=34,
)

print(created["ad"]["platformAdSetId"])
```
</Tab>
<Tab value="curl">
```bash
curl -X POST "https://zernio.com/api/v1/ads/create" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "accountId": "66b2e19d8c3f5a7e9d0b1c2d",
    "adAccountId": "7123456789012345678",
    "name": "Spring launch",
    "goal": "traffic",
    "budgetAmount": 100,
    "budgetType": "daily",
    "body": "Spring drop is live",
    "linkUrl": "https://example.com/spring",
    "imageUrl": "https://cdn.example.com/launch.mp4",
    "callToAction": "SHOP_NOW",
    "countries": ["US"],
    "ageMin": 18,
    "ageMax": 34
  }'
```
</Tab>
</Tabs>

Response (`201`):

```json
{
  "ad": {
    "_id": "66f0a1b2c3d4e5f6a7b8c9d1",
    "name": "Spring launch",
    "platform": "tiktok",
    "status": "pending_review",
    "adType": "standalone",
    "goal": "traffic",
    "platformAdId": "1802345678901234568",
    "platformCampaignId": "1802345678901234003",
    "platformAdSetId": "1802345678901234004"
  },
  "message": "Ad created"
}
```

`platformAdSetId` is the new TikTok ad group. Every sample in this folder reuses the `zernio` and `client` constructors from this one.

The targeting fields (`countries`, `ageMin`, `interests` and the rest) are listed in [Targeting fields](/platforms/tiktok-ads/targeting).

## Conversion campaigns

A website-conversion campaign needs a TikTok Pixel. Zernio maps `goal: "conversions"` to a `CONVERSIONS` objective with a `WEBSITE` / `CONVERT` ad group.

Without a pixel, TikTok rejects the ad group with `40002: Please select a pixel`.

Pass the pixel through `promotedObject`, the same cross-platform field Meta uses:

| `promotedObject` field | Maps to TikTok | Required |
|---|---|---|
| `pixelId` | ad group `pixel_id` (numeric) | Yes |
| `customEventType` | ad group `optimization_event` (the pixel event to optimise for) | No (auto-bid CONVERT works without it) |

`customEventType` takes a TikTok `optimization_event` code, or the exact event name shown in TikTok Events Manager.

Codes are TikTok's own UPPER_SNAKE codes, not Meta's `PURCHASE` or `LEAD` vocabulary and not PascalCase.

The value must be one of the events your pixel is configured to track. Common website codes:

| Code | Pixel event |
|---|---|
| `ON_WEB_ORDER` | Complete Payment |
| `INITIATE_ORDER` | Place an Order |
| `ON_WEB_CART` | Add to Cart |
| `ON_WEB_REGISTER` | Complete Registration |
| `ON_WEB_DETAIL` | View Content |
| `FORM` | Submit Form |
| `ON_WEB_SEARCH` | Search |
| `ON_WEB_ADD_TO_WISHLIST` | Add to Wishlist |
| `LANDING_PAGE_VIEW` | Landing Page View |

<Callout type="warn">
`pixelId` must be the numeric TikTok Pixel id, not the alphanumeric Pixel Code shown in Events Manager (for example `D00IKHRC77UE0J0RTNHG`). TikTok rejects the code with `40002: pixel_id ... is not a valid integer string`.
</Callout>

The numeric id is the `pixel_id` that TikTok's `GET /pixel/list/` returns.

If Ads Manager only shows the alphanumeric code for your pixel, [list your pixels](/platforms/tiktok-ads/tracking-tag). Each tag's `id` is the numeric id, and `siteTagId` is the code.

Find the pixel and the events it tracks in TikTok Ads Manager under Assets, then Events.

The request is the standalone create plus `promotedObject`:

```json
{
  "accountId": "66b2e19d8c3f5a7e9d0b1c2d",
  "adAccountId": "7123456789012345678",
  "name": "Spring launch, purchases",
  "goal": "conversions",
  "budgetAmount": 100,
  "budgetType": "daily",
  "body": "Spring drop is live",
  "linkUrl": "https://example.com/spring",
  "imageUrl": "https://cdn.example.com/launch.mp4",
  "callToAction": "SHOP_NOW",
  "countries": ["US"],
  "ageMin": 18,
  "ageMax": 34,
  "promotedObject": { "pixelId": "7987654321098765432", "customEventType": "ON_WEB_ORDER" }
}
```

**Existing conversion ad group.** If one exists in TikTok Ads Manager with the pixel and event configured, pass its id as `adSetId` on `POST /v1/ads/create` instead.

The new creative inherits the pixel and `optimization_event` from the parent ad group, so `promotedObject` is not needed ([Attach to an existing ad group](/platforms/tiktok-ads/manage-ads#attach-to-an-existing-ad-group)).

## Bid strategy

Pass `bidStrategy` (the cross-platform Meta enum) on `POST /v1/ads/boost`, `POST /v1/ads/create` or `PUT /v1/ads/ad-sets/{adSetId}`.

Zernio maps it to TikTok's `bid_type`, `bid_price` and `deep_bid_type`:

| `bidStrategy` | Maps to TikTok | Required field |
|---|---|---|
| `LOWEST_COST_WITHOUT_CAP` (default) | `bid_type: BID_TYPE_NO_BID` | none |
| `LOWEST_COST_WITH_BID_CAP` | `bid_type: BID_TYPE_CUSTOM` plus `bid_price` | `bidAmount` |
| `COST_CAP` | `bid_type: BID_TYPE_CUSTOM` plus `bid_price` | `bidAmount` |
| `LOWEST_COST_WITH_MIN_ROAS` | `bid_type: BID_TYPE_NO_BID` plus `deep_bid_type: VO_MIN_ROAS` and `roas_bid` | `roasAverageFloor` (the account must be value-optimization-enabled) |

`LOWEST_COST_WITH_MIN_ROAS` is TikTok's Value optimization with a Minimum ROAS goal. With `goal: "conversions"` Zernio creates the ad group with `optimization_goal: VALUE`.

Also send `promotedObject.pixelId` and a purchase event in `promotedObject.customEventType` (for example `SHOPPING`) that reports a value.

`roasAverageFloor` is sent as `roas_bid` (`2` is a 2.0x ROAS). TikTok refuses it on advertisers that don't have value optimization enabled.

`bidAmount` is in whole currency units of the ad account (USD: `5` is $5.00).

On reads (`GET /v1/ads/tree`, `GET /v1/ads/campaigns`), TikTok's native `bid_type` is normalized back to the same enum. Cross-platform consumers see one shape regardless of source platform.

## Add a video to a Smart+ ad group

To add one more creative to a Smart+ campaign that is already running, send `smartPlus: true` with the `adSetId` of its ad group (app-install campaigns included):

```json
{
  "accountId": "66b2e19d8c3f5a7e9d0b1c2d",
  "adAccountId": "7123456789012345678",
  "name": "New creative",
  "smartPlus": true,
  "adSetId": "1802345678901234004",
  "body": "Try the new editor",
  "imageUrl": "https://cdn.example.com/new-creative.mp4"
}
```

- `goal`, budget and `promotedObject` stay the campaign's, so leave them out.
- `linkUrl` is required unless the ad group promotes an app.
- `status: "PAUSED"` creates the ad without enabling it.
- An ad group of a regular campaign returns a `400` on `adSetId`. Attach to those without `smartPlus`.

## Validate before creating

`validateOnly: true` checks the request and creates nothing: no video upload, no Brand Identity, no campaign, ad group or ad.

TikTok has no dry-run of its own. Zernio runs the input checks a real create runs, then the read-only TikTok calls it makes:

- `identityId` is authorized on the advertiser
- `existingCampaignId` exists and is not an Upgraded Smart+ campaign
- the pixel and `customEventType` resolve on the advertiser
- the schedule and targeting build

A failure returns the same `4xx` a real create would. Success is `200`, and `message` names the identity the ad would run as and the budget, in the advertiser's currency when TikTok returns it:

```json
{
  "validateOnly": true,
  "results": [
    { "node": "identity", "status": "validated" },
    { "node": "campaign", "status": "unverified", "reason": "TikTok has no dry run, so it checks the new campaign (objective, BUDGET_MODE_INFINITE) only on a real create." },
    { "node": "adSet", "status": "unverified", "reason": "TikTok has no dry run. ..." },
    { "node": "creative", "status": "unverified", "reason": "The video is uploaded to the ad account library only on a real create, ..." },
    { "node": "ad", "status": "unverified", "reason": "TikTok reviews the ad text, call to action and landing page only after a real create." }
  ],
  "message": "Zernio ran the read-only checks a TikTok create runs (advertiser access, ad identity, pixel and optimization event, schedule, targeting); nothing was created or uploaded. The ad would run as identity 7330000000000000001 (BC_AUTH_TT). The ad group budget would be 50 USD per day. ..."
}
```

`unverified` nodes are what only TikTok checks, on a real create:

- the video: format, size, length and cover
- the ad group TikTok would build: the budget minimum for your currency, location and audience ids, bid
- a new campaign
- the review of the ad text, call to action and landing page

With `existingCampaignId` the `campaign` node is `validated`. Without `identityId` and with a `brandIdentity` to create, the `identity` node is `unverified`, because the Brand Identity is made only on a real create.

`validateOnly` covers the single standalone video ad. `smartPlus` and `adSetId` return `400`.

## Media requirements

| Type | Format | Max size | Notes |
|------|--------|----------|-------|
| Video | MP4, MOV, MPEG | 500 MB | 9:16 vertical, 720p or better, 5 to 60 seconds |
| Image | JPEG, PNG | 30 MB | 1080 x 1920 for full-screen |

Videos are fetched from the URL you pass. The [media uploads guide](/guides/media-uploads) covers hosting them on Zernio.

## If it fails

| Error | Cause | Fix |
|---|---|---|
| `422` with code `ads_connection_required` | No `tiktokads` account for the profile, or the TikTok user is not authorized as an Identity on the advertiser | [Connect](/platforms/tiktok-ads#connect) TikTok Ads, or authorize the identity in TikTok Ads Manager. |
| `40002: Please select a pixel` | `goal: "conversions"` without `promotedObject.pixelId` | Pass the numeric pixel id, or attach to an existing conversion ad group with `adSetId`. |
| `40002: pixel_id ... is not a valid integer string` | The alphanumeric Pixel Code was sent instead of the numeric id | Use the pixel's `id` from [the pixel list](/platforms/tiktok-ads/tracking-tag). |
| Budget rejected | Below TikTok's minimum | TikTok's minimum is $20 per ad set. |

## Related

- [Promote a post](/platforms/tiktok-ads/boost): Spark Ads from a video that is already live.
- [Targeting fields](/platforms/tiktok-ads/targeting): every targeting field the create takes.
- [Pixels](/platforms/tiktok-ads/tracking-tag): the numeric pixel id a conversion campaign needs.
- [Create standalone ad](/ad-campaigns/create-standalone-ad): every field of the request.