# CONVERSATION_FLOWS

conversation-flows endpoints.

**Base URL:** `https://api.trustpager.com/functions/v1/api/v1`

## Endpoints

### POST /conversation-flows

Create a conversation flow as a switched-off draft, blank or from a template (its lead step goes to your default pipeline). Then test_conversation_flow, publish_conversation_flow, and switch_conversation_flow to switch it on.

**Scopes:** `automations:write` — [full detail](./conversation-flows/post-conversation-flows.md)

### DELETE /conversation-flows/:flow_id

Delete a conversation flow and its results. People mid-flow stop where they are; the messages it sent stay in the Inbox.

**Scopes:** `automations:delete` — [full detail](./conversation-flows/delete-conversation-flows-flow-id.md)

### GET /conversation-flows/:flow_id

Get one conversation flow: its draft (channels, starts, steps) with draft_problems to fix before publishing, and the live version.

**Scopes:** `automations:read` — [full detail](./conversation-flows/get-conversation-flows-flow-id.md)

### GET /conversation-flows/:flow_id/results

Results of a flow: people who started, finished, are still in it, were handed to a person, stopped replying; and per step how many reached it, chose each button, typed something else, answered, are waiting there now. days (default 30) and channel filter.

**Scopes:** `automations:read` — [full detail](./conversation-flows/get-conversation-flows-flow-id-results.md)

### GET /conversation-flows/accounts

The accounts a conversation flow can run on: connected Instagram accounts, Facebook Pages (Messenger) and SMS numbers, with the id to put in a flow's channels accounts.

**Scopes:** `automations:read` — [full detail](./conversation-flows/get-conversation-flows-accounts.md)

### GET /conversation-flow-runs

People going through flows, latest first: the flow, channel and conversation, status (running, waiting, paused: a person replied; handoff: needs a person; finished; stopped), the step they are at, held_by (who holds the conversation now: flow, ai or person), what they answered. Filters: flow_id, conversation_ids (comma separated, up to 100), status (open = running, waiting, paused or handoff).

**Scopes:** `automations:read` — [full detail](./conversation-flows/get-conversation-flow-runs.md)

### GET /conversation-flows/templates

Ready-made conversation flows to start from (create_conversation_flow template): what each does, what it needs, its channels and its first messages.

**Scopes:** `automations:read` — [full detail](./conversation-flows/get-conversation-flows-templates.md)

### GET /conversation-flows

List the workspace's conversation flows (chats that answer, ask and book on Instagram, Messenger and SMS), newest change first: status (draft: never published; off; live; live_with_draft_changes; off_with_draft_changes), the channels and accounts it runs on, how it starts (keywords, any message), and people in the last 30 days (started, finished, handed to a person, still in the flow, stopped). Filter: channel.

**Scopes:** `automations:read` — [full detail](./conversation-flows/get-conversation-flows.md)

### GET /conversation-flows/no-match

For every channel account (SMS numbers, email settings, WhatsApp, Instagram, Messenger, website chat): what happens to a message no conversation flow takes, the "When no flow matches" setting. One choice for business hours and one for after hours: ai_reply (the AI answers), team (it waits in the Inbox for a person) or start_flow (with the flow). source says whether it was chosen (saved) or is what the account did before (auto_responder, chat_agent, none). warnings say when a choice will not work yet. Filter: channel.

**Scopes:** `automations:read` — [full detail](./conversation-flows/get-conversation-flows-no-match.md)

### POST /conversation-flow-runs/:run_id/pause

Pause the flow in one conversation so a person can talk (replying from the Inbox pauses it too). It stays paused until carried on, or 24 hours.

**Scopes:** `automations:write` — [full detail](./conversation-flows/post-conversation-flow-runs-run-id-pause.md)

### POST /conversation-flows/:flow_id/publish

Publish the draft as the live flow (the next version). Refused while the draft has problems (each is named) or when nothing changed. warnings name other switched-on flows that start on the same keywords. People mid-flow carry on with the new version from the step they are on.

**Scopes:** `automations:write` — [full detail](./conversation-flows/post-conversation-flows-flow-id-publish.md)

### POST /conversation-flow-runs/:run_id/resume

Carry a paused or handed-over flow on in its conversation, from the step it was on or step_id (that step's message is sent again; needs social-inbox:send or sms:send too).

**Scopes:** `automations:write` — [full detail](./conversation-flows/post-conversation-flow-runs-run-id-resume.md)

### PUT /conversation-flows/no-match/:channel/:account_id

Set what happens to a message no conversation flow takes on one account: business_hours and after_hours, each ai_reply, team or start_flow (with business_hours_flow_id or after_hours_flow_id, a flow that runs on this account). Send only what changes. Choosing ai_reply switches on the AI for that account (it keeps its own draft or auto-send mode; an account with no AI gets one in draft mode, so replies wait for approval) and needs agent-ops:write. A team reply in a conversation always pauses the AI and any flow; each conversation gets at most 30 automatic replies a day.

**Scopes:** `automations:write` — [full detail](./conversation-flows/put-conversation-flows-no-match-channel-account-id.md)

### POST /conversation-flows/:flow_id/start

Start a switched-on flow in one conversation now, from its first step (sends its first message; needs social-inbox:send or sms:send too). Instagram and Messenger allow it only within 24 hours of the person's last message. Refused when another flow is running there.

**Scopes:** `automations:write` — [full detail](./conversation-flows/post-conversation-flows-flow-id-start.md)

### POST /conversation-flow-runs/:run_id/stop

End the flow in one conversation now. Nothing more is sent; the conversation can start a flow again.

**Scopes:** `automations:write` — [full detail](./conversation-flows/post-conversation-flow-runs-run-id-stop.md)

### POST /conversation-flows/:flow_id/switch

Switch a published conversation flow on (it answers new messages on its channels) or off (people mid-flow stop at their next message). Switching on checks the live flow still fits the workspace; warnings name other switched-on flows that start on the same keywords.

**Scopes:** `automations:write` — [full detail](./conversation-flows/post-conversation-flows-flow-id-switch.md)

### POST /conversation-flows/:flow_id/test

Try a flow on a pretend conversation: give the replies a person would send and get back exactly what the flow sends on that channel, notes on what it saves, makes and hands over, and where it ends. from_step starts it at one step to try a branch on its own. Nothing is sent or saved.

**Scopes:** `automations:read` — [full detail](./conversation-flows/post-conversation-flows-flow-id-test.md)

### PATCH /conversation-flows/:flow_id

Change a conversation flow: name, description, or its draft (definition replaces the whole draft; the live flow changes only on publish_conversation_flow).

**Scopes:** `automations:write` — [full detail](./conversation-flows/patch-conversation-flows-flow-id.md)
