# Create ads

Create a Snapchat campaign with its ad squad and an image or video Snap Ad in one call, with goal, budget, bid and schedule.

import { Tab, Tabs } from 'fumadocs-ui/components/tabs';

`POST /v1/ads/create` uploads the creative to the ad account, then creates the campaign, its ad squad and the Snap Ad in one call.

## Create a campaign

Send `status: "PAUSED"` to create it paused. Without `status`, every level is switched on and the ad starts spending once Snapchat approves it.

<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: '8f2c4a1e-3b5d-4c6e-9f7a-1b2c3d4e5f60',
    name: 'Spring drop',
    goal: 'traffic',
    status: 'PAUSED',
    budgetAmount: 20,
    budgetType: 'daily',
    headline: 'Spring plants, delivered',
    businessName: 'North Supply',
    imageUrl: 'https://cdn.example.com/spring-drop-1080x1920.jpg',
    linkUrl: 'https://example.com/spring',
    callToAction: 'SHOP_NOW',
    countries: ['US']
  }
});

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

client = Zernio()

created = client.ad_campaigns.create_standalone_ad(
    account_id="66b2e19d8c3f5a7e9d0b1c2d",
    ad_account_id="8f2c4a1e-3b5d-4c6e-9f7a-1b2c3d4e5f60",
    name="Spring drop",
    goal="traffic",
    status="PAUSED",
    budget_amount=20,
    budget_type="daily",
    headline="Spring plants, delivered",
    business_name="North Supply",
    image_url="https://cdn.example.com/spring-drop-1080x1920.jpg",
    link_url="https://example.com/spring",
    call_to_action="SHOP_NOW",
    countries=["US"],
)

print(created["ad"]["id"])
```
</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": "8f2c4a1e-3b5d-4c6e-9f7a-1b2c3d4e5f60",
    "name": "Spring drop",
    "goal": "traffic",
    "status": "PAUSED",
    "budgetAmount": 20,
    "budgetType": "daily",
    "headline": "Spring plants, delivered",
    "businessName": "North Supply",
    "imageUrl": "https://cdn.example.com/spring-drop-1080x1920.jpg",
    "linkUrl": "https://example.com/spring",
    "callToAction": "SHOP_NOW",
    "countries": ["US"]
  }'
```
</Tab>
</Tabs>

Response (`201`), trimmed:

```json
{
  "ad": {
    "id": "6ae0968fa23091cc35b72188",
    "name": "Spring drop",
    "platform": "snapchat",
    "status": "paused",
    "adType": "standalone",
    "goal": "traffic",
    "budget": { "amount": 20, "type": "daily" },
    "platformAdId": "4c1d2e3f-5a6b-4c7d-8e9f-0a1b2c3d4e5f",
    "platformCampaignId": "7b8c9d0e-1f2a-4b3c-9d4e-5f6a7b8c9d0e",
    "platformAdSetId": "2e3f4a5b-6c7d-4e8f-9a0b-1c2d3e4f5a6b",
    "platformAdAccountId": "8f2c4a1e-3b5d-4c6e-9f7a-1b2c3d4e5f60"
  }
}
```

`budgetAmount` is in whole units of the ad account's currency: Zernio converts it to Snapchat's micro-currency. `platformAdSetId` is the Snapchat ad squad.

Campaign and ad squad names default to `<name> - Campaign` and `<name> - Ad Set`; send `campaignName` and `adSetName` to set them.

