Skip to main content

Send Campaigns via API

Use API to create, connect and schedule email campaigns in Rule’s new campaign editor directly from your own system.

With API, a campaign consists of several separate components: a template, a campaign and a message. These components are connected before the campaign is scheduled for delivery.

Before you start, make sure you have the following ready:

  • An API key with the appropriate permissions.

  • Your template content in RCML (Rule Content Markup Language).

  • Information about the recipients who should be included in the campaign.

How does it work?

To create and schedule a campaign, complete the following five steps in the specified order:

Step

Action

Endpoint

1

Create a template

New Editor – Template

2

Create a campaign and specify recipients

New Editor – Campaign

3

Create a message

New Editor – Message

4

Connect the message to the template

New Editor – Dynamic Set

5

Schedule the campaign

Campaign Schedule

Each step uses an ID returned by an earlier step: the template id and message id go into the dynamic set, and the campaign id goes into the message and the schedule request.

1. Create a template

Start by creating a template using the New Editor – Template endpoint.

The template defines the structure and layout of your email. Templates in the new editor are built using RCML (Rule Content Markup Language), which is used to define the content and structure of the email.

See the documentation for more information about creating templates and working with RCML.

Save the template id from the response. You will need it in step 4.

2. Create a campaign

Once the template has been created, the next step is to create a campaign using the New Editor – Campaign endpoint.

The campaign contains the settings for the delivery, including the recipients who should receive the email.

Follow these steps:

  1. Retrieve the recipients using the New Editor – Recipients endpoint.

  2. Create the campaign using the New Editor – Campaign endpoint.

  3. Include the recipients in the request when creating the campaign.

Save the campaign id from the response. You will use it in steps 3 and 5.

3. Create a message

Next, create a message using the New Editor – Message endpoint.

The message contains the actual email content and is created separately from the campaign. This means the campaign and its content are managed as two separate components, which are connected in the next step.

In the request, set dispatcher to the campaign id from step 2 with type: "campaign". Save the message id from the response.

4. Connect the message to the template

Once both the template and the message have been created, you need to connect them.

Create a variant (a dynamic set) with the New Editor – Dynamic Set endpoint.

The dynamic set connects the message to the template, allowing the campaign to use the correct content and layout for delivery.

Pass the message id from step 3 as message_id and the template id from step 1 as template_id.

5. Schedule the campaign

Once all previous steps have been completed, you can schedule the campaign for delivery using the Campaign Schedule endpoint.

This is the final step in the process and should be performed once the campaign has been fully configured.

Use the campaign id from step 2 in the endpoint path.

Tips and frequently asked questions

Can I still use API v2?

Yes, the API v2 transactional methods are still working. They will be deprecated in the future so we recommend updating to this version.

Why is the message created separately from the campaign?

The campaign handles the delivery settings, such as recipients, while the message contains the actual email content.

By creating these separately, they can be connected to a template by creating a variant (a dynamic set) with the New Editor – Dynamic Set endpoint.

Did this answer your question?