# Create a value rule set

Creates a value rule set. Works with Meta Ads.

```http
POST https://api.pozy.ai/v1/ads/value-rule-sets
```

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

## Request body

Content type: `application/json`

- `accountId`, string, required
- `adAccountId`, string, required
- `name`, string, required: 1 to 255 characters
- `rules`, array of object, required: At least 1 item. Up to 10 items
  - `id`, string
  - `name`, string, required: 1 to 255 characters
  - `adjustSign`, string, required: One of `INCREASE`, `DECREASE`
  - `adjustValue`, integer, required: 1 to 1000
  - `status`, string
  - `criteria`, array of object, required: At least 1 item. Up to 4 items
    - `id`, string
    - `criteriaType`, string, required: One of `AGE`, `GENDER`, `OS_TYPE`, `DEVICE_PLATFORM`, `LOCATION`, `PLACEMENT`, `OMNI_CHANNEL`, `AUDIENCE_LABEL`
    - `operator`, string, required: One of `CONTAINS`
    - `criteriaValues`, array of string, required: At least 1 item
    - `criteriaValueTypes`, array of string, required: At least 1 item

## Example request

```bash
curl -X POST "https://api.pozy.ai/v1/ads/value-rule-sets" \
  -H "Authorization: Bearer $POZY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "accountId": "696e0b682d0a31188e7a2ba9",
  "adAccountId": "666219aad7bab67ace411e4f",
  "name": "Acme",
  "rules": [
    {
      "name": "Acme",
      "adjustSign": "INCREASE",
      "adjustValue": 1,
      "criteria": [
        {
          "criteriaType": "AGE",
          "operator": "CONTAINS",
          "criteriaValues": [
            "string"
          ],
          "criteriaValueTypes": [
            "string"
          ]
        }
      ]
    }
  ]
}'
```

```ts
const res = await fetch("https://api.pozy.ai/v1/ads/value-rule-sets", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.POZY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    accountId: "696e0b682d0a31188e7a2ba9",
    adAccountId: "666219aad7bab67ace411e4f",
    name: "Acme",
    rules: [
      {
        name: "Acme",
        adjustSign: "INCREASE",
        adjustValue: 1,
        criteria: [
          {
            criteriaType: "AGE",
            operator: "CONTAINS",
            criteriaValues: [
              "string"
            ],
            criteriaValueTypes: [
              "string"
            ]
          }
        ]
      }
    ]
  }),
});
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.post(
    "https://api.pozy.ai/v1/ads/value-rule-sets",
    headers={"Authorization": f"Bearer {os.environ['POZY_API_KEY']}"},
    json={
        "accountId": "696e0b682d0a31188e7a2ba9",
        "adAccountId": "666219aad7bab67ace411e4f",
        "name": "Acme",
        "rules": [
            {
                "name": "Acme",
                "adjustSign": "INCREASE",
                "adjustValue": 1,
                "criteria": [
                    {
                        "criteriaType": "AGE",
                        "operator": "CONTAINS",
                        "criteriaValues": [
                            "string",
                        ],
                        "criteriaValueTypes": [
                            "string",
                        ],
                    },
                ],
            },
        ],
    },
    timeout=30,
)
resp.raise_for_status()
print(resp.json())
```

## Response 201

- `adAccountId`, string
- `valueRuleSetId`, string: Can be null

```json
{
  "adAccountId": "666219aad7bab67ace411e4f",
  "valueRuleSetId": "61a397b2938e2deed78e0e3f"
}
```