Every sample on the Snapchat Ads pages reuses the `zernio` and `client` constructors from this one. The `accountId` is the `snapchatads` account from [Connect](/platforms/snapchat-ads#connect).

## Goals

| `goal` | Snapchat objective | Optimizes for (first is the default) | Needs |
|--------|--------------------|---------------------------------------|-------|
| `awareness` | Awareness and engagement | `IMPRESSIONS` | `linkUrl` optional: without it the ad has no button |
| `engagement` | Awareness and engagement | `SWIPES` | `linkUrl` |
| `video_views` | Awareness and engagement | `VIDEO_VIEWS`, `VIDEO_VIEWS_15_SEC` | `video.url` |
| `traffic` | Traffic | `SWIPES`, `LANDING_PAGE_VIEW` | `linkUrl` |
| `conversions` | Sales | The pixel event in `promotedObject.customEventType` | `linkUrl` and a Snap Pixel |

Send `optimizationGoal` to pick another goal from that column. Any other `goal` returns `422`.

On `conversions`, `promotedObject.customEventType` is one of `PURCHASE`, `ADD_TO_CART`, `SIGN_UP` (or `COMPLETE_REGISTRATION`) and `PAGE_VIEW` (or `VIEW_CONTENT`). `promotedObject.pixelId` picks the Snap Pixel; without it, Zernio uses the ad account's first pixel.

## Creative

| Field | Rule |
|-------|------|
| `imageUrl` or `video.url` | One per ad, required. Images are JPEG or PNG up to 5 MB, videos up to 1 GB. Snap Ads are full screen, so use vertical 9:16 media |
| `headline` | Required, up to 34 characters |
| `businessName` | The brand name over the ad, up to 32 characters |
| `linkUrl` | The page a swipe up opens, `https` only |
| `callToAction` | The button: `LEARN_MORE` (the default), `SHOP_NOW`, `SIGN_UP`, `APPLY_NOW`, `BOOK_NOW`, `BUY_TICKETS`, `DONATE`, `DOWNLOAD`, `GET_OFFER`, `GET_QUOTE`, `GET_SHOWTIMES`, `LISTEN_NOW`, `ORDER_NOW`, `PLAY_GAME`, `SEE_MENU` or `WATCH_MORE` |
| `identityId` | The Snapchat profile shown as the advertiser; defaults to the organization's first |

Zernio uploads the file to the ad account and waits up to about a minute for Snapchat to process it before it creates the ad.

`body` is ignored: a Snap Ad has no body text.

## Budget, bid and schedule

The budget sits on the ad squad:

- `budgetType: "daily"` spends up to `budgetAmount` a day, at least 5 in the ad account's currency.
- `budgetType: "lifetime"` spends it over the whole flight and needs `endDate`.

Snapchat bids automatically unless you send `bidStrategy`:

| `bidStrategy` | Snapchat bid | Needs |
|---------------|--------------|-------|
| `LOWEST_COST_WITHOUT_CAP` (the default) | Auto bid | Nothing |
| `LOWEST_COST_WITH_BID_CAP` | Max bid: never above `bidAmount` per result | `bidAmount`, at least 0.01 |
| `COST_CAP` | Target cost: keeps the average cost per result near `bidAmount` | `bidAmount`; not with `IMPRESSIONS` or `VIDEO_VIEWS` |

`startDate` defaults to now, and `endDate` is optional on a daily budget.

## Other create shapes

- `existingCampaignId` adds a new ad squad and ad to a campaign you already run. The goal defaults to the campaign's.
- `adSetId` adds an ad to an existing ad squad, which keeps its own budget, schedule, targeting and pixel.
- `POST /v1/ads/campaigns` creates an empty campaign, with an optional spend cap of at least 20. `POST /v1/ads/ad-sets` creates an ad squad under it.

## How it behaves

- If the ad squad or the ad fails, Zernio deletes what the create made, so a failed create leaves no empty campaign behind.
- `status: "PAUSED"` pauses the top-most new object, so nothing in the new tree spends.
- Snapchat reviews every new ad: it reads `pending_review` until the review passes, and `rejected` if it fails.
- `validateOnly` returns `501`: Snapchat has no dry run.
- Targeting goes on the same request ([Targeting](/platforms/snapchat-ads/targeting)).

## If it fails

| Error | Cause | Fix |
|-------|-------|-----|
| `422` with `param: "goal"` | A goal Snapchat Ads does not take through Zernio | Send one of the goals in [Goals](#goals). |
| `400` with `param: "headline"` | No headline, or over 34 characters | Send a headline of 34 characters or fewer. |
| `400` with `param: "imageUrl"` | No creative | Send `imageUrl` or `video.url`. |
| `400` with `param: "video"` | `video_views` without a video | Send `video.url`. |
| `400` with `param: "linkUrl"` | A goal that needs a link without one, or a link that is not `https` | Send an `https` `linkUrl`. |
| `400` with `param: "budgetAmount"` | A daily budget under 5 | Raise it to at least 5. |
| `400` with `param: "endDate"` | A lifetime budget without an end date | Send `endDate`. |
| `422` with `param: "bidAmount"` | A max bid or target cost without `bidAmount`, or under 0.01 | Send `bidAmount`, or leave `bidStrategy` out for auto bid. |
| `400` with `param: "promotedObject.customEventType"` | `conversions` without a supported pixel event | Send one of the events in [Goals](#goals). |
| `422` with code `feature_not_available` | `conversions` on an ad account with no Snap Pixel | Create a pixel in Snapchat Ads Manager, then retry. |
| `400` with `param: "promotedObject.pixelId"` | The pixel is not in `adAccountId` | Use a pixel of that ad account. |

## Related

- [Create standalone ad](/ad-campaigns/create-standalone-ad): every field of the request.
- [Targeting](/platforms/snapchat-ads/targeting): who the ad squad reaches.
- [Manage ads](/platforms/snapchat-ads/manage-ads): pause, resume, rename, rebudget and delete.
- [Limits & errors](/platforms/snapchat-ads/reference): what Snapchat Ads does not support yet.