# Outreach Agent API Reference

> Platform documentation snapshot. Access, charging and provider requirements remain operation-specific; examples do not execute requests.

### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `name` | string | Campaign name (required on create). |
| `status` | "draft" | "active" | "paused" | "completed" | Campaign state. Only these four values are accepted — anything else returns 400. Defaults to "draft" when omitted. "draft" = built but the engine never picks it up (no scheduling, no sends). "active" = sending on the configured pacing. "paused" = halted; resumes from the exact step each lead was on. "completed" = finished, no further sends. Both draft and paused ARE valid on create and on PATCH. |
| `campaign_brief` | string | Free-form context every lead in this campaign shares: who they are, why you're reaching out, what to emphasise, what to avoid. Fed to the writer for every message. |
| `personalization_mode` | "personalized" | "template" | Default "personalized" — each prospect gets 1:1 copy written from their own dossier (their brief + person/company enrichment + signals + live website intelligence). Use "template" to send your copy verbatim with merge tokens only. |
| `require_approval` | boolean | When true nothing sends on ANY channel until each lead is approved. The approval gate sits before channel dispatch in the send engine, so email, linkedin_invite and linkedin_message steps are all blocked identically. Unapproved leads are re-checked hourly and carry last_error: "Waiting for approval before sending". Approve in the UI, or via PATCH /outreach/leads/{id} with approval_status: "approved". |
| `steps[]` | object[] | The whole sequence. Each step: { position, action: "email" | "linkedin_invite" | "linkedin_message", delay_days, delay_hours, condition, subject, body, copy_mode, custom_copy, copy_directive, tag_conditions }. |
| `steps[].copy_mode` | "ai" | "customer_template" | "customer_directive" | How this step is written. "ai" = we write it from the dossier. "customer_template" = send your custom_copy exactly (merge tokens rendered). "customer_directive" = we write it but must follow your copy_directive. |
| `steps[].tag_conditions` | { include: string[], exclude: string[] } | Run this step only for leads carrying every include tag and none of the exclude tags. Tags come from the lead brief (auto-extracted) or your own tags[]. |
| `include_unsubscribe_link` | boolean | Default true. Accepted on create and PATCH. false hides only the visible Unsubscribe link in the email body; email steps still send, RFC 8058 List-Unsubscribe headers are always attached, and opt-out replies ("no thanks", "stop", "unsubscribe", "remove me") stop the lead on all channels and fire contact.unsubscribed. You may put your own plain-text opt-out line in the copy. |
| `steps[].condition` | string | Behavioural gate: "always", "if_not_connected", "if_connected", "if_no_reply". |
| `leads[]` | object[] | Leads to add — each needs an email or a linkedin_url. Up to 500 per request. |
| `leads[].lead_brief` | string | The key field for true 1:1 outreach: everything you know about this specific person — had a demo, visited pricing, referred by X, evaluating a competitor, their priorities. Human context outranks everything we research. Aliases: context, notes. |
| `leads[].tags` | string[] | Explicit context tags used for step gating, e.g. ["had_demo", "pricing_intent"]. Merged with tags auto-extracted from the brief. |
| `leads[].step_copy` | object | Per-lead copy overrides keyed by step position: { "1": { "subject": "...", "body": "..." } }. Highest precedence of all — beats step copy and AI. |
| `leads[].external_id` | string | Your own ID. Makes ingestion idempotent — re-posting the same external_id updates that lead instead of duplicating it. |
| `leads[].owner_account_id` | string | Assigns the lead to a salesperson: the id of one of your connected sending accounts (GET /outreach/senders). Every email to that lead goes out from that rep's inbox, so the reply comes back to them. Pass owner_email instead if you only have the rep's address. Aliases: owner_email, owner, assigned_to. |
| `leads[].metadata` | object | Anything else you want stored and available to the writer, e.g. { website, plan, mrr, source }. |
| `events[]` | string[] | Webhook events: "reply.email", "reply.linkedin", "meeting.booked", "unsubscribe". |

### Response Schema

_Complete documented fields for this section, with nested notation preserved. Endpoint-specific envelopes, availability and additional fields are described under each endpoint below._

| Field | Notes |
|-------|-------|
| stats → leads, scheduled_actions, messages_sent, pending_approval, in_progress, completed, replied, stopped (returned on campaign create, campaign GET, and lead ingestion — the authoritative proof of campaign state; all zeros means nothing exists, nothing is queued, nothing was sent) | |
| campaign → id, name, status, campaign_brief, require_approval, personalization_mode, channels, daily_email_limit, daily_linkedin_limit, verified_emails_only, include_unsubscribe_link | |
| steps[] → id, position, action, channel, delay_days, delay_hours, condition, subject, body, copy_mode, custom_copy, copy_directive, tag_conditions | |
| leads[] → id, external_id, full_name, email, linkedin_url, title, company, status, lead_brief, context_tags, tags, owner_account_id, approval_status, personalization_status, next_action_at, replied_at | |
| senders[] → id, channel, provider, identifier, display_name, sender_name, status, is_active, daily_email_limit, emails_sent_today | |
| lead → dossier { summary, hooks[], facts[], company_intel, signals }, step_copy_overrides, metadata | |
| messages[] → id, position, channel, action, subject, body, status, intel_used[] | |
| replies[] → id, campaign_id, contact_id, channel, thread_id, subject, body, from_identifier, from_name, occurred_at | |
| webhook → id, url, events, is_active, secret (returned once, at creation) | |
| deliveries[] → id, event, payload, status, response_status, error, attempts, created_at | |
| reply webhook payload → event, timestamp, workspace_id, data { channel, replied_at, campaign { id, name }, contact { id, full_name, first_name, last_name, email, linkedin_url, company, title, source, lead_brief, context_tags, tags, external_id, metadata }, reply { id, subject, text, full_text, thread_id, from, occurred_at } } | |

