---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://segmentstream.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Email SDK

Declare outbound senders and validate the email manifest captured by a workspace deployment.

## What you can build

- [Declare an outbound sender](https://segmentstream.com/docs/sdk/email#declare-a-notification-sender)

  Give each sender a stable key, address local part and display name.

- [Set replies and limits](https://segmentstream.com/docs/sdk/email#declare-a-notification-sender)

  Choose where replies go and set daily or per-second recipient limits.

- [Check configuration in CI](https://segmentstream.com/docs/sdk/email#validate-the-manifest-locally)

  Validate the manifest and use structured issues to find an invalid field.

## Create a workspace email declaration

Install the SDK in the repository’s root email/ package and commit its lockfile. The workspace reads email/index.ts on a production Git deployment. The sender key is what workspace code refers to. The local part is the portion of its assigned address before @.

Terminal · email/

```
npm install @segmentstream/email
```

## Declare a notification sender

The reply-to address can be an existing support mailbox. The optional limits count recipients and can lower the platform caps.

email/index.ts

```
import { defineEmail } from "@segmentstream/email";

export default defineEmail({
  senders: {
    notifications: {
      localPart: "notifications",
      displayName: "Support",
      replyTo: "support@example.com",
    },
  },
  limits: { daily: 100, perSecond: 2 },
});
```

## Validate the manifest locally

Check the declaration in a TypeScript test. The result contains the sender definition and limits. An invalid declaration throws EmailConfigurationError with an issues array that identifies the field. To exercise that path, try two senders with the same localPart.

email/manifest.test.ts

```
import assert from "node:assert/strict";
import { createEmailManifest, parseEmailManifest } from "@segmentstream/email";
import configuration from "./index";

const manifest = createEmailManifest(configuration);
assert.equal(manifest.version, 1);
assert.deepEqual(parseEmailManifest(manifest), manifest);
```

## Selected API methods and types

### Declare a sender · `defineEmail`

Validate and snapshot a declaration without credentials or provider I/O.

```
function defineEmail(configuration: EmailConfiguration): EmailConfiguration;
```

### Build the manifest · `createEmailManifest`

Produce a deterministic manifest; sender domains are assigned by the platform.

```
function createEmailManifest(configuration: EmailConfiguration): EmailManifest;
```

### Validate a serialized manifest · `parseEmailManifest`

Validate an untrusted deployment artifact against this manifest version.

```
function parseEmailManifest(input: unknown): EmailManifest;
```

[Check a deployment](https://segmentstream.com/docs/check-a-deployment)

[Read as Markdown ↗](https://segmentstream.com/docs/sdk/email.md)
