# OUTREACH_AGENTS

outreach-agents endpoints.

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

## Endpoints

### POST /outreach-agents/:agent_id/targets

Add chosen contacts to the agent's list, by contact id. Anyone who opted out of texts, has no mobile number, is already a customer, was archived or has no open opportunity is skipped, with the reason.

**Scopes:** `outreach-agents:write` — [full detail](./outreach-agents/post-outreach-agents-agent-id-targets.md)

### POST /outreach-agents/:agent_id/audience/build

Add everyone the audience takes to the agent's list (or at most limit of them, e.g. 20 for a pilot). People already in the list are not added twice. Nothing is sent until the agent is started.

**Scopes:** `outreach-agents:write` — [full detail](./outreach-agents/post-outreach-agents-agent-id-audience-build.md)

### POST /outreach-agents

Create an outreach agent: it texts a saved list of old leads one by one, picking up where things were left off with each, and hands every reply to the SMS auto-responder. It starts as a draft. Next: preview_outreach_audience to see who it would text, build_outreach_list to add them (limit 20 for a pilot), draft_outreach_message to read a few sample messages, then update_outreach_agent status "active". To test offers, create an A/B test with subject_type "outreach_agent" and this agent's id (create_ab_test); each lead then gets one version's offer or wording.

**Scopes:** `outreach-agents:write` — [full detail](./outreach-agents/post-outreach-agents.md)

### DELETE /outreach-agents/:agent_id

Delete an outreach agent, its list and its message history. Refused while it is running: pause it first. Messages already sent stay on each lead's timeline.

**Scopes:** `outreach-agents:delete` — [full detail](./outreach-agents/delete-outreach-agents-agent-id.md)

### POST /outreach-agents/:agent_id/targets/:target_id/draft

Research one lead and write their next message now, without sending it, to see exactly what the agent would say (and which A/B version they get). The first time, it also saves where we left off on their opportunity. Uses AI credits like the agent does. The message then waits as the lead's draft and goes out when the agent runs.

**Scopes:** `outreach-agents:write` — [full detail](./outreach-agents/post-outreach-agents-agent-id-targets-target-id-draft.md)

### GET /outreach-agents/:agent_id

One outreach agent: its settings, its list by status, what waits for approval, and its results so far (texted, replied, booked, bought, and which A/B version is winning).

**Scopes:** `outreach-agents:read` — [full detail](./outreach-agents/get-outreach-agents-agent-id.md)

### GET /outreach-agents/:agent_id/report

How the agent is doing over the last `days` days (default 7, 0 for everything so far): leads texted, messages sent, replies, bookings, sales and their value, leads stopped, messages waiting for approval, and which A/B version is winning, with a one-sentence summary.

**Scopes:** `outreach-agents:read` — [full detail](./outreach-agents/get-outreach-agents-agent-id-report.md)

### GET /outreach-agents/:agent_id/targets/:target_id

One lead in the agent's list: where we left off with them, the message waiting to go, and every message the agent wrote them (sent, waiting for approval, turned down or failed).

**Scopes:** `outreach-agents:read` — [full detail](./outreach-agents/get-outreach-agents-agent-id-targets-target-id.md)

### GET /outreach-agents

Every outreach agent (e.g. "Reawaken old leads"): whether it is running, its list by status (queued, drafted, awaiting_approval, sent, replied, done, stopped, skipped, failed), how many messages wait for approval, and how many approvals are left before it sends by itself.

**Scopes:** `outreach-agents:read` — [full detail](./outreach-agents/get-outreach-agents.md)

### GET /outreach-agents/:agent_id/targets

The agent's list: each lead with their status, how many messages they have had, the message waiting to go, where we left off with them (summary), and why they stopped. Filter with status.

**Scopes:** `outreach-agents:read` — [full detail](./outreach-agents/get-outreach-agents-agent-id-targets.md)

### POST /outreach-agents/:agent_id/audience/preview

Who the agent's audience would add to its list, without adding anyone: how many qualify, how many are already in the list, how many are left out and why (opted out, no mobile, already a customer, in an excluded pipeline or stage, archived), and ten names as a sample.

**Scopes:** `outreach-agents:read` — [full detail](./outreach-agents/post-outreach-agents-agent-id-audience-preview.md)

### POST /outreach-agents/:agent_id/run

Have a running agent do its next round within about five minutes instead of waiting up to ten (write messages, settle approvals, send what is due inside each lead's sending hours).

**Scopes:** `outreach-agents:write` — [full detail](./outreach-agents/post-outreach-agents-agent-id-run.md)

### PATCH /outreach-agents/:agent_id

Change an outreach agent's settings, or start it (status "active", needs leads in its list) or pause it (status "paused": nothing is lost, resume with "active"). Changes to instructions or the offer apply to messages written from now on; use update_outreach_target status "queued" to rewrite one already written.

**Scopes:** `outreach-agents:write` — [full detail](./outreach-agents/patch-outreach-agents-agent-id.md)

### PATCH /outreach-agents/:agent_id/targets/:target_id

Stop the agent messaging one lead (status "stopped"), have their next message written again (status "queued"), or edit the message waiting to go (draft, only while their status is drafted).

**Scopes:** `outreach-agents:write` — [full detail](./outreach-agents/patch-outreach-agents-agent-id-targets-target-id.md)
