An AI agent that can only talk is a chatbot. An AI agent that can send the email, text the customer and update the contact record is a teammate. This guide shows how to connect Claude, GPT or any LLM that supports tool calling to the Mailpro™ APIs, so your agent can send emails and SMS on its own, safely, with every message logged and traceable.
TL;DR
- Mailpro™ exposes three HTTPS APIs your agent can call: Email API v2 (transactional and campaign email), CRM API v3 (contacts, lists, tags) and the SMS API.
- You wrap each action in a small tool; the model decides when to call it, your code makes the HTTP request.
- Authenticate with an OAuth 2.0 token limited to the scopes the agent needs, never your master API key in a prompt.
- Use webhooks (
email.delivered,email.bounced,sms.delivered…) so the agent knows what actually happened.- Keep a human approval step for bulk sends and unknown recipients.
Why give your AI agent the power to send emails and SMS?
Because most of the value of an agent is in what it does after it understands the request. A support agent that drafts a reply is useful; one that sends the reply, confirms the refund by SMS and tags the contact as "refunded" closes the ticket. Typical jobs that work well today:
- Order and booking follow-ups — a confirmation email with a personal note written by the agent, plus an SMS reminder the day before.
- Support triage — the agent classifies the ticket, answers the simple ones by email and routes the rest to a human.
- One-time codes and alerts — the agent generates a code, sends it by SMS and checks it when the user replies.
- Daily digests — the agent reads the day's data and sends one summary email instead of forty notifications.
What are the Mailpro™ APIs, in 30 seconds?
| API | Base URL | Use it for |
|---|---|---|
| Email API v2 | https://api.mailpro.com/v2 |
Transactional emails (/send/sendmail), campaigns to a list (/send/campaign), delivery status, statistics |
| CRM API v3 | https://api.mailpro.com/v3 |
Contacts, lists, tags and custom fields — plus email and SMS sending from the same API |
| SMS API | https://api.mailpro.com/sms |
Single SMS (/send/add_single), bulk SMS to a list (/send/add), scheduling, credits |
All three accept the same OAuth 2.0 token (issued once at https://api.mailpro.com/oauth/token), return JSON, and share one monthly request quota per account. Every endpoint is documented, with request and response examples, on the Mailpro™ developer portal.
How does an AI agent call an email or SMS API?
Through tool calling (Anthropic calls it tool use, OpenAI calls it function calling). You describe each action as a tool with a JSON schema. When the model decides an action is needed, it returns a tool call with arguments; your code validates them, calls the Mailpro™ API and hands the result back to the model. The model never holds your credentials and never makes the HTTP request itself.
If you would rather not write the loop yourself, the same tools can be exposed through an MCP server (Model Context Protocol), which Claude Desktop, Claude Code and Cursor can use directly. The API calls underneath are the same.
Minimal example: Claude sends an email and an SMS
1. Get a scoped token
curl -X POST https://api.mailpro.com/oauth/token \
-d "grant_type=client_credentials" \
-d "client_id=YOUR_CLIENT_ID" \
-d "client_secret=YOUR_CLIENT_SECRET" \
-d "scope=email:send email:read sms:send"
Create the client ID and secret in your Mailpro™ account under Settings → API access. The access token lives 20 minutes; your code requests a new one when it expires.
2. Define the tools
tools = [
{
"name": "send_email",
"description": "Send one transactional email to one recipient.",
"input_schema": {
"type": "object",
"properties": {
"to": {"type": "string"},
"subject": {"type": "string"},
"html": {"type": "string"}
},
"required": ["to", "subject", "html"]
}
},
{
"name": "send_sms",
"description": "Send one SMS (max 160 characters) to one phone number.",
"input_schema": {
"type": "object",
"properties": {
"to": {"type": "string", "description": "International format, e.g. +41791234567"},
"message": {"type": "string"}
},
"required": ["to", "message"]
}
}
]
3. Execute the tool calls
import requests
API = "https://api.mailpro.com"
SENDER_ID = 201 # from GET /v2/senderEmail/list
def run_tool(name, args, token):
h = {"Authorization": f"Bearer {token}"}
if name == "send_email":
r = requests.post(f"{API}/v2/send/sendmail.json", headers=h, data={
"IDEmailExp": SENDER_ID,
"EmailData": args["to"],
"Subject": args["subject"],
"BodyHTML": args["html"],
"ActivateStatistics": "true",
})
elif name == "send_sms":
r = requests.post(f"{API}/sms/send/add_single.json", headers=h, data={
"to": args["to"],
"message": args["message"],
})
else:
return {"error": "unknown tool"}
return r.json()
Plug run_tool into your usual Claude (or OpenAI) loop: send the user message with tools, execute each tool call the model returns, and send the result back as a tool result. The email call returns an IdSingleSend; the SMS call returns an Id. Keep both: they are how you track delivery.
Prefer no code? Mailpro’s automated emails send confirmations, reminders and alerts on triggers you set up in a few clicks.
How does the agent know if the message was delivered?
A 200 response means Mailpro™ accepted the message, not that it reached the inbox or the phone. Two ways to close the loop:
-
Poll —
GET /v2/send/{IdSingleSend}/status.jsonreturnsqueued,sent,delivered,deferredorbouncedfor a transactional email. -
Webhooks (recommended) — subscribe once with
POST /webhooksand Mailpro™ posts a signed event to your server:email.delivered,email.bounced,email.opened,sms.delivered,sms.failedand more. Each request carries anX-Mailpro-SignatureHMAC header so you can verify it came from Mailpro™.
Feed these events back to the agent and it can react on its own: retry a failed SMS by email, or flag a bounced address to a human.
Security and best practices for AI-driven sending
Give the agent a scoped token, not your keys
OAuth tokens carry scopes such as email:send, email:read, contacts:read or sms:send. An agent that only sends confirmations does not need contacts:write. A call outside its scopes fails with 403 insufficient_scope. Keep the client secret in server-side environment variables; never put it in a prompt.
Keep a human in the loop for risky sends
Let the agent send one-to-one messages on its own, but require approval for campaigns (/v2/send/campaign, /sms/send/add), for recipients outside your contact lists and for any message that mentions money. A simple allowlist of recipient domains or lists in your tool code prevents a bad prompt from mass-mailing customers.
Respect the quota and back off on errors
Your API requests share a monthly quota across the Email, CRM and SMS APIs (check it with GET /v2/account/limits.json). An agent stuck in a loop can burn through it quickly: cap tool calls per conversation, and retry with exponential backoff on 429 and 5xx responses instead of retrying immediately.
Respect consent and opt-outs
Unsubscribed and blacklisted contacts are skipped automatically, and the API tells you so. Do not let the agent work around it. For SMS, check the rules of each destination country before sending marketing messages.
Log everything
Store each tool call with its arguments, the API response and the returned ID. When a customer asks "why did I get this?", you can answer in seconds.
Case study (fictional): "LoopKart" lets Claude write post-purchase emails
LoopKart is a small online shop selling refurbished kitchen equipment. Its post-purchase emails were one template for everyone. The team connected Claude to the Mailpro™ Email API with a single send_email tool: after each order, the agent reads the order and the customer's history, writes a short personal paragraph (care tips for the exact product, a note if it is a repeat customer) and sends the email through /v2/send/sendmail. A second tool sends an SMS when the parcel ships. Orders above a set amount, and any message that mentions a refund, wait for a human click before sending. Setup took the team two days, most of it spent writing and testing the approval rule.
Frequently asked questions
Which AI models work with the Mailpro™ API?
Any model that supports tool or function calling: Claude, GPT, Gemini, Mistral and open-source models served with a tool-calling framework. The API itself is plain HTTPS and JSON, so the model only needs a thin wrapper.
Do I need a paid Mailpro™ plan to start?
No. You can start on the free plan, test everything and upgrade when your volume justifies it. See Mailpro pricing.
Can the agent send to a whole list?
Yes, with /v2/send/campaign for email and /sms/send/add for SMS. We recommend a human approval step for these.
Is there an MCP server?
You can expose the same tools through any MCP server framework; the calls underneath are the ones shown above.
Where to go next
- Transactional and campaign email in depth: Transactional Email API for AI Agents
- Contacts, lists and tags: Automate your CRM with AI
- SMS, codes and reminders: Send SMS with an AI agent
- Getting into the inbox: email deliverability troubleshooting
- The SMS gateway itself: Mailpro SMS API
Mailpro and the Mailpro API
One API for your AI agent to send both email and SMS
Give your AI agent a single Mailpro API and it can reach customers by email and SMS — one integration, one dashboard, one bill. See what it costs to power both channels.