---
title: "Read a campaign, ad group, ad, and creative tree"
description: "PubNio API ads.getTree: read a campaign, ad group, ad, and creative tree. Request fields, examples in five clients, errors, and idempotency."
---

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

# Read a campaign, ad group, ad, and creative tree

Read a campaign, ad group, ad, and creative tree with [`GET /api/v1/ads/tree`](https://pubnio.com/api/v1/docs#tag/ads/GET/api/v1/ads/tree). Requires an API key with the `read` scope or a signed-in workspace member.

## Request

Optionally filter by account or campaign. Returns at most the requested number of campaigns.

| Parameter     | In    | Type   | Required |
| ------------- | ----- | ------ | -------- |
| `workspaceId` | query | UUID   | Yes      |
| `accountId`   | query | UUID   | No       |
| `campaignId`  | query | UUID   | No       |
| `cursor`      | query | string | No       |
| `limit`       | query | string | No       |

## Response

- HTTP 200: `AdTree` with `data`, `hasMore`, `nextCursor`, `freshness`.

The [OpenAPI document](https://pubnio.com/api/v1/openapi) has each field's type.

## Examples

### TypeScript

```ts
const tree = await workspace.ads.tree({ campaignId });
```

### Python

```python
tree = workspace.ads.get_tree()
```

### cURL

```sh
curl "https://pubnio.com/api/v1/ads/tree?workspaceId=$WORKSPACE_ID" \
  -H "Authorization: Bearer $PUBNIO_API_KEY"
```

### CLI

```sh
pnio ads get-tree --campaign-id "$CAMPAIGN_ID"
```

### MCP execute

```js
async () => {
  const response = await codemode.request({
    method: "GET",
    path: "/api/v1/ads/tree",
    query: { workspaceId: codemode.workspaceId },
  });
  return response.data;
};
```

## Errors

It declares no problem of its own.

It declares the problems [every Ads operation](https://pubnio.com/docs/reference/#ads) and [most operations](https://pubnio.com/docs/reference/#shared-problems) declare.

## Idempotency

None needed: a read is safe to retry.

## Limits

- Up to 100 items a page; pass `nextCursor` back as `cursor`. See [Pagination](https://pubnio.com/docs/concepts/pagination/).

## Related

- [Ads operations](https://pubnio.com/docs/reference/#ads)

Source: https://pubnio.com/docs/reference/ads-get-tree/index.mdx
