# Targeting

Target a Snapchat ad squad by location, radius, age, gender, language, interests, OS and audiences, and change it after launch.

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

Targeting sits on the ad squad. Send it on `POST /v1/ads/create`, flat or inside `targeting`, and change it later with `PUT /v1/ads/ad-sets/{adSetId}`.

## Targeting fields

| Field | Snapchat |
|-------|----------|
| `countries` | ISO 3166-1 alpha-2 codes |
| `regions`, `metros`, `zips` | Keys that carry their country, such as `US:5332921`, `US:807` or `US:90210`, from targeting search |
| `excludedLocations` | `countries`, `regions` and `zips` to leave out |
| `customLocations` | Radius circles (`latitude`, `longitude`, `radius`, `distanceUnit`), 96 m to 100 km, at most 500, inside a targeted country |
| `ageMin`, `ageMax` | `ageMin` from 13 to 35, `ageMax` from 13 to 55 |
| `gender` | `all`, `male` or `female` |
| `languages` | ISO 639-1 codes |
| `interests` | Snap Lifestyle Categories, `{ id, name }` from targeting search |
| `userOs` | `iOS`, `Android` |
| `audienceInclude`, `audienceExclude` | Ids of [Snap Audience Match lists](/platforms/snapchat-ads/audiences) |

Every ad squad needs at least one location: a country, region, metro or ZIP code.

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="Node.js">
```typescript
const { data: created } = await zernio.adcampaigns.createStandaloneAd({
  body: {
    accountId: '66b2e19d8c3f5a7e9d0b1c2d',
    adAccountId: '8f2c4a1e-3b5d-4c6e-9f7a-1b2c3d4e5f60',
    name: 'Spring drop 18-34',
    goal: 'traffic',
    status: 'PAUSED',
    budgetAmount: 20,
    budgetType: 'daily',
    headline: 'Spring plants, delivered',
    imageUrl: 'https://cdn.example.com/spring-drop-1080x1920.jpg',
    linkUrl: 'https://example.com/spring',
    targeting: {
      countries: ['US'],
      ageMin: 18,
      ageMax: 34,
      languages: ['en'],
      interests: [{ id: 'SLC_42', name: 'Home Decor Enthusiasts' }],
      userOs: ['iOS']
    }
  }
});
```
</Tab>
<Tab value="Python">
```python
created = client.ad_campaigns.create_standalone_ad(
    account_id="66b2e19d8c3f5a7e9d0b1c2d",
    ad_account_id="8f2c4a1e-3b5d-4c6e-9f7a-1b2c3d4e5f60",
    name="Spring drop 18-34",
    goal="traffic",
    status="PAUSED",
    budget_amount=20,
    budget_type="daily",
    headline="Spring plants, delivered",
    image_url="https://cdn.example.com/spring-drop-1080x1920.jpg",
    link_url="https://example.com/spring",
    targeting={
        "countries": ["US"],
        "ageMin": 18,
        "ageMax": 34,
        "languages": ["en"],
        "interests": [{"id": "SLC_42", "name": "Home Decor Enthusiasts"}],
        "userOs": ["iOS"],
    },
)
```
</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 18-34",
    "goal": "traffic",
    "status": "PAUSED",
    "budgetAmount": 20,
    "budgetType": "daily",
    "headline": "Spring plants, delivered",
    "imageUrl": "https://cdn.example.com/spring-drop-1080x1920.jpg",
    "linkUrl": "https://example.com/spring",
    "targeting": {
      "countries": ["US"],
      "ageMin": 18,
      "ageMax": 34,
      "languages": ["en"],
      "interests": [{ "id": "SLC_42", "name": "Home Decor Enthusiasts" }],
      "userOs": ["iOS"]
    }
  }'
```
</Tab>
</Tabs>

The response is the created ad, as in [Create ads](/platforms/snapchat-ads/create-ads#create-a-campaign).

## Find ids

`GET /v1/ads/targeting/search` looks up the ids these fields take ([Search ad targeting](/ad-targeting/search-ad-targeting)):

- `dimension=geo`: countries, plus regions and metros of a `countryCode` with `geoType=all`. ZIP codes are not searched: send them as `US:90210`.
- `dimension=interest`: the Lifestyle Categories of a `countryCode` (US by default).
- `dimension=language`: the language codes.

`POST /v1/ads/targeting/reach-estimate` sizes a targeting before you launch.

## Change targeting after creation

`PUT /v1/ads/ad-sets/{adSetId}` with `targeting` rewrites only the parts you send. `GET /v1/ads/ad-sets/{adSetId}/targeting` returns the ad squad's current targeting in the same fields.

```bash
curl -X PUT "https://zernio.com/api/v1/ads/ad-sets/6ae0968fa23091cc35b72190" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "targeting": { "countries": ["US", "CA"], "languages": ["en"] } }'
```

`countries`, `regions`, `metros` and `zips` are one list: sending any of them replaces all four. Snapchat sends the ad squad's ads back to review, which briefly pauses delivery.

## How it behaves

- More than one country needs exactly one language: that is Snapchat's rule for multi-country ad squads.
- A whole country cannot sit with regions, metros or ZIP codes inside it. Inside one country, pick one kind.
- Cities, income, behaviors, placements and device models are not available on Snapchat.
- A targeting edit is refused when the ad squad uses Snapchat criteria these fields cannot express, so nothing set in Ads Manager is dropped silently.

## If it fails

| Error | Cause | Fix |
|-------|-------|-----|
| `400` with `param: "countries"` | No location, or a country together with regions, metros or ZIP codes inside it | Send at least one location, one kind per country. |
| `400` with `param: "languages"` | Several countries without exactly one language | Send one language. |
| `400` with `param: "regions"`, `"metros"` or `"zips"` | A key without its `COUNTRY:` prefix | Use the key targeting search returns. |
| `400` with `param: "customLocations.radius"` | A radius under 96 m or over 100 km | Send a radius in that range. |
| `400` naming another field | A field Snapchat has no targeting for, such as `cities` | Remove it. |

## Related

- [Create ads](/platforms/snapchat-ads/create-ads): the rest of the create request.
- [Customer list audiences](/platforms/snapchat-ads/audiences): the lists `audienceInclude` takes.
- [Search ad targeting](/ad-targeting/search-ad-targeting): location, interest and language ids.