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

# Streams, audiences, and campaigns

> Separate transactional and broadcast traffic, retain consent evidence, and send template-backed campaigns with unsubscribe protection.

<Tip>
  **Live.** This area is documented as current, user-reliable behavior.
</Tip>

## Goal

Operate consent-backed broadcast mail without mixing it with application-triggered transactional traffic.

## Prerequisites

* A verified sender domain
* An active template
* Recipient consent source and timestamp evidence

## Workflow

<Steps>
  <Step>
    Use the protected transactional and broadcast streams, or create a custom stream of either type.
  </Step>

  <Step>
    Create an audience and import between 1 and 10,000 normalized, consent-evidenced members per request.
  </Step>

  <Step>
    Create a draft campaign with an audience, template, optional pinned version, and verified sender.
  </Step>

  <Step>
    Send the draft once, then inspect its batch, recipient items, events, and webhook deliveries.
  </Step>
</Steps>

## Traffic isolation

* Transactional streams are for user or application-triggered messages.
* Broadcast streams are for one-to-many communication and require unsubscribe behavior.
* The built-in transactional and broadcast streams are protected; custom streams retain the policy of their selected type.

## Consent-backed audience import

```ts theme={null}
const audience = await stackshift.mail.audiences.create({ name: 'Early access' })
await stackshift.mail.audiences.import(audience.id, [{
  email: 'ada@example.net',
  consentSource: 'website_waitlist',
  consentAt: '2026-08-18T10:00:00Z',
}])
```

## Campaign lifecycle

* Member states include subscribed, unsubscribed, complained, and hard\_bounced.
* Campaign states include draft, processing, queued, completed, and failed.
* A queued campaign references the resulting batch for recipient-level inspection.
* Campaign delivery uses the broadcast stream, campaign tags, list-unsubscribe behavior, and deterministic member idempotency keys.

## Expected result

<Check>
  Only sendable, consented members enter a broadcast batch with deterministic idempotency and unsubscribe behavior.
</Check>

## Common failures

<Warning>
  * Missing consent source or timestamp
  * Duplicate addresses in one import
  * Sending an archived or empty audience
  * Exceeding the configured batch recipient limit
</Warning>

## Related guides

<CardGroup cols={2}>
  <Card title="Templates and OTP" href="/stackshift-mail/templates-and-otp">
    Create versioned templates, preview and test them, send from a template, and use the built-in one-time-code challenge flow.
  </Card>

  <Card title="Events, webhooks, and timelines" href="/stackshift-mail/events-webhooks-and-timelines">
    List mail events, inspect per-message timelines, subscribe webhooks, rotate secrets, retry deliveries, and verify webhook signatures.
  </Card>

  <Card title="Bounces, suppressions, and reputation" href="/stackshift-mail/bounces-suppressions-and-reputation">
    Handle hard and soft bounces, workspace-scoped suppressions, sending limits, warmup stage, domain reputation, and reputation events.
  </Card>
</CardGroup>
