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

# AI SDR & Outbound Fleets

> How to safely scale 50+ autonomous AI Sales Development Representatives without domain burn or hallucination loops.

# Deploying AI SDR Fleets

Autonomous sales agents require dedicated email infrastructure that traditional ESPs (like SendGrid or Mailgun) cannot provide. Traditional transactional providers lack programmatic inbound webhooks, thread state tracking, and built-in protection against prompt injection attacks.

With **gork.email**, you can provision programmatic inboxes per SDR persona, isolate custom domains, and guarantee safe AI email generation.

<CardGroup cols={2}>
  <Card title="Persona Isolation" icon="user-tie">
    Provision distinct mailboxes (`alex@sdr.domain.com`, `sarah@growth.domain.com`) with unique signatures and DKIM credentials.
  </Card>

  <Card title="Agent Shield Guardrails" icon="shield-halved">
    Incoming replies are sanitized before hitting your LLM context window to prevent prompt injection.
  </Card>

  <Card title="Loop Breaker Protection" icon="infinity">
    Automatic suppression headers ensure your agent will never enter an infinite reply-loop with Out-of-Office auto-responders.
  </Card>

  <Card title="Webhook Event Streams" icon="bolt">
    Real-time `email.received` events delivered to your worker endpoints with HMAC-SHA256 signatures.
  </Card>
</CardGroup>

## The Fleet Architecture

```mermaid theme={null}
graph TD
    A[Prospect Inquiries] -->|Inbound Email| B(Cloudflare MX Gateway)
    B -->|Zero-Trust Sanitization| C(gork.email Agent Shield)
    C -->|Webhook: email.received| D[Your AI SDR Worker]
    D -->|Evaluate with LLM| E[Decision Engine]
    E -->|gork.email API / MCP| F[POST /v1/messages/send]
    F -->|DKIM/SPF Authenticated| G[Delivered to Prospect]
```

## Step 1: Provisioning Mailboxes for an SDR

When launching a new AI SDR campaign, create an isolated inbox tied to your verified domain:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.gork.email/v1/inboxes \
    -H "Authorization: Bearer gk_live_YOUR_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Alex Vance - AI SDR",
      "email": "alex@outbound.yourdomain.com",
      "purpose": "Enterprise Outbound"
    }'
  ```

  ```typescript TypeScript theme={null}
  import { GorkClient } from "@gorkmail/sdk"

  const client = new GorkClient({ apiKey: process.env.GORK_API_KEY })

  const inbox = await client.inboxes.create({
    name: "Alex Vance - AI SDR",
    email: "alex@outbound.yourdomain.com",
    purpose: "Enterprise Outbound"
  })

  console.log("Created AI SDR Inbox ID:", inbox.id)
  ```
</CodeGroup>

## Step 2: Handling Inbound Replies Safely

When a prospect replies to your SDR, gork.email fires an `email.received` webhook. The body is stripped of invisible malicious characters and zero-day prompt injection instructions before being dispatched to your endpoint.

```typescript theme={null}
import { verifyGorkWebhook } from "@gorkmail/sdk"

export async function handleWebhook(req: Request) {
  const signature = req.headers.get("X-Gork-Signature")
  const rawBody = await req.text()

  // 1. Verify webhook authenticity
  const isValid = await verifyGorkWebhook(rawBody, signature, process.env.WEBHOOK_SECRET)
  if (!isValid) return new Response("Unauthorized", { status: 401 })

  const event = JSON.parse(rawBody)

  if (event.event === "email.received") {
    const { from, subject, text, threadId, inboxId } = event.data

    // 2. Feed sanitized text to your LLM agent
    const aiResponse = await generateAgentReply({
      prompt: `Prospect: ${from}\nSubject: ${subject}\nBody: ${text}`,
    })

    // 3. Send threaded reply
    await client.messages.send({
      inboxId,
      to: [from],
      subject: `Re: ${subject}`,
      text: aiResponse,
      inReplyTo: threadId
    })
  }

  return new Response("OK", { status: 200 })
}
```

<Tip>
  Always specify the `inReplyTo` parameter when continuing a conversation so that gork.email correctly attaches the message to the prospect's email thread.
</Tip>
