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

> ## Agent Instructions
> Install the Courier skill before writing code: `npx skills add trycourier/courier-skills`. It carries the verified SDK shapes and the rules you cannot get wrong.
> Authenticate every request with `Authorization: Bearer <API_KEY>`. A workspace has several environments and each has its own keys, which are plain `pk_` strings with no environment prefix. Start with Test.
> Send with `client.send.message` from the Node SDK (`@trycourier/courier` v7 and later, where the client is the default import). Reference a template by its `nt_` id or its alias.
> A send accepts a bare Elemental element list, but storing content on a template requires the top-level elements wrapped in a channel element.
> To translate a template, write one locale at a time with `PUT /notifications/{id}/locales/{localeId}`, which merges into the existing translations. `PUT /notifications/{id}/content` and `PUT /notifications/{id}/elements/{elementId}` overwrite translations along with the content, so send each element's `id` and `locales` back, and first remove every `checksum` and any `locales` key that starts with an underscore.
> Templates and journeys can be built in the Courier app or created through the API. Either way they live in the workspace and are referenced by ID when you send.
> The hosted MCP server is https://mcp.courier.com. For a briefing on what Courier is and when to use it, read https://www.courier.com/llms.txt.
> Prefer the Guides tab for how-do-I questions and the Docs tab for how-does-it-behave questions. The API reference lives under /api-reference.

# Send your first email

> Connect an email provider and your own domain with DKIM and SPF, send a real email, check it in Logs, and plan for bounces and failover in production.

Every workspace can email you on day one. Reaching anyone else takes your own provider and your own domain.

