# Campaign tree

> Campaigns, ad sets, and ads with performance rolled up at every level.

Canonical: <https://www.tryadeli.com/docs/api/ads/get-campaign-tree>

`GET https://app.tryadeli.com/api/v1/ads/tree`

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

The Campaign → Ad set → Ad hierarchy for one ad account, with `spend`,
`impressions`, `reach`, `clicks`, `ctr`, `cpc` and `cpm` rolled up at every
level. An object that did not deliver in the range reports zeroes rather than
being omitted.

**Query parameters**

| Name          | Type     | Required | Description                                                                                     |
| ------------- | -------- | -------- | ----------------------------------------------------------------------------------------------- |
| `adAccountId` | `string` | Yes      | An ad account id, in Meta's act\_<digits> form.                                                 |
| `since`       | `date`   |          | YYYY-MM-DD. Defaults to 28 days ago.                                                            |
| `until`       | `date`   |          | YYYY-MM-DD. Defaults to today. Ranges over 730 days are rejected.                               |
| `accountId`   | `uuid`   |          | A connected Facebook account.                                                                   |
| `profileId`   | `uuid`   |          | Required unless you pass accountId, which names its profile. If you pass both, they must agree. |

## Request examples

**cURL**

```bash
curl --fail-with-body "https://app.tryadeli.com/api/v1/ads/tree?adAccountId=act_1234567890&since=2026-09-12&until=2026-10-09&accountId=00000000-0000-0000-0000-000000000000" \
  -H "Authorization: Bearer $ADELI_API_KEY"
```

**JavaScript**

```javascript
const response = await fetch("https://app.tryadeli.com/api/v1/ads/tree?adAccountId=act_1234567890&since=2026-09-12&until=2026-10-09&accountId=00000000-0000-0000-0000-000000000000", {
  headers: {
    Authorization: `Bearer ${process.env.ADELI_API_KEY}`,
  },
});
console.log(await response.json());
```

**Python**

```python
import os

import requests

response = requests.get(
    "https://app.tryadeli.com/api/v1/ads/tree",
    headers={"Authorization": f"Bearer {os.environ['ADELI_API_KEY']}"},
    params={
        "adAccountId": "act_1234567890",
        "since": "2026-09-12",
        "until": "2026-10-09",
        "accountId": "00000000-0000-0000-0000-000000000000",
    },
)
print(response.json())
```

## Responses

### 200

```json
{
  "platform": "facebook",
  "accountId": "00000000-0000-0000-0000-000000000000",
  "profileId": "00000000-0000-4000-8000-000000000002",
  "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"
  },
  "campaigns": [
    {
      "id": "120210000000000001",
      "name": "Fall launch",
      "status": "ACTIVE",
      "effectiveStatus": "ACTIVE",
      "metrics": { "spend": 182.4, "impressions": 41250, "reach": 30110, "clicks": 912, "ctr": 2.210909, "cpc": 0.2, "cpm": 4.421818, "conversions": 0 },
      "objective": "OUTCOME_ENGAGEMENT",
      "adSets": [
        {
          "id": "120210000000000002",
          "name": "Fall launch — ad set",
          "status": "ACTIVE",
          "effectiveStatus": "ACTIVE",
          "metrics": { "spend": 182.4, "impressions": 41250, "reach": 30110, "clicks": 912, "ctr": 2.210909, "cpc": 0.2, "cpm": 4.421818, "conversions": 0 },
          "ads": [
            {
              "id": "120210000000000004",
              "name": "Fall launch — ad",
              "status": "ACTIVE",
              "effectiveStatus": "ACTIVE",
              "metrics": { "spend": 182.4, "impressions": 41250, "reach": 30110, "clicks": 912, "ctr": 2.210909, "cpc": 0.2, "cpm": 4.421818, "conversions": 0 }
            }
          ]
        }
      ]
    }
  ],
  "range": { "since": "2026-09-12", "until": "2026-10-09" },
  "fetchedAt": "2026-10-09T16:00:00.000Z"
}
```

### 400

```json
{
  "error": {
    "code": "invalid_request",
    "message": "since and until must be YYYY-MM-DD, with since on or before until"
  }
}
```

### 429

```json
{
  "error": {
    "code": "rate_limited",
    "message": "Facebook is rate limiting this ad account; try again in a minute",
    "details": { "retryAfterSeconds": 60, "limit": "ad_account" }
  }
}
```
