# X Ads

Create campaigns, promote posts you already published and upload Tailored Audiences on an xads account, with OAuth 1.0a signing handled server-side.

Create a campaign with `POST /v1/ads/create`, or promote a post you already published with `POST /v1/ads/boost`. Both run on an `xads` account for X (platform value `twitter`).

## Quick reference

Zernio signs every X Ads call with OAuth 1.0a server-side, so you send `$ZERNIO_API_KEY` as on any other platform.

| Property | Value |
|----------|-------|
| Hierarchy | Campaign > Line Item > Promoted Tweet, created in one call |
| Goals (`goal`) | `engagement`, `traffic`, `awareness`, `video_views`, `app_promotion` |
| Ad text | `body`, 280 characters; a `linkUrl` without a website card counts as about 24 of them |
| Website card | `imageUrl` + `headline` (max 70 characters) + `linkUrl`, all three together, on a create |
| Rejected creative fields | `description`, `video`, `callToAction` (return `400`) |
| Media | An image through the website card on a create; a boost carries the media of the post it promotes, video included |
| Budget | `daily` or `lifetime` (`lifetime` needs `endDate`), set on the line item |
| Targeting | Country, region, metro, city, postal code, interests, custom audiences, age (rounded out to X's fixed ranges), gender, language |
| Audiences | Tailored Audiences (create, member upload, read) |
| Analytics | Yes |
| Edits after creation | Status, budget and bid only ([Manage ads](/platforms/x-ads/manage-ads)) |
| X Pixel | Create, read, first-party cookie setting, conversion events, stats and Shopify / WordPress install ([X Pixel](/platforms/x-ads/tracking-tag)) |

## Before you start

X Ads is a separate OAuth from X posting, so the profile needs both:

- a connected X posting account
- the `xads` account created from it

There is no ads-only mode.

You also need the X Ads account id, a base36 string such as `18ce54d4x5t`, from [List ad accounts](/ad-accounts/list-ad-accounts).

<Callout type="info">
`accountId` takes either shape. Pass the X posting account id or the `xads` account id and Zernio resolves the sibling internally. When the resolved profile has no X Ads connection, the call returns `422` with code `ads_connection_required`.
</Callout>

## Connect

Call `GET /v1/connect/twitter/ads` with `profileId` and the `accountId` of the X posting account to connect X Ads from ([Connect ads](/connect/connect-ads)).

`accountId` is required here: the `xads` account is always created from an X posting account, so there is no ads-only path.

The ads themselves are published as the ad account's full promotable user (see [Create ads](/platforms/x-ads/create-ads)).

```bash
curl "https://zernio.com/api/v1/connect/twitter/ads?profileId=66a1f0c2a4b9d3e8f1a2b3c4&accountId=66b2e19d8c3f5a7e9d0b1c2d" \
  -H "Authorization: Bearer $ZERNIO_API_KEY"
```

Response (`200`):

```json
{
  "authUrl": "https://api.x.com/oauth/authorize?oauth_token=...",
  "state": "..."
}
```

Send the user to `authUrl`, as in the [connecting accounts guide](/guides/connecting-accounts).

X Ads keeps its own token, so this round trip always happens the first time. Afterwards the same call returns `alreadyConnected: true` with the `xads` `accountId`.

**Errors.** On failure the browser lands on your `redirect_url` with `platform=xads` and an `error` slug such as `x_ads_denied`, `x_ads_auth_failed` or `x_ads_token_failed`.

**Scoping ad sync.** Pass `adAccountId` on the connect call to scope ad sync to one X Ads account, or `adAccountIds` (repeated or comma-separated) for several.

Sending neither leaves whatever scope is already stored. Sending one removes ads already synced from the accounts it drops.

## In this section

<PlatformPages platform="x-ads" />

## Related

- [X](/platforms/twitter): the posting account the `xads` account is connected from.
- [Connecting accounts](/guides/connecting-accounts): the OAuth flow behind `authUrl`.
- [Create standalone ad](/ad-campaigns/create-standalone-ad) and [Boost post](/ad-campaigns/boost-post): every field of both requests.
- [Create ad audience](/ad-audiences/create-ad-audience) and [Add users to ad audience](/ad-audiences/add-users-to-ad-audience).
- [Get ad analytics](/ad-insights/get-ad-analytics): metrics, date ranges and rollups.
- [Pixels and tracking tags](/guides/pixels): the pixel API across platforms.