How to create new subscribers through database?


Hi all,

How do I create new subscribers through the database?

I have a separate system A: when users registers at System A, I would like them to be created as a subscriber in the Mailwizz system. However, I noticed that there is a subscriber_uid in the list_subscriber table, which I think is auto-generated?
Also, can I leave the "source" as any value I want?

Why not using the API for this?
Anyway, subscriber_uid has to be a unique 13 chars hash, and is generated only when subscriber is added via mailwizz.
Also, can I leave the "source" as any value I want?
No, it has to be "web"

So that means there is no way I can do some sql and php code in my other system, to add a subscriber in my Mailwizz system?
Hi, I have seen and downloaded the github examples. However, could you get me started on where I should upload the files to and probably point me to which files I should be looking at to modify? Thanks!

I have never been exposed to API before.
Would this be correct:
  1. I upload github's examples/setup.php to
  2. Copy some codes from github's examples/list_subscribers.php to
  3. I upload the whole MailWizzApi folder to
  4. At system A, i post new subscribers' data to
  5. should look sth like this:
$response = $endpoint->create('LIST-UNIQUE-ID', array(
'EMAIL' => '',
// the confirmation email will be sent!!! Use valid email address
'CustomFieldTag' => $_POST['value'],
'CustomFieldTag' => $_POST['value'] ));​
Last edited:
Not quite no...
Here's an example with Site A and Site B
Site A is where mailwizz is installed and Site B is your second system, so we have:
Site B
--- public_html
------ MailwizzWebApi
------ setup-api.php
------ connect.php

In setup-api.php you have something like:
// require the autoloader class
require_once dirname(__FILE__) . '/MailWizzApi/Autoloader.php';
// register the autoloader.
// if using a framework that already uses an autoloading mechanism, like Yii for example, 
// you can register the autoloader like:
// Yii::registerAutoloader(array('MailWizzApi_Autoloader', 'autoloader'), true);
 * Notes: 
 * If SSL present on the webhost, the api can be accessed via SSL as well (https://...).
 * A self signed SSL certificate will work just fine.
 * If the MailWizz powered website doesn't use clean urls, 
 * make sure your apiUrl has the index.php part of url included, i.e: 
 * http://www.mailwizz-powered-website.tld/api/index.php
 * Configuration components:
 * The api for the MailWizz EMA is designed to return proper etags when GET requests are made.
 * We can use this to cache the request response in order to decrease loading time therefore improving performance.
 * In this case, we will need to use a cache component that will store the responses and a file cache will do it just fine.
 * Please see MailWizzApi/Cache for a list of available cache components and their usage.
// configuration object
$config = new MailWizzApi_Config(array(
    'apiUrl'        => '',
    'publicKey'     => 'PUBLIC-KEY', // generate this
    'privateKey'    => 'PRIVATE-KEY', // generate this
    // components
    'components' => array(
        'cache' => array(
            'class'     => 'MailWizzApi_Cache_File',
            'filesPath' => dirname(__FILE__) . '/../MailWizzApi/Cache/data/cache', // make sure it is writable by webserver
// now inject the configuration and we are ready to make api calls
// start UTC

and connect.php should contain something like:
require_once dirname(__FILE__) . '/setup-api.php';
if (!empty($_POST)) {
    $listUid    = 'LIST-UNIQUE-ID';// you'll take this from your customers area, in list overview from the address bar.
    $endpoint   = new MailWizzApi_Endpoint_ListSubscribers();
    $response   = $endpoint->create($listUid, array(
        'EMAIL' => isset($_POST['EMAIL']) ? $_POST['EMAIL'] : null,
        'FNAME' => isset($_POST['FNAME']) ? $_POST['FNAME'] : null,
        'LNAME' => isset($_POST['LNAME']) ? $_POST['LNAME'] : null,
    $response   = $response->body;
    // if the returned status is success, we are done.
    if ($response->itemAt('status') == 'success') {
            'status'    => 'success',
            'message'   => 'Thank you for joining our email list. Please confirm your email address now!'
    // otherwise, the status is error
        'status'    => 'error',
        'message'   => $response->itemAt('error')
[...] continue here with rest of page[...]

As you see, with Site A where mailwizz is hosted, you don't really have anything to do, just point the setup items to it when needed.
I don't know how i could explain this better...
See this also
Hi again,

At Site B, when users are created/users update certain values, I have used the API to create/update custom values for a specific list.

1) However, I realised I need to update the subscription values too (when users subscribe->unsubscribe / unsubscribe->subscribe at Site B). How can this be done, through any api or function etc?
Initially I just removed users from Site A (where Mailwizz is) when they unsubscribe at Site B. Then I realised it affected the statistics of campaigns. So no choice, I've got to update the subscription values.

2) When users unsubscribe through a Mailwizz campaign, I need to update a custom value. How can this be done?

For #1 - When you get a higher number of unsubscribes, you can use Bulk action from source feature (see your list overview) to import a csv file with those subscribers and mark them all as unconfirmed/unsubscribed/blacklisted.

For #2 - This will be, again, very tricky.
You can use webhooks so that when the subscriber unsubscribes to make a request to a url with the subscriber info and then in that url you process the request and by using the API you make a call to mailwizz and update this subscriber and set the custom field value as you wish.
It's pretty tricky to achieve though...
@twisted1919 Why should I use it?
Api runs through the Postman. I want to test other methods. But alas, I do not know the parameters that need to be sent.
All methods GET work. POST can not run, I swear on the required parameters.
@aglar - Not sure how that's possible since without proper keys and proper signature in headers you can't bypass the RequestAccess filter.(unless you have disabled the signature check, case in which you can reach that page if you have proper api keys).
Here's how a request looks in my end: 2017-02-24 11.50.32.png?dl=0

If you disabled the signature check, then you have to send the following headers:
X-MW-PUBLIC-KEY - (public api key to identify customer)  
X-MW-TIMESTAMP - (integer timestamp)
X-MW-SIGNATURE - (this has to have some value in it, say the string '---')

For the request type and rest of params, the SDK classes will show what you need to send.