# Create Rules

Creates one or more rules for a campaign. All active rules must pass for a payment to trigger the campaign (AND logic).

Visit the [conditional operators reference](/reference/communications-campaigns#conditional-operators-reference) for more information on how to use them.

**POST** `/campaigns/{campaign_id}/rules`

Base URL: `https://api-sandbox.whitelabel.com/v1`

## Authorization

- public-api-key (apiKey in header)
- private-secret-key (apiKey in header)

## Path parameters

- `campaign_id` (string, required)
  The campaign identifier (UUID).

## Body

Content type: `application/json`

- `rules` (object[], required)
  Array of rule objects
  - `rule_type` (string, required)
    Type of rule (see [Rule Types Reference](/reference/communications-campaigns#rule-types-reference))
  - `values` (string[])
    Array of string values for comparison. Not required for `UNIQUE_BY_USER`.
  - `conditional` (string)
    Comparison operator. Not required for `USER_COMMS_PER_DAY` or `UNIQUE_BY_USER`. See [Conditional Operators Reference](/reference/communications-campaigns#conditional-operators-reference).
  - `metadata_key` (string)
    Required when `rule_type` is `METADATA`. The metadata field name to evaluate.

Example:

```json
{
  "rules": [
    {
      "rule_type": "string",
      "values": [
        "string"
      ],
      "conditional": "string",
      "metadata_key": "string"
    }
  ]
}
```

## Responses

### 201

Created

- `data` (object[])
  - `id` (string)
  - `rule_type` (string)
  - `values` (string[])
  - `conditional` (string)
  - `metadata_key` (string)
  - `status` (string)
  - `created_at` (string)
  - `updated_at` (string)

Example:

```json
{
  "data": [
    {
      "id": "f1e2d3c4-b5a6-7890-abcd-ef1234567890",
      "rule_type": "PAYMENT_STATUS",
      "values": [
        "DECLINED"
      ],
      "conditional": "EQUAL",
      "metadata_key": null,
      "status": "ACTIVE",
      "created_at": "2025-07-01T12:05:00Z",
      "updated_at": "2025-07-01T12:05:00Z"
    }
  ]
}
```