**Illustrative Example Response (synthetic, not a complete endpoint schema):**

```json
{
  "data": {
    "stats": {
      "leads": "string",
      "scheduled_actions": "string",
      "messages_sent": "string",
      "pending_approval": "string",
      "in_progress": "string",
      "completed": "string",
      "replied": "string",
      "stopped (returned on campaign create": "string",
      "campaign GET": "string",
      "and lead ingestion — the authoritative proof of campaign state; all zeros means nothing exists": "string",
      "nothing is queued": "string",
      "nothing was sent)": "string"
    },
    "campaign": {
      "id": "abc123",
      "name": "string",
      "status": "string",
      "campaign_brief": "string",
      "require_approval": "string",
      "personalization_mode": "string",
      "channels": "string",
      "daily_email_limit": "user@example.com",
      "daily_linkedin_limit": "string",
      "verified_emails_only": "user@example.com",
      "include_unsubscribe_link": "string"
    },
    "steps": [
      {
        "id": "abc123",
        "position": "string",
        "action": "string",
        "channel": "string",
        "delay_days": "string",
        "delay_hours": "string",
        "condition": "string",
        "subject": "string",
        "body": "string",
        "copy_mode": "string",
        "custom_copy": "string",
        "copy_directive": "string",
        "tag_conditions": "string"
      }
    ],
    "leads": [
      {
        "id": "abc123",
        "external_id": "abc123",
        "full_name": "string",
        "email": "user@example.com",
        "linkedin_url": "https://example.com",
        "title": "string",
        "company": "string",
        "status": "string",
        "lead_brief": "string",
        "context_tags": "string",
        "tags": "string",
        "owner_account_id": "abc123",
        "approval_status": "string",
        "personalization_status": "string",
        "next_action_at": "2025-06-01T12:00:00Z",
        "replied_at": "2025-06-01T12:00:00Z"
      }
    ],
    "senders": [
      {
        "id": "abc123",
        "channel": "string",
        "provider": "string",
        "identifier": "string",
        "display_name": "string",
        "sender_name": "string",
        "status": "string",
        "is_active": false,
        "daily_email_limit": "user@example.com",
        "emails_sent_today": "user@example.com"
      }
    ],
    "lead": {
      "dossier { summary": "string",
      "hooks[]": "string",
      "facts[]": "string",
      "company_intel": "string",
      "signals }": "string",
      "step_copy_overrides": "string",
      "metadata": {
        "title": "string",
        "description": "string",
        "og_image": "https://example.com/og.png"
      }
    },
    "messages": [
      {
        "id": "abc123",
        "position": "string",
        "channel": "string",
        "action": "string",
        "subject": "string",
        "body": "string",
        "status": "string",
        "intel_used[]": "string"
      }
    ],
    "replies": [
      {
        "id": "abc123",
        "campaign_id": "abc123",
        "contact_id": "abc123",
        "channel": "string",
        "thread_id": "abc123",
        "subject": "string",
        "body": "string",
        "from_identifier": "string",
        "from_name": "string",
        "occurred_at": "2025-06-01T12:00:00Z"
      }
    ],
    "webhook": {
      "id": "abc123",
      "url": "https://example.com",
      "events": "string",
      "is_active": false,
      "secret (returned once": "string",
      "at creation)": "string"
    },
    "deliveries": [
      {
        "id": "abc123",
        "event": "string",
        "payload": "string",
        "status": "string",
        "response_status": "string",
        "error": "string",
        "attempts": "string",
        "created_at": "2025-06-01T12:00:00Z"
      }
    ],
    "reply webhook payload": {
      "event": "string",
      "timestamp": "string",
      "workspace_id": "abc123",
      "data { channel": "string",
      "replied_at": "2025-06-01T12:00:00Z",
      "campaign { id": "string",
      "name }": "string",
      "contact { id": "string",
      "full_name": "string",
      "first_name": "string",
      "last_name": "string",
      "email": "user@example.com",
      "linkedin_url": "https://example.com",
      "company": "string",
      "title": "string",
      "source": "string",
      "lead_brief": "string",
      "context_tags": "string",
      "tags": "string",
      "external_id": "abc123",
      "metadata }": "string",
      "reply { id": "string",
      "subject": "string",
      "text": "string",
      "full_text": "string",
      "thread_id": "abc123",
      "from": "string",
      "occurred_at } }": "2025-06-01T12:00:00Z"
    }
  }
}
```

### POST /outreach/campaigns — Create Campaign (with full sequence)

Create a multi-channel campaign and its entire sequence in one call. New campaigns use v2; existing campaigns retain immutable engine_version. A physical sender cannot span v1 and v2 campaigns, including paused campaigns; sender updates obey the same rule. Controlled admin migration moves the entire shared-sender group while paused, retaining campaign/lead IDs, steps, progress, schedule and history. No self-serve engine edit. V2: maximum 5 attempts per campaign and 20 across a run, one attempt per physical sender per five-minute run and a three-minute pacing floor. Sending windows, caps, approval and STOP/reply checks still apply. Steps can use AI, exact copy or copy direction.

**Example Request Body:**

