Skip to main content
Your AI agent decides who to tell and when, and Courier handles channels, routing, failover, preferences, and delivery logs. Give the agent Courier in one of two ways:
  • A Courier tool gives you tight control. You write one function that sends one published template, and the agent fills in only the fields your schema allows.
  • The Courier MCP server gives the agent the full API: 170+ tools for sending, users, templates, and logs. You choose which of them the agent sees.
Build with a Test environment key. Test’s built-in email provider only delivers to the address you signed up with, so until you connect your own provider, an agent can’t reach a real customer by mistake.

Prerequisites

Set up the project

In a new folder, install the Agents SDK and the Courier SDK:
Set both keys in the shell that runs the agent. Each SDK reads its key from the environment:

Give the agent a Courier tool

1

Write the agent

The tool sends one template and takes three inputs. The SDK validates every call against the schema, so the agent can’t send a status other than in_progress or resolved. Save the file as agent.ts or agent.py.
In TypeScript, the Zod schema is the contract. In Python, the signature and docstring are: Literal becomes an enum, and each line under Args: becomes a field description.The Courier SDK retries failed requests, and the Idempotency-Key makes those retries safe: a retried request returns the first response instead of sending twice. Use a fresh key for each send. A key built from the ticket and status would replay a failed first attempt, and silence a second notice with the same status, for 25 hours.
2

Run it

The agent calls send_ticket_update and replies with the requestId. The template holds the content, so the agent picks the recipient and the moment without writing the message.

Connect the Courier MCP server

1

Point the agent at the server

Connect to the hosted server over Streamable HTTP, with your key in the api_key header. The connection runs from your process, and a tool filter picks which Courier tools the agent sees. Save the file as agent.ts or agent.py.
The filter exposes two tools: send_message_template to send, and trace_message to check delivery. Add names to the list to give the agent more of the API, or remove the filter to expose every tool.The MCP send tools take a user_id or a list_id, not an email address, so the customer needs a saved profile.
2

Run it

The agent calls send_message_template and replies with the requestId.

Ask a person for approval

Send a template with an action button to Slack, Microsoft Teams, or the Inbox, and point the button at a URL in your app. The click reaches your app, not Courier, so record the decision there and resume the agent. The , , , and pages cover each channel.

Verify

1

Find the request in Logs

Copy the requestId from the agent’s reply, open , and find that request. Logs are per environment, so a Test send appears only in Test logs.
2

Confirm it delivered

Expand the message timeline and confirm the provider accepted it. A channel with no configured provider shows as UNROUTABLE, so start with the inbox channel, which needs no setup.

Next steps

  • to test sends from Claude Code, Cursor, or Codex
  • for every tool the server exposes
  • for every field a send accepts
  • , so a template mapped to a subscription topic respects each customer’s opt-outs