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

# Manage Follow-up

> CRUD for follow-up configurations

## Create Configuration

```bash theme={null}
POST /backend/followup/configs
```

**Body:**

```json theme={null}
{
  "assistant_id": "uuid",
  "trigger_status_ids": ["uuid-status-1"],
  "steps": [
    {
      "interval": "PT30M",
      "prompt": "Friendly follow-up message"
    },
    {
      "interval": "PT2H",
      "prompt": "Offer a product demo"
    }
  ],
  "official_steps": [
    {
      "channel_id": "uuid",
      "channel_name": "WhatsApp Business",
      "app_id": "gupshup_app_12345",
      "steps": [
        {
          "interval": "P1D",
          "template_name": "reengagement_v1",
          "template_language": "en",
          "template_params": ["{{LEAD_FIRSTNAME}}"]
        }
      ]
    }
  ]
}
```

| Field                         | Type      | Required    | Description                                |
| ----------------------------- | --------- | ----------- | ------------------------------------------ |
| `assistant_id`                | UUID      | Yes         | Linked assistant                           |
| `trigger_status_ids`          | UUID\[]   | Yes         | Statuses that trigger follow-up            |
| `steps`                       | array     | Conditional | AI steps (required if no `official_steps`) |
| `steps[].interval`            | string    | Yes         | ISO 8601 interval (min 30 min)             |
| `steps[].prompt`              | string    | Conditional | Prompt for AI message generation           |
| `steps[].template_name`       | string    | Conditional | Required if interval >= 24h                |
| `steps[].template_language`   | string    | No          | Template language (default: `pt_BR`)       |
| `steps[].template_params`     | string\[] | No          | Template parameters                        |
| `official_steps`              | array     | No          | Steps per official channel (Meta/Gupshup)  |
| `official_steps[].channel_id` | string    | Yes         | Channel ID                                 |
| `official_steps[].app_id`     | string    | Yes         | Gupshup app ID                             |
| `official_steps[].steps`      | array     | Yes         | Channel steps (min 1)                      |

**Response (201):** Complete FollowupConfig object.

### Validations

* At least one step (in `steps` or `official_steps`)
* Maximum 3 steps per configuration
* Minimum interval: 30 minutes
* If interval >= 24h: `template_name` required
* No duplicate `channel_id` in `official_steps`
* One config per assistant

## Get Configuration

```bash theme={null}
GET /backend/followup/configs/{id}
```

## Get by Assistant

```bash theme={null}
GET /backend/followup/configs/assistant/{assistantId}
```

Returns the follow-up configuration linked to the assistant.

## List by Tenant

```bash theme={null}
GET /backend/followup/configs/tenant/{tenantId}
```

## Update Configuration

```bash theme={null}
PUT /backend/followup/configs/{id}
```

**Body (all fields optional):**

```json theme={null}
{
  "trigger_status_ids": ["uuid-status-1", "uuid-status-2"],
  "steps": [...],
  "official_steps": [...],
  "is_active": false
}
```

## Delete Configuration

```bash theme={null}
DELETE /backend/followup/configs/{id}
```

**Response:** 204 No Content

<Note>
  Already scheduled follow-up jobs will continue running until processed. Deletion does not cancel in-progress jobs.
</Note>
