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

# Targeting

Target LinkedIn ads by country, region and the B2B facets (industry, company size, seniority, job function, title, skill), look up LinkedIn's ids, and change a running campaign's audience.

By the end of this page, a LinkedIn ad reaches the professional audience you describe, and you can change that audience once it runs.

## Before you start

You need a `linkedinads` [account](/platforms/linkedin-ads#connect) and the create call from [Create a campaign](/platforms/linkedin-ads/create-ads).

## Targeting fields

`countries: ['US']` is the minimum LinkedIn accepts.

The professional facets are what LinkedIn Ads are bought for. They go in a nested `targeting` object on `POST /v1/ads/create`, the same spec [Bid pricing and forecasts](/platforms/linkedin-ads/planning) prices and sizes before you spend:

```json
{
  "targeting": {
    "countries": ["US", "GB"],
    "industries": ["4"],
    "companySizes": ["D", "E", "F"],
    "seniorities": ["4", "5"],
    "jobFunctions": ["8"]
  }
}
```

| Field | Value | Matched as |
|---|---|---|
| `countries` | ISO 3166-1 alpha-2 codes | LinkedIn geo URNs |
| `regions` | `[{ "key": ... }]`, each key a `urn:li:geo:*` URN from the [search](#look-up-linkedin-ids) | The same locations facet as `countries` |
| `industries` | Industry id fragments | `urn:li:industry:{id}` |
| `companySizes` | Staff-count codes (below) | `urn:li:staffCountRange:{range}` |
| `seniorities` | Seniority id fragments | `urn:li:seniority:{id}` |
| `jobFunctions` | Function id fragments | `urn:li:function:{id}` |
| `jobTitles` | Title id fragments or `urn:li:title:*` URNs from `GET /v1/ads/targeting/search?dimension=jobTitle` | `urn:li:title:{id}` |
| `skills` | Skill id fragments, or `urn:li:skill:*` URNs from the search (`python` finds `urn:li:skill:1346`) | `urn:li:skill:{id}` |
| `interests` | `[{ "id": ... }]`, each id a URN from the search | The interests facet |
| `behaviors` | `[{ "id": ... }]`, each id a `urn:li:memberBehavior:*` URN from the search, such as Frequent Travelers, Job Seekers or Recently Promoted | The member behaviors facet |
| `audienceInclude`, `audienceExclude` | Segment ids from [`GET /v1/ads/audiences`](/platforms/linkedin-ads/audiences) | `urn:li:adSegment:{id}` |
| `excludedLocations.countries` | ISO 3166-1 alpha-2 codes | The exclude clause |

A full URN passes through unchanged wherever an id fragment is accepted, so a value straight out of LinkedIn's own tooling works as it is.

`companySizes` takes a letter per staff-count range:

| Code | Staff |
|---|---|
| `A` | 1 |
| `B` | 2 to 10 |
| `C` | 11 to 50 |
| `D` | 51 to 200 |
| `E` | 201 to 500 |
| `F` | 501 to 1,000 |
| `G` | 1,001 to 5,000 |
| `H` | 5,001 to 10,000 |
| `I` | 10,001 and above |

Other facets map to LinkedIn's own:

- `ageMin` / `ageMax` round out to LinkedIn's age buckets: 18-24, 25-34, 35-54, 55+. Nothing under 18.
- `gender` maps to LinkedIn's gender facet.
- `languages` (ISO 639-1) maps to its interface locale, one per language (default English).

## Rules LinkedIn enforces

3 rules decide whether the request survives:

- LinkedIn requires at least one location. Send none and the ad targets the United States.
- `jobTitles` cannot be combined with `seniorities` or `jobFunctions`. LinkedIn rejects the whole ad, so on create and boost Zernio returns a `400` with code `mutually_exclusive_fields` first. On a targeting update, LinkedIn returns the error.
- `cities`, `zips`, `metros`, `customLocations`, `incomeTier` and Meta's work facets return a `400` with code `invalid_field_value` naming the field. LinkedIn's Marketing API has no equivalent.

<Callout type="warn">A country code outside the 45 Zernio maps returns `400` `invalid_field_value` with `param` `countries`. Only a request with no location at all falls back to the United States.</Callout>

## Look up LinkedIn ids

Call `GET /v1/ads/targeting/search` with `accountId`, `q` and `dimension`. On LinkedIn, `dimension` takes `geo`, `interest`, `behavior`, `industry`, `jobFunction`, `jobTitle`, `seniority`, `companySize` and `skill`.

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

const zernio = new Zernio();

const { data: search } = await zernio.adtargeting.searchAdTargeting({
  query: {
    accountId: '66b2e19d8c3f5a7e9d0b1c2d',
    q: 'python',
    dimension: 'skill'
  }
});

const skillUrn = search.results[0].id;
```
</Tab>
<Tab value="Python">
```python
from zernio import Zernio

client = Zernio()

search = client.ad_targeting.search_ad_targeting(
    account_id="66b2e19d8c3f5a7e9d0b1c2d",
    q="python",
    dimension="skill",
)

skill_urn = search["results"][0]["id"]
```
</Tab>
<Tab value="curl">
```bash
curl "https://zernio.com/api/v1/ads/targeting/search?accountId=66b2e19d8c3f5a7e9d0b1c2d&q=python&dimension=skill" \
  -H "Authorization: Bearer $ZERNIO_API_KEY"
```
</Tab>
</Tabs>

Response (`200`):

```json
{
  "results": [
    { "id": "urn:li:skill:1346", "name": "Python", "type": "skill" }
  ]
}
```

The B2B dimensions return the full URN to pass straight back, such as `urn:li:industry:4` or `urn:li:staffCountRange:(51,200)`.

Only `industry`, `jobTitle` and `skill` are name searches on LinkedIn's side. For job functions, seniorities and company sizes, Zernio fetches LinkedIn's whole table and matches `q` itself.

A `geo` search returns every matching level in one list, and LinkedIn ignores `geoType` and `countryCode`.

A country comes back with `type: country` and its ISO code as `id`. Every other place is `type: region`, with a `urn:li:geo:*` URN for `regions[].key`.

## Change a running campaign

Send `targeting` on `PUT /v1/ads/{adId}`. Zernio writes it to the ad's LinkedIn Campaign, so it applies to every creative in that Campaign.

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="Node.js">
```typescript
const { data: updated } = await zernio.adcampaigns.updateAd({
  path: { adId: '66f0a1b2c3d4e5f6a7b8c9d0' },
  body: {
    targeting: {
      countries: ['US', 'GB'],
      seniorities: ['5', '6'],
      companySizes: ['E', 'F', 'G']
    }
  }
});
```
</Tab>
<Tab value="Python">
```python
updated = client.ad_campaigns.update_ad(
    ad_id="66f0a1b2c3d4e5f6a7b8c9d0",
    targeting={
        "countries": ["US", "GB"],
        "seniorities": ["5", "6"],
        "companySizes": ["E", "F", "G"],
    },
)
```
</Tab>
<Tab value="curl">
```bash
curl -X PUT "https://zernio.com/api/v1/ads/66f0a1b2c3d4e5f6a7b8c9d0" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "targeting": {
      "countries": ["US", "GB"],
      "seniorities": ["5", "6"],
      "companySizes": ["E", "F", "G"]
    }
  }'
```
</Tab>
</Tabs>

Response (`200`) returns the updated `ad` and a `message`.

<Callout type="info">
The update merges facet by facet. Zernio reads the live targeting and keeps every facet you do not send. A facet sent empty or `null` is removed.
</Callout>

An update applies every targeting field a create takes: countries or regions, `excludedLocations` (countries), the B2B facets, interests, behaviors, age, gender, languages and audience segments.

- Any location you send replaces the live locations.
- Sending only `ageMin` or only `ageMax` keeps the other live bound.
- `gender: "all"` removes the gender facet.
- `languages` sent empty falls back to English, since LinkedIn requires a language.

## Read the live targeting and creatives

`GET /v1/ads/ad-sets/{adSetId}/targeting` reads a LinkedIn Campaign live from LinkedIn. `adSetId` is the LinkedIn Campaign id, the ad's `platformAdSetId`.

```bash
curl "https://zernio.com/api/v1/ads/ad-sets/123456789/targeting?platform=linkedin" \
  -H "Authorization: Bearer $ZERNIO_API_KEY"
```

```json
{
  "adSetId": "123456789",
  "targeting": {
    "countries": ["US"],
    "languages": ["en"],
    "seniorities": ["urn:li:seniority:5"],
    "ageMin": 25,
    "ageMax": 54
  },
  "unmappedTargeting": null,
  "startDate": "2026-12-01T00:00:00.000Z",
  "endDate": null,
  "creatives": [
    {
      "platformAdId": "501",
      "status": "ACTIVE",
      "creative": { "headline": "Headline", "body": "Body text", "linkUrl": "https://example.com", "callToAction": "LEARN_MORE", "imageUrl": "https://media.licdn.com/..." }
    }
  ]
}
```

`targeting` is the shape `PUT /v1/ads/{adId}` takes. Sending it back unchanged leaves the Campaign's targeting as it is.

- B2B facets, interests and behaviors come back as LinkedIn URNs, which an update accepts as they are.
- Targeting the fields cannot rebuild exactly comes back verbatim under `unmappedTargeting`. An update keeps it.

Each `creative` is the shape `PUT /v1/ads/{adId}` takes, with `platformAdId` as the `adId`. It is `null` for carousel, document, event, text and lead-gen ads.

`imageUrl` and `videoUrl` are LinkedIn's signed links and expire. Download the media before sending it back.

## If it fails

| Error | Cause | Fix |
|---|---|---|
| `400` `mutually_exclusive_fields` | `jobTitles` sent with `seniorities` or `jobFunctions` on create or boost | Keep `jobTitles`, or the other two |
| `400` `invalid_field_value` naming a field | `cities`, `zips`, `metros`, `customLocations`, `incomeTier` or a Meta work facet | Target by country, region and the B2B facets |
| `400` on a country code | The country code is unknown | Send an ISO 3166-1 alpha-2 code, or a region URN from the search |
| `400` naming `dimension` | The search dimension does not exist on LinkedIn | Use one of the dimensions above |

## Related

- [Create a campaign](/platforms/linkedin-ads/create-ads): the create call these fields ride on.
- [Bid pricing and forecasts](/platforms/linkedin-ads/planning): price and size a targeting spec before you spend.
- [Matched Audiences](/platforms/linkedin-ads/audiences): the segments for `audienceInclude`.
- [Search targeting options](/ad-targeting/search-ad-targeting) and [Update ad](/ad-campaigns/update-ad): every parameter.