Skip to main content
This guide walks through the fastest path to your first campaign via API: API key → create campaign → write LMX → preview → send By the end, you’ll have a draft campaign with real email content that you can open in Loops, preview, choose an audience for, and send. Each step includes examples for the Loops CLI, curl, and the JavaScript SDK. The CLI is especially useful for creating emails inside coding agents. Check out Loops’ Agent skills for more information.

Prerequisites

Before you start, make sure you have: Authenticate and verify your key:
Never commit your API key to source control. The CLI stores keys locally via loops auth login; curl and SDK examples use the LOOPS_API_KEY environment variable.

What you’ll build

You’ll create a product update campaign named March product update with a short LMX body, then open it in the Loops dashboard to preview and send.

Step 1: Create a draft campaign

Creating a campaign also creates an empty email message. Save the IDs from the response. You’ll need them in the next steps.
The response includes:
Save emailMessageContentRevisionId from the create response. Pass it as expectedRevisionId (or --expected-revision-id in the CLI) when updating the email message.

Step 2: Write LMX content

LMX (Loops Markup Language) is how you define email body content for the API. Create a file called email.lmx:
You can also reference themes and components by ID instead of inline styles. See the LMX reference for all available tags.

Step 3: Update the email message

Push your LMX content and sending settings to the email message created in step 1.
fromEmail is the username only (the part before @). Loops appends your team’s sending domain automatically.
For agent scripts where you don’t have a saved revision ID, use --force instead of --expected-revision-id. This fetches the current revision automatically but overwrites any concurrent edits.

Step 4: Preview in the dashboard

Open your campaign in Loops:
Click into the email editor. Your LMX content renders in the editor. You can tweak copy, adjust styles, or add images from here. You can also make edits via the API, CLI, or an AI tool, and see the changes happen in real-time in the editor. To send a test to your inbox, click the Send a preview icon in the top right of the editor. Pick a contact (or enter test data) and send. You can also send a preview via the CLI, API, or JavaScript SDK:

Step 5: Choose an audience and send

Back in the dashboard, click Next to choose who receives the campaign. Pick a mailing list, segment, or your full audience. On the final step, send now or schedule for later. You can also set the audience and scheduling preference on the draft via the API or CLI with Update a campaign. Open the campaign in the dashboard to publish and send. Use loops lists list -o json to find a mailing list ID:
Sending requires a verified sending domain and a valid audience. Test sending to @example.com addresses first if you want to validate the flow without delivering real email.

Next steps

LMX reference

Campaign API examples

Create campaign API

JavaScript SDK

Loops CLI

Last modified on September 3, 2026