REST API
The REST API lets you drive the platform from your own applications: manage your sub-accounts and contact lists, set up a complete campaign (settings, HTML message, recipients, test send) and schedule its send, track its results and feed your unsubscribe lists.
It does not cover every feature of the platform: some are only available in the SOAP API.
To hand these calls over to an AI assistant such as Claude Code or ChatGPT, see Driving the platform with an AI assistant.
campaign_schedule, which schedules the send of a campaign to its recipients, campaign_send_test, which sends a test, and envoi_mail_auto, which triggers an automatic campaign. All the others prepare or read, without sending anything. The API does not offer an immediate send of a campaign: the minimum scheduling delay is 10 minutes.REST API sections
Getting started
Retrieve the API key
In your account, go to the Account Management page > API / Zapier > Key for REST API and Zapier, and request an API key if the function is not yet activated. The key is passed in every call, in the api_key parameter.
Declare your IPs
On the same page, declare the IPs of the applications that will call the REST API, separated by commas.
Authentication to the REST API uses both the IP of the machine calling the API and the API key. The IP is checked first: a call from an undeclared IP always receives Error auth ip, whether the key is valid or not.
If your calls come from an online service (automation tool, cloud hosting), declare the outgoing IPs of that service. For Make, the list of IPs per zone is in Using the REST API from Make.
Methods whose access point starts with https://www.mdworks.fr/api_http_open/ are an exception. These display or statistics methods transmit no personal data and accept calls from any IP.
Make a first call
The account_info method is the right starting point. It only needs the key and returns, among other things, in ip, the address your calls arrive from, which is useful when a machine has several outgoing IPs. If you get Error auth ip, this address is not declared, and account_info is then rejected like the other methods: check the machine’s public outgoing IP, which often differs from its local IP behind a firewall, a proxy or with a cloud host.
curl -X POST https://www.mdworks.fr/api_http/account_info \
-H 'Content-Type: application/json' \
-d '{"api_key": "YOUR_API_KEY"}'{
"user_id": 1234,
"login": "myaccount",
"name": "Example Company",
"email": "contact@example.com",
"credits": 25000,
"ip": "54.75.157.176"
}Rules common to all methods
Call format
| URL | https://www.mdworks.fr/api_http/METHOD_NAME |
| HTTP method | POST |
| Header | Content-Type: application/json |
| Body | a UTF-8 encoded JSON object, which always contains api_key |
In the pages of this documentation, parameter tables do not repeat api_key: it is required everywhere.
Responses and errors
The API always answers with HTTP code 200, even on error. An error is recognised by the presence of the error key:
{"error": "1", "message": "Error campaign_id is missing or is not numeric"}The message text is in English and does not change from one version to the next: you can rely on it to tell errors apart in your code. Each method lists its own errors. These ones are common to all methods:
| Message | Cause |
|---|---|
Error action missing | the URL contains no method name |
Error POST empty | the request body is empty |
Error POST json_decode | the body is not valid JSON |
Error api_key missing | the api_key parameter is missing |
Error auth ip | the call comes from an undeclared IP (except api_http_open methods) |
Error api_key invalid | unknown key |
Text encoding
Input is always sent in UTF-8: accented letters, the € sign, emojis.
Output texts are also in UTF-8. Characters outside the Latin set (€ entered through the API in a subject, emojis, non-Latin alphabets) may however come back as numeric HTML entities, for instance € for € or 🚀 for 🚀. This is their storage format: recipients receive them correctly, as the platform converts them at send time.
Code example
Adding an address to the unsubscribed list with unsub_add:
$url = 'https://www.mdworks.fr/api_http/unsub_add';
$data = array(
'api_key' => 'YOUR_API_KEY',
'email' => 'address@example.com'
);
$options = array(
'http' => array(
'header' => "Content-Type: application/json\r\n",
'method' => 'POST',
'content' => json_encode($data, JSON_UNESCAPED_UNICODE)
)
);
$context = stream_context_create($options);
$result = json_decode(file_get_contents($url, false, $context), true);
if (isset($result['error'])) {
echo 'Error: ' . $result['message'];
}Method index
| Method | Purpose | Section |
|---|---|---|
account_info | account details and credits, IP seen by the server | Accounts |
user_list | list sub-accounts | Accounts |
get_sub_account_api_key | retrieve a sub-account’s API key | Accounts |
pools_list | list the account’s IP pools | Accounts |
user_create | create a sub-account | Accounts |
user_update | edit a sub-account | Accounts |
user_delete | delete a sub-account | Accounts |
user_lang | change an account’s interface language | Accounts |
list_list | list contact lists | Lists |
list_fields | read a list’s fields | Lists |
list_create | create a list | Lists |
list_delete | delete a list | Lists |
list_insert | insert contacts (data sent in the call) | Lists |
list_insert_url | insert contacts from a URL | Lists |
list_insert_or_update | insert or update contacts | Lists |
campaign_create | create a draft campaign | Preparing a campaign |
campaign_update | edit a draft campaign | Preparing a campaign |
campaign_set_message | load the HTML message | Preparing a campaign |
campaign_send_test | send a test (proof) | Preparing a campaign |
campaign_delete | delete a draft campaign | Preparing a campaign |
campaign_add_recipients | add recipients | Recipients |
inject_segmentlist_2_campaign | inject a segment of a list into a campaign | Recipients |
campagne_import_status | check whether import and cleaning are finished | Recipients |
mails_retires_imports | addresses removed at import and why | Recipients |
campaign_schedule | schedule the actual send of a campaign | Scheduling the send |
campaign_unschedule | cancel the scheduling | Scheduling the send |
campaign_list | list campaigns, whatever their status | Viewing |
campaign_get | read a campaign’s settings | Viewing |
campaigns_stats | campaigns sent in the last month and their statistics | Viewing |
campaign_results | per-recipient sending results | Viewing |
envoi_mail_auto | trigger an automatic campaign | Automatic campaigns |
unsub_add | add an address to the unsubscribed list | Unsubscribes |
unsub_global_add | add an address to the suppression list | Unsubscribes |
repoussoir_add | add an address to an exclusion list | Unsubscribes |
get_form_entries | retrieve a form’s entries | Forms |