```json
{
  "name": "Q3 no-show re-engagement",
  "status": "active",
  "campaign_brief": "Inbound leads who booked a demo and no-showed. Reference the missed demo warmly, keep it short, goal is to re-book. Never pitch features they haven't asked about.",
  "personalization_mode": "personalized",
  "require_approval": false,
  "daily_email_limit": 50,
  "daily_linkedin_limit": 25,
  "steps": [
    {
      "position": 1,
      "action": "linkedin_invite",
      "delay_days": 0,
      "condition": "if_not_connected",
      "copy_mode": "ai"
    },
    {
      "position": 2,
      "action": "email",
      "delay_days": 1,
      "condition": "if_no_reply",
      "copy_mode": "customer_directive",
      "copy_directive": "Open by naming the exact demo date they missed, one sentence on the outcome they told us they wanted, then ask for 15 minutes. No feature lists."
    },
    {
      "position": 3,
      "action": "email",
      "delay_days": 4,
      "condition": "if_no_reply",
      "copy_mode": "customer_template",
      "subject": "Still worth 15 minutes, {{first_name}}?",
      "custom_copy": "Hi {{first_name}} — closing the loop on the demo we had booked for {{company}}. Happy to re-run it any time this week.",
      "tag_conditions": {
        "include": [
          "had_demo"
        ],
        "exclude": [
          "unsubscribed"
        ]
      }
    },
    {
      "position": 4,
      "action": "linkedin_message",
      "delay_days": 7,
      "condition": "if_connected",
      "copy_mode": "ai"
    }
  ]
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/campaigns",
  "method": "POST",
  "body": {
    "name": "Q3 no-show re-engagement",
    "status": "active",
    "campaign_brief": "Inbound leads who booked a demo and no-showed. Reference the missed demo warmly, keep it short, goal is to re-book. Never pitch features they haven't asked about.",
    "personalization_mode": "personalized",
    "require_approval": false,
    "daily_email_limit": 50,
    "daily_linkedin_limit": 25,
    "steps": [
      {
        "position": 1,
        "action": "linkedin_invite",
        "delay_days": 0,
        "condition": "if_not_connected",
        "copy_mode": "ai"
      },
      {
        "position": 2,
        "action": "email",
        "delay_days": 1,
        "condition": "if_no_reply",
        "copy_mode": "customer_directive",
        "copy_directive": "Open by naming the exact demo date they missed, one sentence on the outcome they told us they wanted, then ask for 15 minutes. No feature lists."
      },
      {
        "position": 3,
        "action": "email",
        "delay_days": 4,
        "condition": "if_no_reply",
        "copy_mode": "customer_template",
        "subject": "Still worth 15 minutes, {{first_name}}?",
        "custom_copy": "Hi {{first_name}} — closing the loop on the demo we had booked for {{company}}. Happy to re-run it any time this week.",
        "tag_conditions": {
          "include": [
            "had_demo"
          ],
          "exclude": [
            "unsubscribed"
          ]
        }
      },
      {
        "position": 4,
        "action": "linkedin_message",
        "delay_days": 7,
        "condition": "if_connected",
        "copy_mode": "ai"
      }
    ]
  }
}'
```

### GET /outreach/campaigns — List Campaigns

All workspace campaigns, immutable engine_version (v1/v2), status and pacing settings. Campaign status: draft, active, paused, completed. Preparation states are separate from lead progress.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/campaigns",
  "method": "GET"
}'
```

### GET /outreach/campaigns/{campaignId} — Get Campaign

One campaign, full sequence and live stats. messages_sent counts stored outbound actions across email and LinkedIn, not proven recipient delivery. Other stats: leads, scheduled_actions, pending_approval, in_progress, completed, replied, stopped. Readback includes next_send_at, last_send_at, min_gap_minutes, max_gap_minutes, ramp_start, ramp_step, activated_at, send_days, send_hour_start, send_hour_end and timezone. PATCH status:paused is the full-channel pause; daily_email_limit:0 blocks email only, not LinkedIn.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/campaigns/{campaignId}",
  "method": "GET"
}'
```

### PATCH /outreach/campaigns/{campaignId} — Update Campaign

Change the brief, pacing, senders, review gate, status, or include_unsubscribe_link. Updating `campaign_brief` rewrites the copy for leads that haven't sent yet. include_unsubscribe_link must be a JSON boolean (true/false; anything else returns 400). false removes only the visible Unsubscribe link from the email body; email steps still send, one-click List-Unsubscribe headers are always attached, and opt-out replies (e.g. "no thanks", "stop", "unsubscribe") still stop the lead on every channel.

**Example Request Body:**

```json
{
  "campaign_brief": "Same segment, but lead with the security review angle this quarter.",
  "require_approval": true,
  "include_unsubscribe_link": false,
  "status": "active"
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/campaigns/{campaignId}",
  "method": "PATCH",
  "body": {
    "campaign_brief": "Same segment, but lead with the security review angle this quarter.",
    "require_approval": true,
    "include_unsubscribe_link": false,
    "status": "active"
  }
}'
```

### PUT /outreach/campaigns/{campaignId}/steps — Replace Sequence

Replace the whole sequence, including your own copy per step. Send the complete `steps[]` array — it overwrites the existing sequence.

**Example Request Body:**

```json
{
  "steps": [
    {
      "position": 1,
      "action": "email",
      "delay_days": 0,
      "condition": "always",
      "copy_mode": "customer_template",
      "subject": "{{first_name}}, quick one about {{company}}",
      "custom_copy": "Hi {{first_name}},\n\nSaw {{company}} is hiring across sales. Worth 15 minutes?\n\n— Koko"
    },
    {
      "position": 2,
      "action": "email",
      "delay_days": 3,
      "condition": "if_no_reply",
      "copy_mode": "ai"
    }
  ]
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/campaigns/{campaignId}/steps",
  "method": "PUT",
  "body": {
    "steps": [
      {
        "position": 1,
        "action": "email",
        "delay_days": 0,
        "condition": "always",
        "copy_mode": "customer_template",
        "subject": "{{first_name}}, quick one about {{company}}",
        "custom_copy": "Hi {{first_name}},\n\nSaw {{company}} is hiring across sales. Worth 15 minutes?\n\n— Koko"
      },
      {
        "position": 2,
        "action": "email",
        "delay_days": 3,
        "condition": "if_no_reply",
        "copy_mode": "ai"
      }
    ]
  }
}'
```

