# Create ad account

> Create an ad account in a Business portfolio.

Canonical: <https://www.tryadeli.com/docs/api/ads/create-ad-account>

`POST https://app.tryadeli.com/api/v1/ads/accounts`

Authorization: `Bearer <API key>` — see [Authentication](https://www.tryadeli.com/docs/authentication)

Creates an ad account in a Business portfolio the authorizing person
administers. Meta has no API for personal ad accounts. The currency and time
zone cannot be changed afterwards, and a portfolio may only hold a limited
number of ad accounts — commonly one until it has spend history — which Meta
reports as `422 provider_rejected`.

An `Idempotency-Key` header is required, since a retry would be a second ad
account: the same key replays `200` with the same account, `409
ad_account_create_failed` if it failed, or `409 ad_account_create_in_progress`.
A new account is `201`, and the account list is refreshed to include it.

**Body**

| Name         | Type     | Required | Description                                                                                 |
| ------------ | -------- | -------- | ------------------------------------------------------------------------------------------- |
| `businessId` | `string` | Yes      | A portfolio from GET `/api/v1/ads/businesses`.                                              |
| `name`       | `string` | Yes      | Up to 100 characters.                                                                       |
| `timezone`   | `string` | Yes      | An IANA zone Adeli maps to Meta's time zone id, such as America/New\_York or Europe/London. |
| `currency`   | `string` |          | ISO 4217. Defaults to USD.                                                                  |

## Request examples

**cURL**

```bash
curl --fail-with-body -X POST "https://app.tryadeli.com/api/v1/ads/accounts?accountId=00000000-0000-0000-0000-000000000000" \
  -H "Authorization: Bearer $ADELI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: client-a-ad-account" \
  -d '{
  "businessId": "1122334455",
  "name": "Client A — Ads",
  "timezone": "America/New_York",
  "currency": "USD"
}'
```

**JavaScript**

```javascript
const response = await fetch("https://app.tryadeli.com/api/v1/ads/accounts?accountId=00000000-0000-0000-0000-000000000000", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.ADELI_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": "client-a-ad-account",
  },
  body: JSON.stringify({
    businessId: "1122334455",
    name: "Client A — Ads",
    timezone: "America/New_York",
    currency: "USD",
  }),
});
console.log(await response.json());
```

**Python**

```python
import os

import requests

response = requests.post(
    "https://app.tryadeli.com/api/v1/ads/accounts",
    headers={"Authorization": f"Bearer {os.environ['ADELI_API_KEY']}", "Idempotency-Key": "client-a-ad-account"},
    params={
        "accountId": "00000000-0000-0000-0000-000000000000",
    },
    json={
        "businessId": "1122334455",
        "name": "Client A — Ads",
        "timezone": "America/New_York",
        "currency": "USD",
    },
)
print(response.json())
```

## Responses

### 201

```json
{
  "adAccount": {
    "id": "act_1234567890",
    "accountId": "1234567890",
    "name": "Client A — Ads",
    "currency": "USD",
    "timezoneName": "America/New_York",
    "accountStatus": 1,
    "minDailyBudget": 100,
    "businessId": "1122334455",
    "businessName": "Client A"
  },
  "replayed": false
}
```

### 400

```json
{
  "error": {
    "code": "invalid_request",
    "message": "An Idempotency-Key header is required"
  }
}
```

### 409

```json
{
  "error": {
    "code": "ad_account_create_in_progress",
    "message": "This ad account is still being created",
    "details": { "replayed": true }
  }
}
```
