- 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.
Prerequisites
- An OpenAI API key
- Node.js 20 or later, or Python 3.10 or later
Set up the project
In a new folder, install the Agents SDK and the Courier SDK: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 TypeScript, the Zod schema is the contract. In Python, the signature and docstring are:
in_progress or resolved. Save the file as agent.ts or agent.py.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
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 The filter exposes two tools:
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.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
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