### GET /outreach/campaigns/{campaignId}/steps — Get Sequence

The campaign's steps in order, with copy modes and tag gates.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/campaigns/{campaignId}/steps",
  "method": "GET"
}'
```

### POST /outreach/campaigns/{campaignId}/leads — Add Leads (with per-lead brief and copy)

Push leads into a campaign, each with its own context. For every lead we build a dossier — your brief + person and company enrichment + signals + a live crawl of their website — then write that person's whole sequence against it. Pass `step_copy` to hard-override any step for one lead.

Limits: Up to 500 leads per request.
Idempotency: Always pass `external_id` (your own CRM ID). Re-posting the same `external_id` updates the existing lead instead of creating a duplicate. Leads without `external_id` are always inserted as new rows, so a retry after a timeout can duplicate them.
Timeout / retry: If the HTTP request times out, retry with the same payload. The first call may have already succeeded; the second call will return the same lead row because of `external_id`. The response includes `added` and the full `leads[]` array so you can verify by matching `external_id` to the returned `id`.

**Example Request Body:**

```json
{
  "leads": [
    {
      "external_id": "crm-8841",
      "first_name": "Jesse",
      "last_name": "Roberts",
      "email": "jesse@acme.com",
      "linkedin_url": "https://www.linkedin.com/in/jesseroberts",
      "company": "Acme",
      "title": "VP Sales",
      "lead_brief": "Sat through a demo on July 9 with two of his AEs. Loved the LinkedIn hot-lead signals, worried about data coverage in EMEA. Visited the pricing page twice since. Referred in by Dana at Northwind.",
      "tags": [
        "had_demo",
        "pricing_intent"
      ],
      "metadata": {
        "website": "acme.com",
        "region": "EMEA",
        "plan_interest": "growth"
      }
    },
    {
      "external_id": "crm-8842",
      "first_name": "Priya",
      "email": "priya@northwind.io",
      "company": "Northwind",
      "title": "Head of Growth",
      "lead_brief": "Cold. Downloaded the outbound benchmark report, no demo yet. Runs a 4-person SDR team on Apollo and complains about bounce rates.",
      "step_copy": {
        "1": {
          "subject": "Priya — the bounce rate thing",
          "body": "Hi Priya, you mentioned bounce rates on your Apollo lists. We verify every address before it sends. Worth a look?"
        }
      }
    }
  ]
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/campaigns/{campaignId}/leads",
  "method": "POST",
  "body": {
    "leads": [
      {
        "external_id": "crm-8841",
        "first_name": "Jesse",
        "last_name": "Roberts",
        "email": "jesse@acme.com",
        "linkedin_url": "https://www.linkedin.com/in/jesseroberts",
        "company": "Acme",
        "title": "VP Sales",
        "lead_brief": "Sat through a demo on July 9 with two of his AEs. Loved the LinkedIn hot-lead signals, worried about data coverage in EMEA. Visited the pricing page twice since. Referred in by Dana at Northwind.",
        "tags": [
          "had_demo",
          "pricing_intent"
        ],
        "metadata": {
          "website": "acme.com",
          "region": "EMEA",
          "plan_interest": "growth"
        }
      },
      {
        "external_id": "crm-8842",
        "first_name": "Priya",
        "email": "priya@northwind.io",
        "company": "Northwind",
        "title": "Head of Growth",
        "lead_brief": "Cold. Downloaded the outbound benchmark report, no demo yet. Runs a 4-person SDR team on Apollo and complains about bounce rates.",
        "step_copy": {
          "1": {
            "subject": "Priya — the bounce rate thing",
            "body": "Hi Priya, you mentioned bounce rates on your Apollo lists. We verify every address before it sends. Worth a look?"
          }
        }
      }
    ]
  }
}'
```

### GET /outreach/campaigns/{campaignId}/leads — List Leads

Paginated leads in a campaign with their brief, tags, approval and personalization state.

**Query Parameters:**

- `limit`: Page size, max 500.
- `offset`: Pagination offset.
- `status`: Filter by lead status (pending, active, replied, stopped, completed).
- `tag`: Only leads carrying this context tag.
- `owner`: Only leads owned by this salesperson — pass a sending account id, the rep's inbox address, or "unassigned".

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/campaigns/{campaignId}/leads",
  "method": "GET"
}'
```

### GET /outreach/senders — List Salespeople (Sending Accounts)

