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

# Campaigns conditions create

## POST /api/v1/public/campaigns/{id}/conditions/

Adds a new condition to a campaign. Conditions allow you to create branching logic in your campaign flow.

Auth: `X-API-Key`

### Path Parameters

* `id` (integer, required): Campaign ID

### Request Body

```json theme={null}
{
  "condition_type": "HAS_EMAIL",
  "delay_in_hours": 0,
  "parent_step_id": 123,
  "yes_child_step_id": 456,
  "no_child_step_id": 789
}
```

### Available Condition Types

* `HAS_EMAIL`: Check if the prospect has an email address
* `HAS_EMAIL_PREMIUM`: Check if the prospect has a premium email (Gmail, Outlook, etc.)
* `ACCEPTED_INVITE`: Check if the prospect accepted the LinkedIn connection request
* `ALREADY_CONNECTED`: Check if the prospect is already connected on LinkedIn

### Flow Management Fields

* `parent_step_id` (integer, optional): ID of the step that comes before this condition
* `yes_child_step_id` (integer, optional): ID of the step to execute if condition is true
* `no_child_step_id` (integer, optional): ID of the step to execute if condition is false

### Response

```json theme={null}
{
  "success": true,
  "condition": {
    "id": 101,
    "condition_type": "HAS_EMAIL",
    "delay_in_hours": 0,
    "parent_step_id": 123,
    "yes_child_step_id": 456,
    "no_child_step_id": 789,
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-15T10:30:00Z"
  },
  "campaign": {...}
}
```

### Example

```bash theme={null}
curl -X POST -H "X-API-Key: <key>" \
  -H "Content-Type: application/json" \
  -d '{
    "condition_type": "HAS_EMAIL",
    "parent_step_id": 123,
    "yes_child_step_id": 456,
    "no_child_step_id": 789
  }' \
  "https://api.seleqt.ai/api/v1/public/campaigns/123/conditions/"
```

### Building Conditional Flows

Here's an example of how to create a conditional campaign flow:

#### 1. Create initial LinkedIn invite

```bash theme={null}
curl -X POST -H "X-API-Key: <key>" \
  -H "Content-Type: application/json" \
  -d '{
    "step_type": "LINKEDIN_INVITE",
    "message_template": "Hi {{first_name}}, I would love to connect!",
    "delay_in_hours": 0
  }' \
  "https://api.seleqt.ai/api/v1/public/campaigns/123/steps/"
```

#### 2. Create a condition to check if they have email

```bash theme={null}
curl -X POST -H "X-API-Key: <key>" \
  -H "Content-Type: application/json" \
  -d '{
    "condition_type": "HAS_EMAIL",
    "parent_step_id": 456
  }' \
  "https://api.seleqt.ai/api/v1/public/campaigns/123/conditions/"
```

#### 3. Create email step for prospects with email (YES path)

```bash theme={null}
curl -X POST -H "X-API-Key: <key>" \
  -H "Content-Type: application/json" \
  -d '{
    "step_type": "EMAIL",
    "message_template": "Hi {{first_name}}, thanks for connecting!",
    "subject_line": "Quick question about {{company_name}}",
    "delay_in_hours": 24,
    "parent_condition_id": 101
  }' \
  "https://api.seleqt.ai/api/v1/public/campaigns/123/steps/"
```

#### 4. Create LinkedIn message for prospects without email (NO path)

```bash theme={null}
curl -X POST -H "X-API-Key: <key>" \
  -H "Content-Type: application/json" \
  -d '{
    "step_type": "LINKEDIN_MESSAGE",
    "message_template": "Thanks for connecting {{first_name}}! I would love to discuss how we can help {{company_name}}.",
    "delay_in_hours": 48,
    "parent_condition_id": 101
  }' \
  "https://api.seleqt.ai/api/v1/public/campaigns/123/steps/"
```

This creates a flow: LinkedIn Invite → Check if has email → Email (if yes) OR LinkedIn Message (if no)
