How to Send Emails and SMS with an AI Agent (Mailpro™ API Guide)

Send Emails & SMS with an AI Agent via Mailpro™ API

Large language models can now do more than talk. Tool use, function calling and the Model Context Protocol have turned them into agents that take action — and one of the most valuable actions they can take is to send an email or an SMS on your behalf. This pillar guide shows how to connect Claude, GPT, Gemini or any other modern AI agent to the Mailpro™ APIs so they can deliver real messages to real inboxes and phones.

TL;DR

  • Mailpro™ offers three APIs an AI agent can call: Email v2, CRM v3, SMS.
  • Every endpoint is documented on our developer portal with copy-paste examples in over 20 programming languages.
  • Use Email v2 for simple sending and campaigns, CRM v3 for the full contacts & integrations ecosystem, SMS for short-form messages and OTPs.
  • AI agents integrate via standard HTTPS + JSON — no proprietary SDK required.

Why give your AI agent the power to send emails and SMS?

From chatbot to action: the shift to agentic AI

Until recently, conversations with an LLM ended at the prompt. The model wrote you a draft, a summary or a piece of code, and you were the one doing the last mile. With tool use (Anthropic's term), function calling (OpenAI's term) or the Model Context Protocol (the emerging open standard), the model now decides to call an external function — and you execute that call. Suddenly the agent can look up a record, compute something, and send a message.

That last part — sending — is where AI stops being a toy and starts being a business process. A support agent that answers a ticket is nice. A support agent that answers the ticket and emails the customer the resolution is a saved staff hour.

Four concrete use cases

  • Smart transactional sending. The agent drafts a tailored order confirmation, a promo follow-up or a password-reset email, then dispatches it through the Mailpro™ Email API v2.
  • Event-driven campaigns. Give the agent a campaign brief and a target list; it writes the copy, schedules the send, and reports back with the campaign ID.
  • CRM hygiene at scale. The agent reads noisy lead data, cleans it, tags it, assigns it to a segment — all through the Mailpro™ CRM API v3.
  • OTP on demand. The agent requests a one-time passcode SMS via the SMS API to verify a user in the middle of a chat.

In every case, the agent isn't "replacing" you — it's closing the loop between deciding and acting.

The Mailpro™ APIs in 30 seconds

Mailpro™ exposes three REST APIs, each designed for a specific job. An agent can use one, two or all three in the same workflow. All of them run at api.mailpro.com and are documented on our developer portal, with copy-paste code examples in over 20 programming languages (cURL, Python, Node.js, PHP, Go, Ruby, C#, Java, Swift, Kotlin and many more).

API Format Best for
Email API v2 JSON + XML Simple email sending, campaigns, email lists
CRM API v3 JSON (snake_case) Full contacts ecosystem, tags, segments, third-party integrations
SMS API JSON + XML Single or bulk SMS, number lists, credits

Email API v2 — simple and direct for sending

Need email and SMS from one place? Mailpro’s plans give your AI agent both channels through one API — one integration, one predictable bill.

The most straightforward of the three. If you just want to send an email — a one-off transactional or a campaign to a list — the Email API v2 is the shortest distance between your agent and the recipient's inbox. It manages email lists, HTML templates, sender addresses, campaigns and stats. Responses in .json or .xml.

CRM API v3 — the full contacts ecosystem

v3 isn't about "sending fast": it's about managing the full contact lifecycle. UUID-identified contacts, tags, lists, dynamic segments, custom fields, JWT authentication. It's also the API on which your partners and third-party integrations (Z_ID = 123456 # YOUR_ID_CLIENT MAILPRO_KEY = "YOUR_API_KEY" # never send this key to the model client = anthropic.Anthropic(api_key=ANTHROPIC_KEY) # 1. Declare the tool tools = [{ "name": "send_email_campaign", "description": "Send an email campaign to a Mailpro list.", "input_schema": { "type": "object", "properties": { "list_id": {"type": "integer", "description": "Mailpro list ID"}, "subject": {"type": "string"}, "html": {"type": "string", "description": "Full HTML body"} }, "required": ["list_id", "subject", "html"] } }] # 2. Ask Claude for the campaign msg = client.messages.create( model="claude-sonnet-4-5", max_tokens=1024, tools=tools, messages=[{ "role": "user", "content": "Write a spring sale email for our VIP list (ID 42) and send it." }] ) # 3. Execute the tool call for block in msg.content: if block.type == "tool_use" and block.name == "send_email_campaign": args = block.input r = requests.post( "https://api.mailpro.com/v2/send/campaign.json", params={"IdClient": MAILPRO_ID, "ApiKey": MAILPRO_KEY}, data={ "AddressBookId": args["list_id"], "Subject": args["subject"], "Body": args["html"] } ) print("Mailpro response:", r.json())

Two things to notice: the API key stays in your code (never in the prompt), and the agent only sees the shape of the tool — it doesn't need credentials to do its job. This is the foundation of every agentic integration pattern. To see the same call in another language, the Email API v2 documentation offers the equivalent snippet in Node.js, PHP, Go, Ruby, C# and about twenty others.

Security and best practices for AI-driven sending

Agentic systems are fast and they fan out. A misconfigured loop can send thousands of unwanted messages in minutes. Four rules to live by:

Never expose your API key to the LLM directly

The model should receive the tool schema, not the credentials. Keep the key in server-side environment variables and only inject it when the tool is actually executed.

Respect rate limits

Mailpro™ enforces 500 requests per minute per API key by default. An agent that loops aggressively will hit this ceiling fast. Use exponential backoff on 429 responses and batch work when you can — the API exposes bulk endpoints for exactly this reason. For more context, see our guide on email deliverability.

Respect suppressions and opt-outs

When a contact has unsubscribed, bounced hard, or reported spam, the API silently skips them — as it should. Teach your agent to read the response counts, so it doesn't keep trying. The forthcoming Suppressions endpoints will expose these lists directly; in the meantime, the existing unsubscribe handling is automatic.

Audit everything

Log every tool call the agent makes with the returned requestId. When something goes wrong, you need the breadcrumbs. Mailpro™ returns a requestId on every error response precisely so you can cross-reference with our support team.

Case study (fictional): "LoopKart" — a DTC brand letting Claude write post-purchase emails

LoopKart is a small dire

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.

Start free with Mailpro See Mailpro pricing

Previous Article

   

Next Article

You might also be interested in:

Email marketing is an art and a science. While content, design, and strategy play crucial roles, understanding the neuroscience behind how the human brain reacts to emails can give marketers a significant edge. By tapping into th...
Mailpro’s newest version comes packed with features that are designed to enhance your email marketing experience. With improved ergonomics, a revamped email builder, modern design, and enhanced speed and performance, we’ve taken ...
The success of a business, to a large extent, is determined by the marketing strategies. While most businesses focus on bringing more sales, only savvy marketers know that the best way to move ahead is to focus on a deeper aspect...
If you have just finished with your email newsletter, you must know that clicking on that send button can be nerve-wracking. As challenging as it to write a compelling newsletter, it is equally hard to tell if our newsletter is m...
Effective email marketing is more than just a tool for promotions; it's a crucial element in building and maintaining relationships with your customers. In an age where consumers are bombarded with countless messages daily, s...

Unleash the Power of Professional Email Marketing

Secure, scalable, and built for impact. Join Mailpro™ today and enjoy 500 free credits to send your first campaign.
Start Sending for Free