Every connected inbox and LinkedIn profile in the workspace. Use the returned ids as a lead's owner_account_id so one company-wide campaign can be run by an admin while each lead stays with its own rep. Each sender includes `daily_limits` (cap and today's usage) and, for email inboxes, a `health` summary (score, status, inbox_placement_pct, delivered_pct, bounce_rate_pct, issues).

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/senders",
  "method": "GET"
}'
```

### PATCH /outreach/senders/{senderId} — Update Daily Sending Limits

Set how many emails, LinkedIn connection requests or LinkedIn messages one sender may send per day. Email inboxes accept `daily_email_limit` (1–500; Bytemine-managed inboxes max 30). LinkedIn profiles accept `daily_invite_limit` (1–100) and/or `daily_message_limit` (1–150). Values must be whole numbers; fields that don't match the sender's channel return 400. The new cap applies from the next send in any campaign using this sender; today's sent count is kept and counters reset each day, so lowering a cap below today's usage pauses that sender until tomorrow. Campaign daily limits, pacing and safety checks still apply on top. Editing a managed inbox's cap during its post-warm-up ramp stops the automatic ramp from changing it.

**Example Request Body:**

```json
{
  "daily_invite_limit": 20,
  "daily_message_limit": 40
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/senders/{senderId}",
  "method": "PATCH",
  "body": {
    "daily_invite_limit": 20,
    "daily_message_limit": 40
  }
}'
```

### GET /outreach/senders/health — Email Health for All Inboxes

Health report for every connected email inbox. Each entry: `score` (0–100) and `status` (healthy ≥85, fair ≥65, at_risk ≥40, poor); `landing` (inbox_placement_pct and spam_pct from warm-up placement tests, null if the inbox has none); `deliverability` (delivered_pct, bounce_rate_pct, sent_30d, sent_7d — campaign sends only); `bounces` (total_30d, bounce_notices_30d, hard_7d, soft_7d); `complaints` (count_7d, rate_pct); `engagement` (replies_30d, reply_rate_pct); `authentication` (SPF, DKIM, DMARC policy, MX from public DNS; rechecked live when the stored check is older than 24 hours or found no DKIM key, across 40 common DKIM selectors); and `issues` codes such as high_bounce_rate, low_inbox_placement, spf_missing, dmarc_missing, dkim_not_found, disconnected. Read-only; computed live.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/senders/health",
  "method": "GET"
}'
```

### PATCH /outreach/campaigns/{campaignId} — Campaign Reply, Bounce and Stuck-Lead Options

Optional per-campaign behaviour, merged into the campaign's settings (other settings are kept). `stop_company_on_reply` (true/false, default false): when any lead replies, every other unfinished lead at the same company in this campaign is stopped (status `stopped`, last_error `company_replied`). Company = work email domain, or company name when there is no work email. `bounce_behavior` (`stop_lead` default, or `email_only`): with `email_only`, a hard bounce skips that lead's remaining email steps and LinkedIn steps still run; if no LinkedIn steps remain the lead stops with last_error `email_bounced`. `stuck_alert_hours` (1–168, default 4, null = off): hours past a lead's due time before a `lead.stuck` webhook fires (webhook must subscribe to `lead.stuck`).

**Example Request Body:**

```json
{
  "stop_company_on_reply": true,
  "bounce_behavior": "email_only",
  "stuck_alert_hours": 4
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/campaigns/{campaignId}",
  "method": "PATCH",
  "body": {
    "stop_company_on_reply": true,
    "bounce_behavior": "email_only",
    "stuck_alert_hours": 4
  }
}'
```

### PATCH /outreach/leads/{leadId} — Set a Lead Start Date

`start_at` (ISO 8601 date-time, or null to clear) — the lead's first step will not go out before this time. Also accepted on each lead when adding leads (POST /outreach/campaigns/{campaignId}/leads). Sending windows, approvals, daily limits and pacing still apply, so the first touch goes out at the first allowed slot on or after start_at. Changing start_at after step 1 has gone out has no effect on later steps.

**Example Request Body:**

```json
{
  "start_at": "2026-12-01T14:00:00Z"
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/leads/{leadId}",
  "method": "PATCH",
  "body": {
    "start_at": "2026-12-01T14:00:00Z"
  }
}'
```

### GET /outreach/senders/{senderId}/health — Email Health for One Inbox

Same health report as above for a single email inbox. Returns 404 for LinkedIn senders or unknown ids.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/senders/{senderId}/health",
  "method": "GET"
}'
```

### POST /outreach/senders/connect — Connect a LinkedIn Profile or Email Inbox

Start a hosted OAuth connection for a new sender. The response contains a `url` — redirect your user's browser to it. After the OAuth handshake, Bytemine redirects the browser to your `success_redirect_url` (or `failure_redirect_url`) with `bytemine_link_id`, `bytemine_status`, and optional `bytemine_error` query parameters. The account is also mirrored as a sending account automatically and can be used for outreach as soon as the webhook confirms the connection.

**Example Request Body:**

```json
{
  "channel": "linkedin",
  "provider": "LINKEDIN",
  "success_redirect_url": "https://app.yoursaas.com/settings/connected-accounts?connected=1",
  "failure_redirect_url": "https://app.yoursaas.com/settings/connected-accounts?error=1"
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/senders/connect",
  "method": "POST",
  "body": {
    "channel": "linkedin",
    "provider": "LINKEDIN",
    "success_redirect_url": "https://app.yoursaas.com/settings/connected-accounts?connected=1",
    "failure_redirect_url": "https://app.yoursaas.com/settings/connected-accounts?error=1"
  }
}'
```

### GET /outreach/senders/connect/{linkId} — Get Connection Link Status

Poll a pending connection. The same link is also returned via the OAuth redirect and through the webhook.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/senders/connect/{linkId}",
  "method": "GET"
}'
```

### DELETE /outreach/senders/connect/{linkId} — Cancel Pending Connection Link

Delete a connection link that hasn't been completed yet. Doesn't disconnect an already-matured account.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/senders/connect/{linkId}",
  "method": "DELETE"
}'
```

### POST /outreach/senders/sync — Refresh Connected Accounts

Trigger a background sync with the provider to pull the latest connected accounts into the workspace. Useful after a user completes OAuth.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/senders/sync",
  "method": "POST"
}'
```

