> ## Documentation Index
> Fetch the complete documentation index at: https://www.adjar.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Get OpenAI Ads API access

Adjar manages OpenAI Ads — the ads that run inside ChatGPT — through the OpenAI Ads API. Authentication is a single **API key**, scoped to one ad account, that you collect into an `openai.json` file. This page covers how the key works, how to assemble the file, and how to point Adjar at it.

<Note>
  OpenAI Ads access is provisioned per advertiser through OpenAI's onboarding. The exact click-path to generate a key lives in OpenAI's own docs and may change — this page covers what Adjar needs and how it consumes the key, and points you to OpenAI for the provisioning steps.
</Note>

## Prerequisites

* An approved OpenAI Ads advertiser account. Start at [ads.openai.com](https://ads.openai.com) and see the developer docs at [developers.openai.com/ads](https://developers.openai.com/ads).
* The `adjar` CLI installed (see the [Quick Start](/docs/quickstart)).

## How OpenAI Ads auth differs from Google

If you've set up [Google Ads access](/docs/google-ads-api-access), OpenAI is much simpler:

|                  | Google Ads                              | OpenAI Ads                      |
| ---------------- | --------------------------------------- | ------------------------------- |
| Mechanism        | OAuth (six values)                      | A single bearer API key         |
| Token refresh    | Yes (refresh token)                     | None — the key is used directly |
| Scope            | A manager account over many ad accounts | One key per ad account          |
| Credentials file | `google.json` (6 fields)                | `openai.json` (1–2 fields)      |

There's no manager account, no OAuth client, and no refresh-token exchange — just one key.

<Steps>
  <Step title="Get your Ads API key">
    Obtain the API key for your ad account from OpenAI's advertiser onboarding (via [ads.openai.com](https://ads.openai.com) or your OpenAI partner contact). Each key is scoped to a **single ad account** — if you manage more than one, you'll have one key and one `openai.json` per account.

    OpenAI Ads keys are bearer tokens. Treat the key like a password: it grants full read/write access to that ad account's campaigns and spend. Store it in a secret manager or an untracked file, never in version control.
  </Step>

  <Step title="Find your ad account ID">
    Your account ID looks like `adacct_6a44ee8e025c819fbd6057719ccb8545`. You can read it off the OpenAI Ads dashboard, or confirm it against the key by calling the account endpoint:

    ```bash theme={null}
    curl -s https://api.ads.openai.com/v1/ad_account \
      -H "Authorization: Bearer $OPENAI_ADS_API_KEY"
    ```

    The response's `id` field is your account ID — the value you pass to `adjar import --account`.
  </Step>
</Steps>

## Assemble the credentials file

Put the key into an `openai.json` file:

```json theme={null}
{
  "api_key": "sk-...",
  "account_id": "adacct_6a44ee8e025c819fbd6057719ccb8545"
}
```

* `api_key` — **required.** The bearer key for your ad account.
* `account_id` — optional. The key already determines the account server-side, so Adjar only uses this to cross-check the `account.id` in your config. You can omit it.

### Point Adjar at the file

Save the file anywhere, then point Adjar at it:

```bash theme={null}
# per command
adjar plan --config config/openai.toml --credentials /path/to/openai.json

# or once, via the environment (e.g. in your shell profile or CI)
export ADJAR_CREDENTIALS=/path/to/openai.json
```

`--credentials` takes priority over `ADJAR_CREDENTIALS`. Either way, give the path to the JSON file, not a folder. There are no implicit or default locations — credentials are always explicit.

<Warning>
  The API key grants full control of the ad account's campaigns and budget. Keep `openai.json` out of git (add it to `.gitignore`) and rotate the key if it's ever exposed.
</Warning>

With `openai.json` ready, head to the [Quick Start](/docs/quickstart) to import your account.
