Blog

Build notifications with Claude Code, Cursor, and Courier

Emily LaneEmily LaneJanuary 22, 2026
Vibe Coding Notifications: How to Use Courier with Cursor or Claude Code — cover

Ask Claude Code or Cursor to "add notifications" and you'll get more than you asked for. The agent writes a send function, then a retry queue, then provider SDK wrappers, then templates hardcoded in your repo. Vibe coding notifications this way is fast for the first hour, and then you're the one maintaining a notification system.

A better split: your agent writes product code, and Courier handles delivery, routing, templates, and logs. You give the agent two things. Courier Skills teaches it how Courier works, so it writes correct code the first time. The Courier MCP server gives it access to your Test workspace, so it can create templates, send, and read delivery history from the chat.

This tutorial builds an order-shipped notification that lands in an in-app inbox, goes out as push, and falls back to SMS. Steps 1 to 3 match Courier's AI agent quickstart.

Prerequisites

  • Claude Code or Cursor
  • A Courier account (the Developer plan is free and includes 10,000 sends a month)
  • A Node.js 20+ app. The examples use Next.js; the agent adapts them to your stack
  • For push: a mobile app using Courier's iOS, Android, Flutter, or React Native SDK, plus FCM or APNs set up in Courier
  • For SMS: an SMS provider such as Twilio. Email and Inbox work in a Test environment with no setup

Step 1: Save a Test key to your environment

Copy a Test environment key from Settings → API Keys. Run this in your own terminal, not in the agent chat, with your key in place of YOUR_COURIER_API_KEY, so the key never shows up in a transcript:

Terminal
printf '\nCOURIER_API_KEY=YOUR_COURIER_API_KEY\n' >> .env

Make sure .env is in .gitignore. Test and production environments have separate keys and separate providers, so a Test key can't send through your production setup. It still delivers through any provider you add to Test, so send only to yourself and your team while you build.

Step 2: Install Courier Skills

In Claude Code, install the Courier plugin:

Text
/plugin marketplace add trycourier/courier-skills
/plugin install courier@courier-skills

The plugin adds the Courier skill and connects the Courier docs MCP server, so the agent can search the docs without extra setup. Claude Code loads the skill automatically when a task involves Courier.

In Cursor (or Codex, Windsurf, and other tools that read agent skills):

Terminal
npx skills add trycourier/courier-skills

The skill is about 40 short guides plus a routing file. The agent reads the router first, then loads only the one or two guides a task needs. To confirm it loaded, ask a question only the skill can answer:

Text
Which Courier skill files would you read to add a one-time passcode flow?

An agent with the skill names files such as transactional.md and sms.md. If it doesn't, start a new session.

Step 3: Connect the Courier MCP server

The skill changes the code your agent writes. The MCP server lets it act on your workspace: 170+ tools covering the Courier API, from creating templates to reading a message's delivery history.

Claude Code and the Courier CLI read the key from your shell environment, not from .env. Export it in the terminal you start them from:

Terminal
set -a; source .env; set +a

In Claude Code, add the server:

Terminal
claude mcp add --transport http courier https://mcp.courier.com --header "api_key: $COURIER_API_KEY"

To share the server with your team, commit a project .mcp.json instead. Claude Code expands ${COURIER_API_KEY} from the environment of the shell that launched it, so the key stays out of the repo:

JSON
{
  "mcpServers": {
    "courier": {
      "type": "http",
      "url": "https://mcp.courier.com",
      "headers": {
        "api_key": "${COURIER_API_KEY}"
      }
    }
  }
}

Run claude mcp list to confirm the server connected. If the variable isn't exported, Claude Code sends the literal text ${COURIER_API_KEY} and every tool call fails with a 403.

In Cursor, use the one-click install on the MCP docs page and replace the placeholder with your Test key, or add the same server to .cursor/mcp.json with your Test key in the api_key header.

Then write down your project's conventions so every session starts from them. In Claude Code, that's CLAUDE.md:

Markdown
## Notifications
- All notifications go through Courier (`@trycourier/courier`). Don't add provider SDKs.
- Send with templates, never inline content. Template IDs live in `lib/notifications.ts`.
- Every send gets an `Idempotency-Key` built from the event ID.
- Use the Test key for development. Never ask for or use a production key.

In Cursor, put the same rules in a project rule under .cursor/rules/.