### DELETE /outreach/senders/{senderId} — Disconnect a Sending Account

Remove an account from the workspace. Email or LinkedIn messages already in flight will not be cancelled; future sends are blocked.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/senders/{senderId}",
  "method": "DELETE"
}'
```

### POST /outreach/campaigns/{campaignId}/leads/assign — Assign Leads to a Salesperson

Bulk (re)assign lead ownership. Pass lead_ids[] for specific leads, or only_unassigned: true to hand every unowned lead to one rep. Set owner to "unassigned" to clear ownership and fall back to sender rotation.

**Example Request Body:**

```json
{
  "owner_email": "rep@acme.com",
  "lead_ids": [
    "0f2c…",
    "8a91…"
  ]
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/campaigns/{campaignId}/leads/assign",
  "method": "POST",
  "body": {
    "owner_email": "rep@acme.com",
    "lead_ids": [
      "0f2c…",
      "8a91…"
    ]
  }
}'
```

### GET /outreach/leads/{leadId} — Get Lead + Dossier

One lead with the dossier we built for it — the summary, the hooks we found, the facts we will use, and any copy overrides.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/leads/{leadId}",
  "method": "GET"
}'
```

### GET /outreach/leads/{leadId}/messages — Get Lead's Generated Copy

Every message written for this prospect, step by step, including the intel each one used. Use this to review before approving.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/leads/{leadId}/messages",
  "method": "GET"
}'
```

### POST /outreach-integration-api — Outreach Identity, Event History & LinkedIn Evidence

Live isolated integration API. Call this function directly, not api-gateway, with your existing active workspace API key and {path,method,body}. Routes: /v1/outreach/events (GET); /v1/outreach/leads/{id}/linkedin-diagnostics (GET); /v1/outreach/leads/{id} (GET or identity-only PATCH). Identity PATCH accepts full_name, first_name, last_name, external_id (string or explicit null); omitted fields survive. No lookup, copy generation, re-add or resume is queued. Recipient, owner, tags, copy, approval and progress stay unchanged. Use the existing gateway for copy/brief changes: those queue preparation and may require renewed approval.

Events accept limit 1–500 (default 100), campaign_id, lead_id and opaque cursor in the path query. Returns events, snapshot_at, has_more, next_cursor. Each event includes reply_text: the exact stored inbound body for reply.email/reply.linkedin, null otherwise. It may contain HTML and quoted history; treat it as untrusted content. Reply events also include reply_text_plain (HTML and quoted history removed), auto_reply / out_of_office, mailbox {id,address,channel} and step_number (1-based last step sent before the reply). Workspace, direction, campaign, lead and channel are checked before exposing text. Keep filters unchanged and continue until has_more=false and next_cursor=null. Stable event IDs; recorded_at keyset order; occurred_at is observed event time (bounce uses received_at). Email provider acceptance is not delivery. Retained records include enrollments, email/LinkedIn outbound records, replies and captured hard/soft bounces; ambiguous bounce attribution stays null. Delivery and historical connection acceptances are incomplete. Exhausted pages prove retained-record coverage only, not events never stored or since deleted. Warm-up and delivery notices are not replies.

LinkedIn diagnostics returns separate owner selection, sender-limit and connection proofs. No email-to-LinkedIn mapping or combined 15-action/day cap exists; configured invite and message limits are separate. Missing proof is unknown. Messages/if_connected require fresh exact-sender first-degree proof. Zero delay does not bypass schedule, approval, STOP/reply, caps or three-minute pacing. No provider calls, invitations, messages or send authorization.

**Example Request Body:**

```json
{
  "path": "/v1/outreach/events?limit=100",
  "method": "GET"
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/outreach-integration-api' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/v1/outreach/events?limit=100",
  "method": "GET"
}'
```

### PATCH /outreach/leads/{leadId} — Update Lead Brief / Approve

Update brief, owner, tags, copy or approval using the existing gateway. Brief changes rebuild dossier and copy; step_copy/step_copy_overrides queues personalization and can reset required approval. To restore identity without queuing work, use the isolated outreach-integration-api identity PATCH documented above. Do not re-add or resume an existing lead just to change names. Name support in the mixed gateway is source-only pending a verified isolated gateway release.

**Example Request Body:**

```json
{
  "lead_brief": "Update: re-booked the demo for Aug 21 and asked for an EMEA coverage breakdown beforehand.",
  "tags": [
    "had_demo",
    "meeting_booked"
  ],
  "owner_email": "rep@acme.com",
  "approval_status": "approved"
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/leads/{leadId}",
  "method": "PATCH",
  "body": {
    "lead_brief": "Update: re-booked the demo for Aug 21 and asked for an EMEA coverage breakdown beforehand.",
    "tags": [
      "had_demo",
      "meeting_booked"
    ],
    "owner_email": "rep@acme.com",
    "approval_status": "approved"
  }
}'
```

### DELETE /outreach/leads/{leadId} — Stop Lead

Immediately stop all future sends for one lead. Nothing else in the campaign is affected.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/leads/{leadId}",
  "method": "DELETE"
}'
```

### POST /outreach/exclusions — Add Excluded Companies

One master exclusion list per workspace. Any lead whose company domain, work email domain, or company name matches an entry is never enrolled and never sent to, in every campaign and everywhere leads enter the system. Subdomains of an excluded domain are covered automatically, and free mailbox domains (gmail.com and similar) are ignored so you can't block a whole consumer provider by accident.

Accepts `domains: ["acme.com"]` (URLs and emails are normalized to their domain) or `companies: [{ domain, company_name, reason }]` for richer entries. Re-posting the same domain updates the existing entry, so uploads are safe to retry. Max 5000 entries per request. No credits.

