Driving the platform with an AI assistant
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
| Task | Through the API |
|---|---|
| Set up a campaign: settings, HTML message, recipients | yes |
| Send a test | yes, one credit per address |
| Schedule the send of a campaign | yes, 10 minutes ahead at the earliest |
| Send a campaign immediately | no |
| Create contact lists and feed them | yes |
| Read statistics and per-recipient results | yes |
| Manage unsubscribes and sub-accounts | yes |
| Send SMS | yes, to French mobile numbers, with the SMS API |
| Lay out a message with the responsive editor | no: a campaign set up through the API is a raw message, whose HTML the assistant provides |
| Create an automatic campaign or an automation scenario | no, 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.megives 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.
| Need | Method | API |
|---|---|---|
| Check access, read email credits | account_info | REST |
| Set up a campaign from end to end | the sequence of calls | REST |
| Create or edit a campaign | campaign_create, campaign_update | REST |
| Load the HTML message | campaign_set_message | REST |
| Add recipients coming from a file or another tool | campaign_add_recipients, in batches of 255 | REST |
| Take the recipients from a platform list | inject_segmentlist_2_campaign | REST |
| Know whether the recipients are ready | campagne_import_status | REST |
| Send a test | campaign_send_test | REST |
| Schedule or unschedule the send | campaign_schedule, campaign_unschedule | REST |
| Find a campaign, read its settings back | campaign_list, campaign_get | REST |
| Statistics of the last month’s sends | campaigns_stats | REST |
| Send status per recipient | campaign_results | REST |
| List or create lists, read their fields | list_list, list_create, list_fields | REST |
| Add or update contacts in a list | list_insert, list_insert_or_update | REST |
| Send a prepared email on demand (confirmation, reminder) | envoi_mail_auto | REST |
| Unsubscribe an address | unsub_add, or repoussoir_add for an exclusion list | REST |
| Retrieve the entries of a form | get_form_entries | REST |
| Manage sub-accounts | user_list, user_create, user_update | REST |
| Bring a contact into an automation scenario | Add a recipient in the loop of a scenario | SOAP |
| Search or delete a row in a hosted database | Database module | SOAP |
| Add email credit to a sub-account | Resellers: add sending credit to a sub-account | SOAP |
| Send an SMS | SMS API V2 | SMS |
| Read SMS credits | Retrieve account credits | SMS |
| Bounces and volumes of sends made through SMTP | SMTP API | SMTP |
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_autoand any SMS send;campaign_delete,list_deleteanduser_delete, which delete permanently;unsub_add,unsub_global_addandrepoussoir_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.