Step 4: Plan the build

Start in plan mode (Shift+Tab in Claude Code) so you can review the design before any code is written:

Text
Add an order-shipped notification with Courier. It should always appear in the
in-app inbox, go out as push, and fall back to SMS if push fails. Include the
carrier, tracking URL, and order number. A retried webhook must never send twice.
Propose the templates, routing, and code changes before writing anything.

With the skill loaded, the plan should include an Idempotency-Key on the send, a routing order rather than a hand-written retry loop, and a server-issued JWT for the inbox. If any of those are missing, push back before you approve the plan. In Cursor, ask the agent for the same plan in Agent mode before it edits files.

Step 5: Build it

Approve the plan and let the agent work. Over MCP, it creates and publishes the Order shipped template with content for each channel. In your repo, it should produce a send function close to this:

TypeScript
// lib/notifications.ts
import Courier from "@trycourier/courier";

const courier = new Courier(); // reads COURIER_API_KEY

export const ORDER_SHIPPED_TEMPLATE = "nt_01kx4h2jdafq8bk9aftxak4b40";

export async function sendOrderShipped(order: {
  id: string;
  userId: string;
  carrier: string;
  trackingUrl: string;
}) {
  const { requestId } = await courier.send.message({
    message: {
      to: { user_id: order.userId },
      template: ORDER_SHIPPED_TEMPLATE,
      data: {
        order_id: order.id,
        carrier: order.carrier,
        tracking_url: order.trackingUrl,
      },
      routing: {
        method: "all",
        channels: ["inbox", { method: "single", channels: ["push", "sms"] }],
      },
    },
    "Idempotency-Key": `order-shipped-${order.id}`,
  });

  return requestId;
}

The routing reads as: deliver to every channel at the top level (all), where the second channel is itself a rule that tries push and moves to SMS only if push fails (single). Push needs a device token, which Courier's mobile SDKs register. A web-only app has no token, so every send would skip to SMS; use email in place of push there.

If several notifications share that policy, ask the agent to move it into a routing strategy attached to each template and remove the routing block from the send. An inline routing object replaces the strategy's channel list for that message, so leaving it in means edits to the strategy never take effect.

The inbox and preference center need a token issued by your backend for the signed-in user:

TypeScript
// app/api/courier-token/route.ts
import Courier from "@trycourier/courier";
import { getSession } from "@/lib/auth"; // your existing auth

const courier = new Courier();

export async function GET() {
  const session = await getSession();
  if (!session) return new Response("Unauthorized", { status: 401 });

  const { token } = await courier.auth.issueToken({
    scope: `user_id:${session.userId} inbox:read:messages inbox:write:events read:preferences write:preferences`,
    expires_in: "2 days",
  });

  return Response.json({ token });
}

Then a bell in the header:

TSX
// components/notification-bell.tsx
"use client";

import { useEffect } from "react";
import { useCourier, CourierInboxPopupMenu } from "@trycourier/courier-react";

export function NotificationBell({ userId }: { userId: string }) {
  const courier = useCourier();

  useEffect(() => {
    let cancelled = false;

    async function signIn() {
      const res = await fetch("/api/courier-token");
      if (!res.ok) return; // signed out: leave the inbox empty
      const { token } = await res.json();
      if (!cancelled) courier.shared.signIn({ userId, jwt: token });
    }

    signIn().catch(console.error);
    // The SDK doesn't refresh tokens. Mint a new one daily, well before the 2-day expiry.
    const timer = setInterval(() => signIn().catch(console.error), 24 * 60 * 60 * 1000);

    return () => {
      cancelled = true;
      clearInterval(timer);
    };
  }, [userId, courier]);

  return <CourierInboxPopupMenu />;
}

SMS reads phone_number from the user's profile.

Step 6: Test it against your workspace

Ask the agent to run the full loop over MCP:

Text
Create a Courier profile for test_user_1 with my email and phone number, send the
order-shipped template to them with sample order data, then read the message
history and tell me which channels delivered.

The agent calls the send tool, then reads the message history: each status change with its reason, so you can tell an unconfigured provider from a rendering problem.

If the template has an email channel, check how it renders before your users do. Device Preview (a paid add-on) renders a template on real email clients and returns a screenshot from each. Ask the agent to run it and review the results:

Text
Run a Courier device preview of the order-shipped template on the Courier
Recommended set with sample order data. Poll until it finishes, review each
screenshot, and fix anything broken in Outlook, on mobile, or in dark mode.

The same checks work as shell commands for scripts and CI:

Terminal
npm install -g @trycourier/cli
courier messages history <message_id>
courier messages list --status UNDELIVERABLE --status UNROUTABLE --format json

Step 7: Hand the copy to your team

The agent built the template, but it doesn't have to own it. Templates live in your Courier workspace, not your repo, so product and marketing can edit copy in Design Studio and publish without a deploy. Your code references the template ID and keeps working.

Localization is available on every plan. AI Translation in Design Studio translates a template across every channel, with a side-by-side review before you publish; it runs on AI credits, available on the Business and Enterprise plans. If users need control over what they receive, ask the agent to add a preference topic for shipping updates and the drop-in preference center.

Use Claude inside Courier too

A Journey's AI node runs a model as a step in the flow, with Claude Haiku 5.5, Sonnet 5.5, Opus 5.5, and Fable 5.1 among the options. It can classify a user, branch on the result, and write copy for each channel from one prompt.

Text
Build a Courier journey for delayed orders. Use an AI node on claude-haiku-5-5 to
read the carrier's free-text delay reason and classify it as weather, address
problem, or lost package. Branch on the result: ask the customer to confirm
their address for address problems, and send an apology with the new delivery
estimate for everything else.

AI nodes run on AI credits and are available in the US datacenter. Claude and Courier covers both directions.

Keep AI agent access scoped

Claude Code prompts before each MCP tool call by default, but one "Yes, and don't ask again" or a broad allow rule removes that prompt for good. Commit rules to .claude/settings.json so reads run freely and anything that sends always needs approval:

JSON
{
  "permissions": {
    "allow": ["mcp__courier__get_*", "mcp__courier__list_*"],
    "ask": [
      "mcp__courier__send_*",
      "mcp__courier__schedule_broadcast",
      "mcp__courier__resend_message",
      "mcp__courier__invoke_*",
      "mcp__courier__release_*",
      "mcp__courier__run_bulk_job"
    ]
  }
}

An ask rule prompts even when an allow rule also matches, so these tools stay gated whatever a developer approves later. The MCP tools reference marks which tools write.

Next steps

  • Start a common flow from a tested recipe: onboarding, failed payments, trial ending.
  • Per-tool setup and sample prompts: Claude Code, Cursor, and Codex.
  • Build with AI covers the skill, the MCP server, the CLI, and Courier's docs for AI agents.

Frequently asked questions

Do I need Courier Skills, the MCP server, or both?

Courier Skills changes the code your agent writes and needs no API key. The MCP server lets the agent create templates, send notifications, and read delivery logs in your workspace. Most setups install both: the skill to build, the MCP server to test and debug.

How do I connect Courier to Claude Code?

Install the Courier plugin with /plugin marketplace add trycourier/courier-skills and /plugin install courier@courier-skills. Then add the MCP server with claude mcp add --transport http courier https://mcp.courier.com --header "api_key: YOUR_COURIER_API_KEY", using a Test environment key.

How do I connect Courier to Cursor?

Run npx skills add trycourier/courier-skills in your project, then add Courier's MCP server at https://mcp.courier.com with your API key in an api_key header, either with the one-click install on courier.com/docs/resources/mcp or in .cursor/mcp.json. Courier MCP works best in Agent mode.

Can I test without sending to real users?

Yes. Every Courier workspace has separate Test and production environments, each with its own API keys and providers, so a Test key never sends through your production setup. Test environments come with the Inbox provider and a testing provider, so the agent can send before you configure a real provider. Providers you add to Test deliver for real, so send to yourself. Switch to the production key when you ship.

How much does Courier cost?

The Developer plan is free and includes 10,000 sends a month, plus Journeys, broadcasts, the MCP server, the CLI, and the SDKs. Business is $0.005 per send on any channel, from the first send, with no per-seat or channel add-on fees, and Enterprise pricing is custom. Check courier.com/pricing for current plans.

What channels does Courier support?

Courier supports email, SMS, push (iOS and Android), in-app notifications, Slack, Microsoft Teams, WhatsApp, Discord, and webhooks. Slack messages support Block Kit, Teams messages support Adaptive Cards, and Courier provides drop-in components for the in-app Inbox, toasts, and preference centers.