**Example Request Body:**

```json
{
  "domains": [
    "acme.com",
    "https://www.competitor.io",
    "someone@bigcorp.com"
  ],
  "reason": "Existing customer"
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/exclusions",
  "method": "POST",
  "body": {
    "domains": [
      "acme.com",
      "https://www.competitor.io",
      "someone@bigcorp.com"
    ],
    "reason": "Existing customer"
  }
}'
```

### GET /outreach/exclusions — List Excluded Companies

Every company on the workspace exclusion list with its domain, company name, reason and source.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/exclusions",
  "method": "GET"
}'
```

### DELETE /outreach/exclusions — Remove Excluded Companies

Remove entries with `?domain=acme.com`, a body of `{ "domains": ["acme.com", "competitor.io"] }`, or clear the whole list with `?all=true`.

**Query Parameters:**

- `domain`: Single domain to remove.
- `all`: Clear the entire exclusion list.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/exclusions",
  "method": "DELETE"
}'
```

### GET /outreach/replies — List Replies

Poll every inbound reply across email and LinkedIn. Prefer the webhook below for real-time delivery into your CRM.

**Query Parameters:**

- `limit`: Max 200.
- `since`: Only replies after this timestamp.
- `campaign_id`: Restrict to one campaign.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/replies",
  "method": "GET"
}'
```

### POST /outreach/webhooks — Create Reply Webhook

We POST to your endpoint the moment a prospect replies, books, or unsubscribes, so your CRM owns the conversation from there.

Payload: `event`, `timestamp`, `workspace_id`, and `data` containing `channel`, `replied_at`, `campaign { id, name }`, `contact { id, full_name, first_name, last_name, email, linkedin_url, company, title, source, lead_brief, context_tags, tags, external_id, metadata }`, `reply { id, subject, text, full_text, text_plain, thread_id, from, occurred_at, classification, out_of_office, auto_reply }`, `step_number` (1-based last step sent before the reply; `step_index` is 0-based), and `mailbox { id, address, channel }` that received the reply. `text_plain` has HTML and quoted earlier messages removed.

Opt-in events (list them in `events` to receive them): `step.skipped`, `email.bounced`, `invite.accepted`, and `lead.stuck` — fired once per due time when an approved lead is still unsent `stuck_alert_hours` (default 4) after its due time; data has `campaign`, `lead`, `step_index`, `due_at`, `hours_overdue`, `threshold_hours`, `hold_reason`.

Signature: `x-bytemine-signature` = HMAC-SHA256(`{timestamp}.{rawBody}`) using your secret, plus `x-bytemine-timestamp` and `x-bytemine-event`.

Retries: Failed deliveries retry 3 times with exponential backoff (0s, 2s, 8s). Inspect delivery logs via `GET /outreach/webhooks/{webhookId}/deliveries`.

Sequence stop: A reply automatically marks the lead as `replied` and clears `next_action_at`, so no remaining campaign steps are sent to that prospect.

**Example Request Body:**

```json
{
  "url": "https://api.yourcrm.com/hooks/bytemine-outreach",
  "events": [
    "reply.email",
    "reply.linkedin",
    "contact.unsubscribed"
  ],
  "description": "Push replies into HubSpot"
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/webhooks",
  "method": "POST",
  "body": {
    "url": "https://api.yourcrm.com/hooks/bytemine-outreach",
    "events": [
      "reply.email",
      "reply.linkedin",
      "contact.unsubscribed"
    ],
    "description": "Push replies into HubSpot"
  }
}'
```

### GET /outreach/webhooks — List Webhooks

All reply webhooks configured for your workspace.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/webhooks",
  "method": "GET"
}'
```

### GET /outreach/webhooks/{webhookId}/deliveries — List Webhook Deliveries

Delivery log for one webhook, including the payload we sent, HTTP response status, error, and retry attempts. Use this to debug missed or failed hooks.

**Query Parameters:**

- `limit`: Page size, max 200.
- `offset`: Pagination offset.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/webhooks/{webhookId}/deliveries",
  "method": "GET"
}'
```

### PATCH /outreach/webhooks/{webhookId} — Update Webhook

Change the URL, the events, or pause delivery.

**Example Request Body:**

```json
{
  "events": [
    "reply.email",
    "reply.linkedin"
  ],
  "is_active": true
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/webhooks/{webhookId}",
  "method": "PATCH",
  "body": {
    "events": [
      "reply.email",
      "reply.linkedin"
    ],
    "is_active": true
  }
}'
```

### DELETE /outreach/webhooks/{webhookId} — Delete Webhook

Remove a webhook endpoint.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/webhooks/{webhookId}",
  "method": "DELETE"
}'
```

### GET /outreach/opt-outs — List Opt-Outs

Everyone your workspace must never contact again, across every campaign and channel. Aliases: /outreach/optouts and /outreach/unsubscribes behave identically. Free.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/opt-outs",
  "method": "GET"
}'
```

### POST /outreach/opt-outs — Add Opt-Outs

Suppress people workspace-wide: stop every running sequence for them and block future contact on all channels. Accept emails, LinkedIn URLs and/or lead IDs in one call, with an optional reason. Free.

**Example Request Body:**

```json
{
  "emails": [
    "jane@acme.com"
  ],
  "linkedin_urls": [
    "linkedin.com/in/janedoe"
  ],
  "reason": "requested removal"
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/opt-outs",
  "method": "POST",
  "body": {
    "emails": [
      "jane@acme.com"
    ],
    "linkedin_urls": [
      "linkedin.com/in/janedoe"
    ],
    "reason": "requested removal"
  }
}'
```

### DELETE /outreach/opt-outs — Remove Opt-Out

Delete a suppression entry — for example to correct a false positive. Use with care: the person becomes contactable again. Pass ?email=… or ?linkedin_url=… (also accepted in the body). Free.

**Query Parameters:**

- `email`: Suppressed email to remove (or use linkedin_url).

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/opt-outs",
  "method": "DELETE"
}'
```

