# Pipelines & stages — full CRUD

> **TL;DR for agents:** Pipeline: `POST /api/pipelines {name, currency}`. Stages CRUD: `POST/PATCH/DELETE /api/pipelines/:id/stages…`. Reorder: `PATCH /api/pipelines/:id/stages/reorder {stageIds:[…]}`. Hide technical: `PATCH /api/pipelines/:id/stages/:stageId {isHidden:true}`. Automations: `POST /api/pipelines/stages/:stageId/automations`.

## Create pipeline (auto-seeds 6 stages)

```bash
curl -s -X POST "https://api.live-direct-marketing.online/api/pipelines" \
  -H "Authorization: Bearer $LDM_KEY" -H "Content-Type: application/json" \
  -d '{"name":"Outbound 2026","currency":"USD"}'
```

## Add / rename / delete a stage

```bash
# add
curl -s -X POST "https://api.live-direct-marketing.online/api/pipelines/$P/stages" \
  -H "Authorization: Bearer $LDM_KEY" -H "Content-Type: application/json" \
  -d '{"name":"Discovery call","sortOrder":3,"probability":40}'

# rename / change probability
curl -s -X PATCH "https://api.live-direct-marketing.online/api/pipelines/$P/stages/$S" \
  -H "Authorization: Bearer $LDM_KEY" -H "Content-Type: application/json" \
  -d '{"name":"Discovery — booked","probability":50}'

# delete
curl -s -X DELETE "https://api.live-direct-marketing.online/api/pipelines/$P/stages/$S" \
  -H "Authorization: Bearer $LDM_KEY"
```

## Reorder stages

```bash
curl -s -X PATCH "https://api.live-direct-marketing.online/api/pipelines/$P/stages/reorder" \
  -H "Authorization: Bearer $LDM_KEY" -H "Content-Type: application/json" \
  -d '{"stageIds":["$S1","$S2","$S3","$S4"]}'
```

## Hide a technical stage from kanban

Same as in `/leads-pipeline`. Hidden stages still hold leads, but the kanban filters them by default; toolbar exposes a toggle.

```bash
curl -s -X PATCH "https://api.live-direct-marketing.online/api/pipelines/$P/stages/$S" \
  -H "Authorization: Bearer $LDM_KEY" -H "Content-Type: application/json" -d '{"isHidden":true}'
```

## Stage automations (move on dialog received, etc.)

```bash
curl -s "https://api.live-direct-marketing.online/api/pipelines/stages/$S/automations" \
  -H "Authorization: Bearer $LDM_KEY"

curl -s -X POST "https://api.live-direct-marketing.online/api/pipelines/stages/$S/automations" \
  -H "Authorization: Bearer $LDM_KEY" -H "Content-Type: application/json" \
  -d '{"trigger":"DIALOG_RECEIVED","action":"MOVE_TO_STAGE","actionParams":{"stageId":"$NEXT"}}'
```
