> ## 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.

# Migrate from an in-house system

> Replace homegrown notification code with Courier one type at a time: inventory your sends, run both paths in parallel, then delete the old code.

Most teams don't arrive from another vendor. They arrive from a `sendEmail()` helper that grew for three years.

This guide maps that code to Courier and moves it across one notification type at a time, with both systems running until the logs agree.

## What you already built

A homegrown system is rarely one component. It is a provider SDK, a template directory, a preferences table, and a cron job, each added when something broke.

| What you maintain | What replaces it |
| :- | :- |
| `sendEmail()` wrapping a provider SDK | [One send call](https://www.courier.com/docs/send/overview.md), with the provider chosen by config |
| A second wrapper for SMS, and a third for push | The same call, with [routing](https://www.courier.com/docs/send/routing.md) deciding the channel |
| Hardcoded HTML, or a templates directory | [Templates](https://www.courier.com/docs/design/templates/overview.md), editable without a deploy |
| A `notification_preferences` table and its checks | [Preferences](https://www.courier.com/docs/recipients/preferences/overview.md), enforced at send time |
| A cron job that batches the nightly digest | A [topic digest](https://www.courier.com/docs/guides/send-a-daily-digest.md) |
| Retry, backoff, and dead-letter handling | [Retries and provider failover](https://www.courier.com/docs/send/routing.md#failover) |
| `user_id` to email and phone lookups | [Profiles](https://www.courier.com/docs/recipients/overview.md) |
| A WebSocket feed, unread counts, and read state | [Inbox](https://www.courier.com/docs/in-app/overview.md) |

The preferences row is the one teams underestimate. A `notification_preferences` table is easy to add and hard to finish, because every new notification type needs a column, a migration, and a check at every call site.

## What this actually buys you

Frame the project as deleting code you maintain, not as adopting a platform. That is what it is, and it is the honest way to size it.

**Provider changes stop being deploys.** Swapping SendGrid for SES becomes configuration. Adding a backup provider becomes configuration.

**Copy changes stop being tickets.** A PM edits a template and publishes. Your queue doesn't know the difference.

**The failure modes get names.** A homegrown send that vanishes leaves you grepping logs. Courier gives every message a [status](https://www.courier.com/docs/send/statuses.md) and a reason, so `UNROUTABLE` and `BOUNCED` and `OPT_IN_REQUIRED` are distinguishable.

Cost is worth checking early rather than at the end. [How sends are counted](https://www.courier.com/docs/workspaces/billing.md#how-sends-are-counted) is the number to model against, and it counts sends rather than seats or channels.

## Migrate incrementally

Nobody rewrites every notification in one release. Move one type, prove it, then move the next.

**1. Inventory what you send**

List every notification your code can produce, and for each one record the trigger, the channel, and the audience.

The list is usually longer than anyone expects, and it is the artefact the rest of the migration runs on. Sort it by volume. The lowest-volume, least-critical notification is the one to move first.

**2. Connect the providers you already use**

Add your existing SendGrid, Twilio, or FCM credentials as [integrations](https://www.courier.com/docs/integrations/overview.md). You keep the same accounts, the same sending domains, and the same sender reputation.

Nothing about deliverability changes at this step, which is what makes the cutover reversible.

**3. Move your users in**

Send your existing user records to [`POST /profiles/{user_id}`](https://www.courier.com/docs/api-reference/user-profiles/create-a-profile) and keep the id your database already uses. [Import your users](https://www.courier.com/docs/guides/import-your-users.md) covers the bulk path.

Reusing your own `user_id` matters more than it looks. It means no mapping table, and it means a send from anywhere in your code can address a user with the id it already has.

**4. Rebuild one notification**

Take the lowest-stakes item from your inventory. Recreate its content as a [template](https://www.courier.com/docs/design/templates/overview.md), then replace that one call site with a Courier send.

Leave every other call site alone.

**5. Run both, and compare**

Keep your old path sending, and have Courier send to a test recipient in the [Test environment](https://www.courier.com/docs/workspaces/environments.md). Compare what arrives.

You're checking three things: the content renders the same, the recipient resolves to the same person, and the timing is what you expect.

**6. Cut over, then delete**

Point production at the Courier send and remove the old code path. Not commented out, removed. A dead path that still compiles is one someone reintroduces in six months.

Then take the next item from the inventory.

## Verify

**1. Confirm delivery in the logs**

Open [Logs](https://app.courier.com/logs) and find the message. The timeline shows routing, rendering, and the provider handoff.

**2. Check a preference is honored**

Opt a test user out of the topic, send again, and confirm the message is `FILTERED` rather than delivered. That proves your preferences moved, which is the part most likely to be missed.

**3. Compare against the old system**

For the notification you moved, confirm the volume in Courier matches what your old path used to send over the same period. A gap means a call site you haven't found yet.

## What you can delete at the end

The point of the inventory is that it doubles as a deletion list.

* Provider SDK wrappers, and the per-provider error handling around them
* The template directory, and whatever renders it
* The preferences table, its migrations, and every call-site check
* Retry, backoff, and dead-letter queues for notification sends
* The cron jobs that batch digests
* The WebSocket server behind your in-app feed, if you adopt [Inbox](https://www.courier.com/docs/in-app/overview.md)

Keep one thing: whatever decides *that* a notification should happen. That logic is your product, and it belongs in your code. Courier owns everything after that decision.
