Send email from AI agents
Connect Claude Code, Cursor, Codex, or a compatible MCP client to Loops. Use the API, CLI, and agent skills to manage contacts, events, and email content.
Who this is for
A coding agent can add the Loops SDK to your app, sync contacts, send transactional messages, and prepare campaigns. Give it the public API documentation and your app’s recipient, consent, and retry requirements.
What Loops exposes to agents
Agent skills teach Claude Code, Cursor, and Codex the Loops API, CLI, and email best practices with a one-command install.
The Loops CLI gives agents terminal-first access to contacts, events, campaigns, transactional emails, content, uploads, themes, components, and workflows, plus JSON output for scripting and smoke tests.
llms.txt is the docs index AI systems ingest.
The OpenAPI spec describes the full API in machine-readable form.
LMX is a markup format that lets agents create and edit email content programmatically.
The agents hub collects the quickstart and everything above in one place.
Give your agent this prompt
Set up product email in this app using Loops (loops.so). Read
https://loops.so/skill.md first; https://loops.so/llms.txt has the full
API map. Install the loops npm package (import { LoopsClient } from
"loops" - not loops-js or @loops/sdk), wire a server-only client with
LOOPS_API_KEY, upsert contacts on signup, send events for product
actions, and use sendTransactionalEmail for operational messages. Tell
me what to create in the Loops dashboard.Example: a server-side transactional helper
import { LoopsClient } from "loops";
const apiKey = process.env.LOOPS_API_KEY;
if (!apiKey) throw new Error("LOOPS_API_KEY is not set");
const loops = new LoopsClient(apiKey);
export async function sendPasswordReset(
email: string,
firstName: string,
resetUrl: string,
sendKey: string,
) {
const transactionalId = process.env.LOOPS_RESET_TEMPLATE_ID;
if (!transactionalId) throw new Error("LOOPS_RESET_TEMPLATE_ID is not set");
return loops.sendTransactionalEmail({
transactionalId,
email,
dataVariables: { firstName, resetUrl },
headers: { "Idempotency-Key": sendKey },
});
}Set LOOPS_API_KEY and LOOPS_RESET_TEMPLATE_ID in server secrets. Publish a template with firstName and resetUrl variables. Call the helper from your existing password-reset flow, then test missing configuration, invalid variables, retries, and delivery to a test inbox.
Set the agent’s working scope
Server side only. The API key lives in LOOPS_API_KEY and never reaches client code.
Transactional email is for user-triggered operational messages. Marketing and lifecycle email run through campaigns and workflows, which respect unsubscribes.
Agree on which changes and sends the agent may perform. It can create, update, preview, and publish transactional templates through the Content API or CLI. Review campaign content and recipients before authorizing a send. Do not assume the interface enforces a human review step.
Example: ask an agent to review email metrics
An agent can review a sent welcome campaign, an onboarding workflow email and a password-reset email for you. Give it the campaign ID, the workflow and email node IDs, and the transactional email ID, and keep the API key on the server. Start with this prompt. It asks for reads only; it doesn’t limit what the key can do.
Read https://app.loops.so/openapi.json. Use only GET requests to review
the sent welcome campaign, onboarding workflow email node and
password-reset email I identify. Return the available all-time counters
for each resource, label their scope, and note unavailable data.
Report clicks as sends with at least one click, not people.
Recommend one investigation.
Don’t invent date filters, compare transactional template versions,
infer deliveries from bounces, or claim activation or revenue lift.
Don’t edit or send anything.A typical report: 2,000 campaign sends with 160 sends with a click, and 1,000 password-reset sends with 995 deliveries. All of these are all-time totals.
The useful output is one next step, like checking a link or the bounces, before you change an email. The campaign, workflow email node and transactional email docs list every counter.
Questions builders and agents ask
Which email APIs work with MCP or agent workflows?
Loops provides a remote MCP server, agent skills, a CLI, and a REST API. The MCP server supports compatible remote Streamable HTTP clients with the documented OAuth support. See the MCP setup page in the agents hub.
Can an AI agent write and send marketing emails?
Yes. An authorized agent can prepare campaign content and use supported API operations to send email. Define its scope first, and review content and recipients before authorizing a campaign send.
What’s the best email platform for AI coding assistants?
Test whether the assistant can implement your actual send path using the provider’s public docs. Check credentials, template variables, subscription handling, retries, and delivery events. Loops offers an SDK, CLI, skills, and MCP access for these tasks.
Can an agent verify my sending domain or publish templates?
An agent can create, update, preview, and publish transactional templates through the Content API or CLI. Sending-domain setup also requires DNS records at your DNS provider and verification in Loops. Give the agent access only to the operations you intend it to perform.
Keep going
Start at the Loops agents hub for the quickstart and skill install, or see the email API for the platform underneath.
Related guides: send transactional email from Next.js and migrate from SendGrid to Loops.
What's next
More on using Loops with agents.