### DELETE /outreach/exclusions/{domain} — Remove Company Exclusion

Remove one company from your master exclusion list. Alternatives: ?domain=acme.com, a body of { domains: [...] }, or ?all=true to clear the whole list. Free.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/exclusions/{domain}",
  "method": "DELETE"
}'
```

### GET /outreach/domains/config — Get Domains Config

Current managed-domain program configuration: whether provisioning is configured, the per-inbox monthly price and markups, and per-order caps. Free.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/domains/config",
  "method": "GET"
}'
```

### GET /outreach/domains/check — Check Domain

Live availability and purchase price for one domain. .ai endings are not supported. Free.

**Query Parameters:**

- `domain`: Domain to check (required).

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/domains/check",
  "method": "GET"
}'
```

### GET /outreach/domains/suggest — Suggest Domains

Alternative domain suggestions for a keyword, each with its price. Free.

**Query Parameters:**

- `keyword`: Base keyword (required).
- `tld`: Desired ending, default com.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/domains/suggest",
  "method": "GET"
}'
```

### GET /outreach/domain-orders — List Domain Orders

Your domain orders and provisioned inboxes: status, costs, errors and warm-up progress. Free.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/domain-orders",
  "method": "GET"
}'
```

### POST /outreach/domain-orders — Create Domain Order

Start an order for managed sending domains plus inboxes. Every domain must include at least one inbox. Returns a Stripe Checkout URL (order_id, url) — purchases are billed by Stripe at the published per-item prices, never with data credits.

**Example Request Body:**

```json
{
  "domains": [
    "acme.com"
  ],
  "inboxes": [
    {
      "domain": "acme.com",
      "email": "lara@acme.com",
      "first_name": "Lara",
      "last_name": "Hodgson"
    }
  ]
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/domain-orders",
  "method": "POST",
  "body": {
    "domains": [
      "acme.com"
    ],
    "inboxes": [
      {
        "domain": "acme.com",
        "email": "lara@acme.com",
        "first_name": "Lara",
        "last_name": "Hodgson"
      }
    ]
  }
}'
```

### POST /outreach/domain-orders/{orderId}/confirm — Confirm Order Payment

Confirm and return the order's payment status after checkout.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/domain-orders/{orderId}/confirm",
  "method": "POST"
}'
```

### POST /outreach/domain-orders/{orderId}/checkout — Resume Order Checkout

Get a checkout URL again for an order still awaiting payment (returns the existing open session when present).

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/domain-orders/{orderId}/checkout",
  "method": "POST"
}'
```

### POST /outreach/domain-orders/{orderId}/cancel — Cancel Order

Cancel an order that is still awaiting payment.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/domain-orders/{orderId}/cancel",
  "method": "POST"
}'
```

### GET /outreach/inboxes — List Managed Inboxes

Your provisioned sending inboxes with warm-up progress and readiness. Free.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/inboxes",
  "method": "GET"
}'
```

### PATCH /outreach/inboxes/{inboxId} — Update Inbox Forwarding

Set or clear the forwarding address for a managed inbox; replies route to it.

**Example Request Body:**

```json
{
  "forwarding_email": "you@company.com"
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/inboxes/{inboxId}",
  "method": "PATCH",
  "body": {
    "forwarding_email": "you@company.com"
  }
}'
```

### DELETE /outreach/inboxes/{inboxId} — Remove Inbox

Remove a managed inbox (workspace admins only). Cancels its subscription line item.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/inboxes/{inboxId}",
  "method": "DELETE"
}'
```

### DELETE /outreach/campaigns/{campaignId} — Stop Campaign

Soft-stop a campaign: it is set to paused and the engine stops picking it up. No leads, steps or history are deleted — resume anytime with PATCH status.

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/campaigns/{campaignId}",
  "method": "DELETE"
}'
```

### POST /outreach/leads/{leadId}/stop — Stop Lead

Halt every remaining action for one lead on all channels (email and LinkedIn) without suppressing the person. Pending and queued messages are cancelled. Optional reason is stored on the lead. Free.

**Example Request Body:**

```json
{
  "reason": "customer asked to pause"
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/leads/{leadId}/stop",
  "method": "POST",
  "body": {
    "reason": "customer asked to pause"
  }
}'
```

### POST /outreach/leads/{leadId}/resume — Resume Lead

Restart one stopped or skipped lead without touching the rest of the campaign. Optional step (1-based position) rewinds to retry a skipped step; optional recheck_email re-verifies the address. The lead becomes due immediately. Replied or unsubscribed leads cannot be resumed (409). Free.

**Example Request Body:**

```json
{
  "step": 2,
  "recheck_email": true
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/leads/{leadId}/resume",
  "method": "POST",
  "body": {
    "step": 2,
    "recheck_email": true
  }
}'
```

### POST /outreach/leads/{leadId}/unsubscribe — Unsubscribe Lead

Opt one lead out for the whole workspace: stops all their sequences and blocks future contact on every campaign and channel. Free.

**Example Request Body:**

```json
{
  "reason": "unsubscribed via reply"
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/outreach/leads/{leadId}/unsubscribe",
  "method": "POST",
  "body": {
    "reason": "unsubscribed via reply"
  }
}'
```

