Skip to content
REST API

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.

Three methods actually send emails: 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

URLhttps://www.mdworks.fr/api_http/METHOD_NAME
HTTP methodPOST
HeaderContent-Type: application/json
Bodya 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:

MessageCause
Error action missingthe URL contains no method name
Error POST emptythe request body is empty
Error POST json_decodethe body is not valid JSON
Error api_key missingthe api_key parameter is missing
Error auth ipthe call comes from an undeclared IP (except api_http_open methods)
Error api_key invalidunknown 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

MethodPurposeSection
account_infoaccount details and credits, IP seen by the serverAccounts
user_listlist sub-accountsAccounts
get_sub_account_api_keyretrieve a sub-account’s API keyAccounts
pools_listlist the account’s IP poolsAccounts
user_createcreate a sub-accountAccounts
user_updateedit a sub-accountAccounts
user_deletedelete a sub-accountAccounts
user_langchange an account’s interface languageAccounts
list_listlist contact listsLists
list_fieldsread a list’s fieldsLists
list_createcreate a listLists
list_deletedelete a listLists
list_insertinsert contacts (data sent in the call)Lists
list_insert_urlinsert contacts from a URLLists
list_insert_or_updateinsert or update contactsLists
campaign_createcreate a draft campaignPreparing a campaign
campaign_updateedit a draft campaignPreparing a campaign
campaign_set_messageload the HTML messagePreparing a campaign
campaign_send_testsend a test (proof)Preparing a campaign
campaign_deletedelete a draft campaignPreparing a campaign
campaign_add_recipientsadd recipientsRecipients
inject_segmentlist_2_campaigninject a segment of a list into a campaignRecipients
campagne_import_statuscheck whether import and cleaning are finishedRecipients
mails_retires_importsaddresses removed at import and whyRecipients
campaign_scheduleschedule the actual send of a campaignScheduling the send
campaign_unschedulecancel the schedulingScheduling the send
campaign_listlist campaigns, whatever their statusViewing
campaign_getread a campaign’s settingsViewing
campaigns_statscampaigns sent in the last month and their statisticsViewing
campaign_resultsper-recipient sending resultsViewing
envoi_mail_autotrigger an automatic campaignAutomatic campaigns
unsub_addadd an address to the unsubscribed listUnsubscribes
unsub_global_addadd an address to the suppression listUnsubscribes
repoussoir_addadd an address to an exclusion listUnsubscribes
get_form_entriesretrieve a form’s entriesForms
Last updated on