Skip to content
Driving the platform with an AI assistant

Driving the platform with an AI assistant

By Loïc Bresler 7 min read

An AI assistant that can write and run code, such as Claude Code, Cursor or ChatGPT, can drive the platform for you: set up a campaign from a contact file, feed a list, pull the results of a send. There is no dedicated connector. The assistant reads this documentation, writes the code that calls the REST API, then runs it.

To get started, simply give it the URL of this page. It tells the assistant which method to use for each need, and the rules to follow before anything that sends emails or uses credits.

This page is about assistants outside the platform. The editor’s AI Assistant, which helps you write a message in the interface, is a different feature.

What an assistant can do, and what it cannot do

TaskThrough the API
Set up a campaign: settings, HTML message, recipientsyes
Send a testyes, one credit per address
Schedule the send of a campaignyes, 10 minutes ahead at the earliest
Send a campaign immediatelyno
Create contact lists and feed themyes
Read statistics and per-recipient resultsyes
Manage unsubscribes and sub-accountsyes
Send SMSyes, to French mobile numbers, with the SMS API
Lay out a message with the responsive editorno: a campaign set up through the API is a raw message, whose HTML the assistant provides
Create an automatic campaign or an automation scenariono, they are prepared in the interface. The API then triggers or feeds them

Prepare the ground

Three precautions before handing the platform over to an assistant.

Keep the API key safe

Get the key as described in Retrieve the API key. Store it in an environment variable, for example MDWORKS_API_KEY, or in a .env file excluded from your code repository, and ask the assistant to read it from there.

Do not paste it into the conversation: everything you write there is sent to the assistant’s provider.

Declare the IP of the machine that runs the code

The REST API only accepts calls coming from a declared IP. What counts is the machine where the code runs, not the one where you chat with the assistant.

  • An assistant installed on your computer (Claude Code, Cursor…) calls the API from your connection. Declare its public IP, which the command curl ifconfig.me gives you, for example. It changes when you change network, from the office to home for instance: you then have to declare the new one.
  • An assistant that runs the code on its own servers goes out through IPs you do not know, which may change. Its calls will most often be refused with Error auth ip. Prefer an assistant that runs the code on your computer or on your server.

The SMS API has its own authorized IPs, to declare under SMS Campaigns > SMS API > Security.

Start with risk-free trials

For the first exchanges, have the assistant set up a test campaign aimed at your own addresses, and do not let it schedule any send. If you manage sub-accounts, a sub-account reserved for trials limits the risks further.

For the assistant: which method for which need

This section and the next one are addressed to the assistant. Use the REST API first, and the other APIs only for what it does not cover. The common call rules are described in Rules common to all methods.

NeedMethodAPI
Check access, read email creditsaccount_infoREST
Set up a campaign from end to endthe sequence of callsREST
Create or edit a campaigncampaign_create, campaign_updateREST
Load the HTML messagecampaign_set_messageREST
Add recipients coming from a file or another toolcampaign_add_recipients, in batches of 255REST
Take the recipients from a platform listinject_segmentlist_2_campaignREST
Know whether the recipients are readycampagne_import_statusREST
Send a testcampaign_send_testREST
Schedule or unschedule the sendcampaign_schedule, campaign_unscheduleREST
Find a campaign, read its settings backcampaign_list, campaign_getREST
Statistics of the last month’s sendscampaigns_statsREST
Send status per recipientcampaign_resultsREST
List or create lists, read their fieldslist_list, list_create, list_fieldsREST
Add or update contacts in a listlist_insert, list_insert_or_updateREST
Send a prepared email on demand (confirmation, reminder)envoi_mail_autoREST
Unsubscribe an addressunsub_add, or repoussoir_add for an exclusion listREST
Retrieve the entries of a formget_form_entriesREST
Manage sub-accountsuser_list, user_create, user_updateREST
Bring a contact into an automation scenarioAdd a recipient in the loop of a scenarioSOAP
Search or delete a row in a hosted databaseDatabase moduleSOAP
Add email credit to a sub-accountResellers: add sending credit to a sub-accountSOAP
Send an SMSSMS API V2SMS
Read SMS creditsRetrieve account creditsSMS
Bounces and volumes of sends made through SMTPSMTP APISMTP

For the assistant: the rules to follow

1. Ask for explicit confirmation before any action that sends, uses credits or cannot be undone. State what you are about to do, to how many recipients and for how many credits, then wait for the human’s agreement. This covers:

  • campaign_schedule, which actually sends the campaign to all its recipients;
  • campaign_send_test, which costs one credit per address;
  • envoi_mail_auto and any SMS send;
  • campaign_delete, list_delete and user_delete, which delete permanently;
  • unsub_add, unsub_global_add and repoussoir_add: the API cannot remove an address from these lists.

2. Never schedule a send before the human has approved the test, even if the initial request included the send. First read the campaign back with campaign_get, and present the subject, the sender, the number of recipients and the planned send date.

3. To send a campaign, use campaign_schedule only, in Paris time, in the YYYY-MM-DD HH:MM format. Do not use the send functions of the SOAP API.

4. Read the API key from the environment. Do not write it in the code, in a versioned file or in your answers.

5. Test the error key in every response. The API always responds with HTTP 200, even in case of error. On an error, stop and show the message to the human, except for the cleaning described in rule 7.

6. When facing Error auth ip, do not look for a workaround. Only the human can declare an IP. Give them the public IP of the machine that runs the code.

7. Respect batches and delays. campaign_add_recipients accepts 255 rows at most per call. A batch refused during the cleaning of the recipients is sent again as is a few seconds later. Wait until campagne_import_status returns a number before reading back, testing or scheduling the campaign.

8. Read a method’s page before calling it. Its parameters, responses and errors are described there: do not guess them, and do not call a write method to see what it does.

9. For marketing SMS, respect the time slots. They are forbidden between 8pm and 8am, on Sundays and on public holidays. Only solicited transactional SMS are allowed during these slots.

The rules to copy into the assistant’s instructions

For these rules to apply in every session, paste this block into your assistant’s permanent instructions: the CLAUDE.md file of a Claude Code project, the rules of a Cursor project, the instructions of a ChatGPT project or a system prompt.

Ediware (MDWorks) email marketing platform, driven through its REST API.
Starting documentation: https://help.ediware.net/developers/integrations/driving-the-platform-with-an-ai-assistant/

- Read the page of each method before calling it, do not guess parameters.
- API key in the MDWORKS_API_KEY environment variable, never in the code or in answers.
- The API always responds with HTTP 200: test the "error" key in every response.
- Ask for confirmation before campaign_schedule, campaign_send_test, envoi_mail_auto,
  any SMS send, any deletion and any unsubscribe.
- Never schedule a send before the test has been approved by a human.
- Send a campaign only with campaign_schedule, in Paris time.
- Error auth ip: do not work around it, ask the human to declare the IP.
Last updated on