Mailing lists and subscribers

    Get the subscribers for a mailing list

    This API endpoint is used to list the subscribers for a mailing list

    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/[mailinglists_ID]/subscribers
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Response

    The list of subscribers in JSON format.

    • entityId - the id of the subscribed entity (integer)
    • listId - the id of the mailing list (integer)
    • siteId - the id of the site (integer)
    • subscribeType - the way the entity was subscribed to this list (interger) Depending on how the customer was subscribed to the mailing lists, possible values are:
      • 1 - the customer subscribed via the site's front-end
      • 2 - the subscription was created via an import file
      • 3 - via the Admin Console from the E-Mail Marketing -> Mailing Lists panel
      • 4 - via the Admin Console from the CRM details panel
      • 5 - via the report generator - after generating a report, the resulting contacts were subscribed to this list
      • 6 - via an API call
    • customer - the customer's details (JSON)

    The response is paginated, you can return only a few of the customer's fields. 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/51787/subscribers HTTPS/1.1
    Authorization: 14f87f21c5ea4830a06a6314a8aad82b45bc61dc08f24a0fb55599cea83ca811
    Connection: keep-alive
    Content-Type: application/json
    

    Response:

    {
    	"items": [
    		{
    			"entityId": 7195611,
    			"listId": 51787,
    			"siteId": 2684161,
    			"subscribeType": 3,
    			"customer": {
    				"id": 7195611,
    				"siteId": 2684161,
    				"customerTypeId": 0,
    				"leadSourceTypeId": 0,
    				"industryTypeId": 0,
    				"ratingTypeId": 0,
    				"titleTypeId": null,
    				"externalId": null,
    				"firstName": "usurelu3",
    				"middleName": null,
    				"lastName": "",
    				"company": null,
    				"dateOfBirth": null,
    				"username": null,
    				"createDate": "2017-05-11T11:39:39.813",
    				"lastUpdateDate": "2017-05-11T11:39:39.813",
    				"wholesaler": false
    			}
    		},
    		{
    			"entityId": 7197447,
    			"listId": 51787,
    			"siteId": 2684161,
    			"subscribeType": 3,
    			"customer": {
    				"id": 7197447,
    				"siteId": 2684161,
    				"customerTypeId": 0,
    				"leadSourceTypeId": 0,
    				"industryTypeId": 0,
    				"ratingTypeId": 0,
    				"titleTypeId": null,
    				"externalId": null,
    				"firstName": "John",
    				"middleName": null,
    				"lastName": "Doe",
    				"company": null,
    				"dateOfBirth": null,
    				"username": null,
    				"createDate": "2017-11-13T12:13:16.393",
    				"lastUpdateDate": "2017-11-13T12:13:16.393",
    				"wholesaler": false
    			}
    		},
    		{
    			"entityId": 7197448,
    			"listId": 51787,
    			"siteId": 2684161,
    			"subscribeType": 3,
    			"customer": {
    				"id": 7197448,
    				"siteId": 2684161,
    				"customerTypeId": 0,
    				"leadSourceTypeId": 0,
    				"industryTypeId": 0,
    				"ratingTypeId": 0,
    				"titleTypeId": null,
    				"externalId": null,
    				"firstName": "Jane",
    				"middleName": null,
    				"lastName": "Doe",
    				"company": null,
    				"dateOfBirth": null,
    				"username": null,
    				"createDate": "2017-11-13T12:13:27.08",
    				"lastUpdateDate": "2017-11-13T12:13:27.08",
    				"wholesaler": false
    			}
    		}
    	],
    	"totalItemsCount": 3,
    	"skip": 0,
    	"limit": 10
    }

    Sample code

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/mailinglists/51787/subscribers",
        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);
    })

    Add a subscriber to a mailing list

    This API endpoint is used to subscribe a particular customer to a mailing list

    Request

    • Method: POST
    • 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/[entity_ID]/subscribers
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Parameters

    • {"items" : [ {"entityId" : 7055803}] } (JSON)

    Response

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

    Accepts and returns JSON as Content-Type.


    Request:

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

    Response:

    HTTP/1.1 204 NO CONTENT
    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/subscribers",
    type: "POST",
    connection: "keep-alive",    
        contentType: "application/json",
    processData: false,
    headers: {
        "Authorization": $.cookie('access_token'),
      
    },
    data: JSON.stringify({"items" :
        [
            {"entityId" : 7055803}]
    })
    });
    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);
    })

    Remove a subscriber from a mailing list

    This API endpoint is used to remove a subscriber from a mailing list.

    Request

    • Method: DELETE
    • 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]/subscribers?item=[{"entityId":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/20823/subscribers?items=[{"entityId": 7055807}] 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/20823/subscribers
    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/20823/subscribers?items=[{"entityId": 7055807}]",
        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);
    })