Mailing lists

    Get all the mailing lists

    Get all the mailing lists created on a website

    Request

    • Method: GET
    • Version: v3, this API call supports additional sort and filter mechanisms as well as retrieving only a sub-set of fields

      Note: In order to access the v3 API endpoints please make sure you have enabled the new rendering engine.

    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/mailinglists
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Response

    An array of the first 10 mailing lists; each object has the following properties:

    • id - the mailing list's ID (integer)
    • siteId - the id of the site (integer)
    • roleId - the role id responsible assigned to the mailing list. -1 for none (integer)
    • templateId - the id assigned to the mailing list's autoresponder. Special values include -1 for none and 0 for the default template. (integer)
    • name - the mailing list's name (integer)
    • emailFrom - the mail list autoresponder's "from" name (integer)
    • emailAddress - the mail list autoresponder's "from" email address(integer)
    • emailSubject - the mail list autoresponder's subject (string)
    • emailFormat - the mail list autoresponder's format. Possible values:(string)
      • 2 - text
      • 1 - HTML
    • emailContent - the autoresponder email content (string)
    • createDate - the mailing list's creation date (dateTime)
    • lastUpdateDate - the mailing list's last update date (dateTime)
    • enabled (boolean)

    The response is paginated, you can skip and limit the number if items retrieved. Also take a look at the API V3: sorting and filtering for additional switches you can use.

    You can output additional fields to those listed above as default, see the API v3 Discovery APP for additional details.

    Accepts and returns JSON as Content-Type.


    Request:

    GET /webresources/api/v3/sites/current/mailinglists HTTPS/1.1
    Authorization: 14f87f21c5ea4830a06a6314a8aad82b45bc61dc08f24a0fb55599cea83ca811
    Connection: keep-alive
    Content-Type: application/json
    

    Response:

    {
    	"items": [
    		{
    			"id": 51787,
    			"siteId": 2684161,
    			"roleId": -1,
    			"templateId": -1,
    			"name": "Clients",
    			"emailFrom": "John Doe",
    			"emailAddress": "jdoe@mailinator.com",
    			"emailSubject": "Thank you for your subscription",
    			"emailFormat": 2,
    			"emailContent": "

    Dear {tag_recipientfirstname},

    Thank you for your subscription

    ", "createDate": "2017-05-11T11:23:46.3", "lastUpdateDate": "2017-05-11T11:23:46.3", "enabled": true }, { "id": 51846, "siteId": 2684161, "roleId": -1, "templateId": -1, "name": "Platinum customers", "emailFrom": "Jane Doe", "emailAddress": "j-doe@mailinator.com", "emailSubject": "Thank you for your subscription", "emailFormat": 2, "emailContent": "

    Dear {tag_recipientfirstname},

    Thank you for your subscription

    ", "createDate": "2017-11-13T11:59:51.39", "lastUpdateDate": "2017-11-13T12:00:33.973", "enabled": true }, { "id": 51847, "siteId": 2684161, "roleId": -1, "templateId": -1, "name": "Gold customers", "emailFrom": "Jane Doe", "emailAddress": "j-doe@mailinator.com", "emailSubject": "Thank you for your subscription", "emailFormat": 2, "emailContent": "

    Dear {tag_recipientfirstname},

    Thank you for your subscription

    ", "createDate": "2017-11-13T12:00:18.593", "lastUpdateDate": "2017-11-13T12:00:18.593", "enabled": true } ], "totalItemsCount": 3, "skip": 0, "limit": 10 }

    Sample code

    Get all the mailing lists for a site

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/mailinglists",
        type: "GET",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
    
        }
    });
    request.done(function (msg) {
        console.log(msg);
    })
    request.fail(function (jqXHR) {
        console.log("Request failed.");
        console.log("Error code: " + jqXHR.status);
        console.log("Error text: " + jqXHR.statusText);
        console.log("Response text: " + jqXHR.responseText);
    })

    Get a mailing list's details

    Get a particular mailing list by ID.

    Request

    • Method: GET
    • Version: v3, this API call supports additional sort and filter mechanisms as well as retrieving only a sub-set of fields

      Note: In order to access the v3 API endpoints please make sure you have enabled the new rendering engine.

    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/mailinglists/[mailinglist_ID]
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Response

    The details for the specified mailing list ID in JSON format.

    • id - the mailing list's ID (integer)
    • siteId - the id of the site (integer)
    • roleId - the role id responsible assigned to the mailing list. -1 for none (integer)
    • templateId - the id assigned to the mailing list's autoresponder. Special values include -1 for none and 0 for the default template. (integer)
    • name - the mailing list's name (integer)
    • emailFrom - the mail list autoresponder's "from" name (integer)
    • emailAddress - the mail list autoresponder's "from" email address(integer)
    • emailSubject - the mail list autoresponder's subject (string)
    • emailFormat - the mail list autoresponder's format. Possible values:(string)
      • 2 - text
      • 1 - HTML
    • emailContent - the autoresponder email content (string)
    • createDate - the mailing list's creation date (dateTime)
    • lastUpdateDate - the mailing list's last update date (dateTime)
    • enabled (boolean)

    The response is paginated, you can return only a few of the mailing list's fields. Take a look at the API V3: sorting and filtering for additional switches you can use.

    Accepts and returns JSON as Content-Type.


    Request:

    GET /webresources/api/v3/sites/current/mailinglists/51787 HTTPS/1.1
    Authorization: 14f87f21c5ea4830a06a6314a8aad82b45bc61dc08f24a0fb55599cea83ca811
    Connection: keep-alive
    Content-Type: application/json
    

    Response:

    {
    	"id": 51787,
    	"siteId": 2684161,
    	"roleId": -1,
    	"templateId": -1,
    	"name": "Clients",
    	"emailFrom": "Catalin Usurelu",
    	"emailAddress": "usurelu@mailinator.com",
    	"emailSubject": "Thank you for your subscription",
    	"emailFormat": 2,
    	"emailContent": "

    Dear {tag_recipientfirstname},

    Thank you for your subscription

    ", "createDate": "2017-05-11T11:23:46.3", "lastUpdateDate": "2017-05-11T11:23:46.3", "enabled": true }

    Sample code

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/mailinglists/51787",
        type: "GET",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        }
    });
    request.done(function (msg) {
        console.log(msg);
    })
    request.fail(function (jqXHR) {
        console.log("Request failed.");
        console.log("Error code: " + jqXHR.status);
        console.log("Error text: " + jqXHR.statusText);
        console.log("Response text: " + jqXHR.responseText);
    })

    Create a mailing list

    Create a new mailing list.

    Request

    • Method: POST
    • Version: v3
    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/mailinglists/
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Parameters

    • siteId - the id of the site (integer)
    • roleId - the role id responsible assigned to the mailing list. -1 for none (integer)
    • templateId - the id assigned to the mailing list's autoresponder. Special values include -1 for none and 0 for the default template. (integer)
    • name - the mailing list's name (integer)
    • emailFrom - the mail list autoresponder's "from" name (integer)
    • emailAddress - the mail list autoresponder's "from" email address(integer)
    • emailSubject - the mail list autoresponder's subject (string)
    • emailFormat - the mail list autoresponder's format. Possible values:(string)
      • 2 - text
      • 1 - HTML
    • emailContent - the autoresponder email content (string)
    • enabled (boolean)

    Sample code

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
    url: "/webresources/api/v3/sites/current/mailinglists",
    type: "POST",
    connection: "keep-alive",    
        contentType: "application/json",
    processData: false,
    headers: {
        "Authorization": $.cookie('access_token'),
      
    },
      data: JSON.stringify({
        "roleId": -1,
        "templateId": -1,
        "name": "Bronze customers",
        "emailFrom": "Jane Doe",
        "emailAddress": "jadoe@mailinator.com",
        "emailSubject": "Thank you for your subscription",
        "emailFormat": 2,
        "emailContent": "Your subscription to our mailing list has been successful!",
        "enabled": true
    })
    });
    request.done(function(msg) {
    console.log(msg);
    })
    request.fail(function(jqXHR) {
    console.log("Request failed.");
    console.log("Error code: " + jqXHR.status);
    console.log("Error text: " + jqXHR.statusText);
    console.log("Response text: " + jqXHR.responseText);
    })

    Edit a mailing list's details

    Edit the details for an existing mailing list.

    Request

    • Method: PUT
    • Version: v3
    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/mailinglists/[mailinglist_ID]
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Parameters

    • siteId - the id of the site (integer)
    • roleId - the role id responsible assigned to the mailing list. -1 for none (integer)
    • templateId - the id assigned to the mailing list's autoresponder. Special values include -1 for none and 0 for the default template. (integer)
    • name - the mailing list's name (integer)
    • emailFrom - the mail list autoresponder's "from" name (integer)
    • emailAddress - the mail list autoresponder's "from" email address(integer)
    • emailSubject - the mail list autoresponder's subject (string)
    • emailFormat - the mail list autoresponder's format. Possible values:(string)
      • 2 - text
      • 1 - HTML
    • emailContent - the autoresponder email content (string)
    • enabled (boolean)

    Response

    Returns an empty body if successful or a detailed error message.

    Accepts and returns JSON as Content-Type.


    Sample code

    Edit a mailing list's name

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
    url: "/webresources/api/v3/sites/current/mailinglists/51787",
    type: "PUT",
    connection: "keep-alive",    
        contentType: "application/json",
    headers: {
        "Authorization": $.cookie('access_token')
    },
    processData: false,
    data: JSON.stringify({
        "name": "Platinum customers - duplicate",
        "lastName": "Smith"
    })
    });
    request.done(function(msg) {
    console.log(msg);
    })
    request.fail(function(jqXHR) {
    console.log("Request failed.");
    console.log("Error code: " + jqXHR.status);
    console.log("Error text: " + jqXHR.statusText);
    console.log("Response text: " + jqXHR.responseText);
    })
    

    Delete a mailing list

    Delete a mailing list.

    Request

    • Method: DELETE
    • Version: v3
    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/mailinglists/[mailinglist_ID]
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Response

    Returns an empty body if successful or a detailed error message.


    Request:

    DELETE /webresources/api/v3/sites/current/mailinglists/51787 HTTPS/1.1
    Authorization: 14f87f21c5ea4830a06a6314a8aad82b45bc61dc08f24a0fb55599cea83ca811
    Connection: keep-alive
    Content-Type: application/json
    

    Response:

    
    HTTP/1.1 204 NO CONTENT
    Location: /webresources/api/v3/sites/current/mailinglists/[mailinglist_ID]
    Content-Type: application/json; charset=utf-8
    Content-Length: length

    Sample code

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/mailinglists/51787",
        type: "DELETE",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        }
    });
    request.done(function(msg) {
        console.log(msg);
    })
    request.fail(function(jqXHR) {
        console.log("Request failed.");
        console.log("Error code: " + jqXHR.status);
        console.log("Error text: " + jqXHR.statusText);
        console.log("Response text: " + jqXHR.responseText);
    })