> [!NOTE]
>
> Only need to prove the API works? The [quickstart](https://www.courier.com/docs/get-started/send-a-message.md) sends an email in one call with no provider setup, reaching your signup address only.

## Prerequisites

* [A Courier Test API key](https://app.courier.com/~/test/platform/api-keys)
* An account with an email provider, such as [SendGrid](https://sendgrid.com/), [Postmark](https://postmarkapp.com/), or [Resend](https://resend.com/)
* A domain you can add DNS records to

## Send it

**1. Connect your own provider**

Add your provider from [Integrations](https://app.courier.com/integrations/catalog) and paste its API key. [Email providers](https://www.courier.com/docs/integrations/email/overview.md) lists every one, and each page carries that provider's credential fields.

Integrations are per environment, so connect it in the same environment your API key belongs to. A provider added in Production does nothing for a Test key.

> [!NOTE]
>
> The **Courier Test Email Provider** stays connected alongside yours. Once you add your own, [channel priority](https://www.courier.com/docs/send/routing.md#channel-priority) decides which one sends, so set yours first.

**2. Verify your sending domain**

Your provider has to prove it may send as you. That means DKIM and SPF records on your domain, added at your DNS host and verified in the provider's dashboard.

Skipping this is the single biggest cause of mail landing in spam. An unauthenticated message from a domain that publishes no policy is exactly what a receiving server is built to distrust.

[Send from your own domain](https://www.courier.com/docs/guides/send-from-your-domain.md) walks the records and setting the From address.

**3. Put an email address on the profile**

Email addresses a recipient by `email`. Nothing else is required.

```javascript Node.js highlight={2} theme={null}
await client.profiles.create("user_123", {
  profile: { email: "sarah@acme-corp.com" },
});
```

```python Python highlight={3} theme={null}
client.profiles.create(
    "user_123",
    profile={"email": "sarah@acme-corp.com"},
)
```

```bash cURL highlight={4} theme={null}
curl -X POST https://api.courier.com/profiles/user_123 \
  -H "Authorization: Bearer $COURIER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "profile": { "email": "sarah@acme-corp.com" } }'
```

```ruby Ruby highlight={3} theme={null}
courier.profiles.create(
  "user_123",
  profile: {email: "sarah@acme-corp.com"}
)
```

```go Go highlight={2} theme={null}
_, err := client.Profiles.New(context.TODO(), "user_123", courier.ProfileNewParams{
	Profile: map[string]any{"email": "sarah@acme-corp.com"},
})
```

```java Java highlight={4} theme={null}
ProfileCreateParams params = ProfileCreateParams.builder()
    .userId("user_123")
    .profile(ProfileCreateParams.Profile.builder()
        .putAdditionalProperty("email", JsonValue.from("sarah@acme-corp.com"))
        .build())
    .build();

client.profiles().create(params);
```

```php PHP highlight={3} theme={null}
$client->profiles->create(
  'user_123',
  profile: ['email' => 'sarah@acme-corp.com'],
);
```

```csharp C# highlight={7} theme={null}
await client.Profiles.Create(
    "user_123",
    new()
    {
        Profile = new Dictionary<string, JsonElement>
        {
            { "email", JsonSerializer.SerializeToElement("sarah@acme-corp.com") },
        },
    }
);
```

```bash CLI highlight={3} theme={null}
courier profiles create user_123 \
  --api-key "$COURIER_API_KEY" \
  --profile '{"email": "sarah@acme-corp.com"}'
```

```text MCP theme={null}
With Courier MCP, set the email sarah@acme-corp.com on user_123.
```

Addressing a profile rather than an address is what lets [preferences](https://www.courier.com/docs/recipients/preferences/overview.md) apply and what keeps one send working when the person changes their address. [Users](https://www.courier.com/docs/recipients/overview.md#what-each-channel-needs) covers the field every other channel reads.

**4. Send the email**

Route to `email` and Courier picks the provider you connected.

```javascript Node.js highlight={4} theme={null}
const { requestId } = await client.send.message({
  message: {
    to: { user_id: "user_123" },
    routing: { method: "single", channels: ["email"] },
    content: { title: "Your order shipped", body: "It should arrive Thursday." },
  },
});
```

```python Python highlight={4} theme={null}
response = client.send.message(
    message={
        "to": {"user_id": "user_123"},
        "routing": {"method": "single", "channels": ["email"]},
        "content": {"title": "Your order shipped", "body": "It should arrive Thursday."},
    },
)
```

```bash cURL highlight={7} theme={null}
curl -X POST https://api.courier.com/send \
  -H "Authorization: Bearer $COURIER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "message": {
      "to": { "user_id": "user_123" },
      "routing": { "method": "single", "channels": ["email"] },
      "content": { "title": "Your order shipped", "body": "It should arrive Thursday." }
    }
  }'
```

```ruby Ruby highlight={4} theme={null}
response = courier.send_.message(
  message: {
    to: {user_id: "user_123"},
    routing: {method: "single", channels: ["email"]},
    content: {title: "Your order shipped", body: "It should arrive Thursday."}
  }
)
```

```go Go highlight={8} theme={null}
response, err := client.Send.Message(context.TODO(), courier.SendMessageParams{
	Message: courier.SendMessageParamsMessage{
		To: courier.SendMessageParamsMessageToUnion{
			OfUserRecipient: &shared.UserRecipientParam{UserID: courier.String("user_123")},
		},
		Routing: courier.SendMessageParamsMessageRouting{
			Method:   string(shared.MessageRoutingMethodSingle),
			Channels: []shared.MessageRoutingChannelUnionParam{{OfString: courier.String("email")}},
		},
		Content: courier.SendMessageParamsMessageContentUnion{
			OfElementalContentSugar: &shared.ElementalContentSugarParam{
				Title: "Your order shipped",
				Body:  "It should arrive Thursday.",
			},
		},
	},
})
```

```java Java highlight={6} theme={null}
SendMessageParams.Message message = SendMessageParams.Message.builder()
    .to(SendMessageParams.Message.To.ofUserRecipient(
        UserRecipient.builder().userId("user_123").build()))
    .routing(SendMessageParams.Message.Routing.builder()
        .method(SendMessageParams.Message.Routing.Method.SINGLE)
        .channels(List.of(MessageRoutingChannel.ofString("email")))
        .build())
    .content(ElementalContentSugar.builder()
        .title("Your order shipped")
        .body("It should arrive Thursday.")
        .build())
    .build();

client.send().message(SendMessageParams.builder().message(message).build());
```

```php PHP highlight={4} theme={null}
$response = $client->send->message(
  message: [
    'to' => ['user_id' => 'user_123'],
    'routing' => ['method' => 'single', 'channels' => ['email']],
    'content' => ['title' => 'Your order shipped', 'body' => 'It should arrive Thursday.'],
  ],
);
```

```csharp C# highlight={6} theme={null}
SendMessageParams parameters = new()
{
    Message = new()
    {
        To = new UserRecipient { UserID = "user_123" },
        Routing = new() { Method = "single", Channels = ["email"] },
        Content = new ElementalContentSugar
        {
            Title = "Your order shipped",
            Body = "It should arrive Thursday.",
        },
    },
};

var response = await client.Send.Message(parameters);
```

```bash CLI highlight={4} theme={null}
courier send message \
  --api-key "$COURIER_API_KEY" \
  --message.to '{"user_id": "user_123"}' \
  --message.routing '{"method": "single", "channels": ["email"]}' \
  --message.content '{"title": "Your order shipped", "body": "It should arrive Thursday."}'
```

```text MCP theme={null}
With Courier MCP, email user_123 to say their order shipped.
```

Email uses `title` as the subject line and `body` as the message, so both do work here. SMS ignores the title, which is why the same shorthand carries them together.

## Verify

**1. Check your email**

The message arrives from the address you set on the integration.

**2. Read the status**

Open [Logs](https://app.courier.com/logs). `SENT` means your provider accepted it. `DELIVERED` means the recipient's mail server did.

**3. Confirm it came from your provider**

Open the message and check the provider on the send event. If it says Courier Test Email Provider, channel priority is still preferring it over yours.

`DELIVERED` with nothing in your mail client usually means spam or a corporate gateway rather than a failed send. [Debug delivery](https://www.courier.com/docs/guides/debug-delivery.md) works that case from Logs outward.

## What changes in production

**A bounce isn't a retry.** An `UNDELIVERABLE` message with a `BOUNCED` reason means the provider rejected the recipient, and Courier doesn't try again. A hard bounce means the address doesn't exist.

**Suppression lists belong to the provider, not to Courier.** After a bounce or complaint, most providers stop accepting that address. Nothing you send reaches it until you remove it there.

**Add a backup provider.** Two email providers on the channel means an outage at one fails over rather than failing. [Routing and failover](https://www.courier.com/docs/send/routing.md#failover) covers the order.

**Unsubscribes belong in preferences.** An `UNSUBSCRIBED` or `OPT_IN_REQUIRED` reason means [preferences](https://www.courier.com/docs/recipients/preferences/overview.md) stopped the send, which is the system working. Wire your provider's unsubscribe webhook to them rather than keeping a second list.
