# Replace an asset group's listing-group tree

Replaces an asset group's listing-group tree. Works with Google Ads.

```http
PUT https://api.pozy.ai/v1/ads/campaigns/{campaignId}/asset-groups/{assetGroupId}/listing-group-filters
```

- Area: Ads / Ad Campaigns
- Auth: Authorization: Bearer pz_live_...

## Path parameters

- `campaignId` (string, required)
- `assetGroupId` (string, required)

## Request body

Content type: `application/json`

- `tree`, object, required
  - `children`, array of object: At least 2 items
    - `dimension`, object, required
      - `productBrand`, object
        - `value`, string
      - `productCategory`, object
        - `categoryId`, string
        - `level`, string, required: One of `LEVEL1`, `LEVEL2`, `LEVEL3`, `LEVEL4`, `LEVEL5`
      - `productType`, object
        - `value`, string
        - `level`, string, required: One of `LEVEL1`, `LEVEL2`, `LEVEL3`, `LEVEL4`, `LEVEL5`
      - `productItemId`, object
        - `value`, string
      - `productCondition`, object
        - `condition`, string: One of `NEW`, `REFURBISHED`, `USED`
      - `productChannel`, object
        - `channel`, string: One of `ONLINE`, `LOCAL`
      - `productCustomAttribute`, object
        - `value`, string
        - `index`, string, required: One of `INDEX0`, `INDEX1`, `INDEX2`, `INDEX3`, `INDEX4`
    - `excluded`, boolean
    - `children`, array of object: At least 2 items
- `validateOnly`, boolean: Default `false`

## Example request

```bash
curl -X PUT "https://api.pozy.ai/v1/ads/campaigns/65a3737dd8b11ea61f199e6e/asset-groups/65c774748dcac8ef3c031319/listing-group-filters" \
  -H "Authorization: Bearer $POZY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "tree": {
    "children": [
      {
        "dimension": {
          "productBrand": {
            "value": "string"
          },
          "productCategory": {
            "level": "LEVEL1"
          },
          "productType": {
            "level": "LEVEL1"
          }
        }
      }
    ]
  }
}'
```

```ts
const res = await fetch("https://api.pozy.ai/v1/ads/campaigns/65a3737dd8b11ea61f199e6e/asset-groups/65c774748dcac8ef3c031319/listing-group-filters", {
  method: "PUT",
  headers: {
    Authorization: `Bearer ${process.env.POZY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    tree: {
      children: [
        {
          dimension: {
            productBrand: {
              value: "string"
            },
            productCategory: {
              level: "LEVEL1"
            },
            productType: {
              level: "LEVEL1"
            }
          }
        }
      ]
    }
  }),
});
const data = await res.json();
if (!res.ok) throw new Error(data?.error ?? `Request failed with status ${res.status}`);
console.log(data);
```

```python
import os
import requests

resp = requests.put(
    "https://api.pozy.ai/v1/ads/campaigns/65a3737dd8b11ea61f199e6e/asset-groups/65c774748dcac8ef3c031319/listing-group-filters",
    headers={"Authorization": f"Bearer {os.environ['POZY_API_KEY']}"},
    json={
        "tree": {
            "children": [
                {
                    "dimension": {
                        "productBrand": {
                            "value": "string",
                        },
                        "productCategory": {
                            "level": "LEVEL1",
                        },
                        "productType": {
                            "level": "LEVEL1",
                        },
                    },
                },
            ],
        },
    },
    timeout=30,
)
resp.raise_for_status()
print(resp.json())
```

## Response 200

- `assetGroupId`, string
- `removed`, integer
- `created`, integer
- `validateOnly`, boolean

```json
{
  "assetGroupId": "65c774748dcac8ef3c031319",
  "removed": 1,
  "created": 1,
  "validateOnly": true
}
```
