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.

Questions builders and agents ask

Which email APIs work with MCP or agent workflows?

Can an AI agent write and send marketing emails?

What’s the best email platform for AI coding assistants?

Can an agent verify my sending domain or publish templates?

Keep going

Start at the Loops agents hub for the quickstart and skill install, or see the email API for the platform underneath.