Chilkat Online Tools

Node.js / Braze Endpoints / Query List of Unsubscribed Email Addresses

Back to Collection Items

var os = require('os');
if (os.platform() == 'win32') {  
    if (os.arch() == 'ia32') {
        var chilkat = require('@chilkat/ck-node21-win-ia32');
    } else {
        var chilkat = require('@chilkat/ck-node21-win64'); 
    }
} else if (os.platform() == 'linux') {
    if (os.arch() == 'arm') {
        var chilkat = require('@chilkat/ck-node21-arm');
    } else if (os.arch() == 'x86') {
        var chilkat = require('@chilkat/ck-node21-linux32');
    } else {
        var chilkat = require('@chilkat/ck-node21-linux64');
    }
} else if (os.platform() == 'darwin') {
    if (os.arch() == 'arm64') {
        var chilkat = require('@chilkat/ck-node21-mac-m1');
    } else {
        var chilkat = require('@chilkat/ck-node21-macosx');
    }
}


function chilkatExample() {

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    var http = new chilkat.Http();
    var success;

    var queryParams = new chilkat.JsonObject();
    queryParams.UpdateString("start_date","2020-01-01");
    queryParams.UpdateString("end_date","2020-02-01");
    queryParams.UpdateInt("limit",1);
    queryParams.UpdateInt("offset",1);
    queryParams.UpdateString("sort_direction","desc");
    queryParams.UpdateString("email","example@braze.com");

    // Adds the "Authorization: Bearer {{api_key}}" header.
    http.AuthToken = "{{api_key}}";

    // resp: HttpResponse
    var resp = http.QuickRequestParams("GET","https://rest.iad-01.braze.com/email/unsubscribes",queryParams);
    if (http.LastMethodSuccess == false) {
        console.log(http.LastErrorText);
        return;
    }

    console.log(resp.StatusCode);
    console.log(resp.BodyStr);


}

chilkatExample();

Curl Command

curl -G -d "start_date=2020-01-01"
	-d "end_date=2020-02-01"
	-d "limit=1"
	-d "offset=1"
	-d "sort_direction=desc"
	-d "email=example%40braze.com"
	-H "Authorization: Bearer {{api_key}}"
https://rest.iad-01.braze.com/email/unsubscribes

Postman Collection Item JSON

{
  "name": "Query List of Unsubscribed Email Addresses",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Authorization",
        "value": "Bearer {{api_key}}",
        "type": "text"
      }
    ],
    "url": {
      "raw": "https://{{instance_url}}/email/unsubscribes?start_date=2020-01-01&end_date=2020-02-01&limit=1&offset=1&sort_direction=desc&email=example@braze.com",
      "protocol": "https",
      "host": [
        "{{instance_url}}"
      ],
      "path": [
        "email",
        "unsubscribes"
      ],
      "query": [
        {
          "key": "start_date",
          "value": "2020-01-01",
          "description": "(Optional*) String in YYYY-MM-DD format\n\nStart date of the range to retrieve unsubscribes, must be earlier than end_date. This is treated as midnight in UTC time by the API."
        },
        {
          "key": "end_date",
          "value": "2020-02-01",
          "description": "(Optional*)  String in YYYY-MM-DD format\n\nEnd date of the range to retrieve unsubscribes. This is treated as midnight in UTC time by the API."
        },
        {
          "key": "limit",
          "value": "1",
          "description": "(Optional) Integer\n\nOptional field to limit the number of results returned. Limit must be greater than 1. Defaults to 100, maximum is 500."
        },
        {
          "key": "offset",
          "value": "1",
          "description": "(Optional) Integer \n\nOptional beginning point in the list to retrieve from"
        },
        {
          "key": "sort_direction",
          "value": "desc",
          "description": "(Optional) String\n\nPass in the value `asc` to sort unsubscribes from oldest to newest. Pass in `desc` to sort from newest to oldest. If sort_direction is not included, the default order is newest to oldest."
        },
        {
          "key": "email",
          "value": "example@braze.com",
          "description": "(Optional*) String\n\nIf provided, we will return whether or not the user has unsubscribed"
        }
      ]
    },
    "description": "Use the /email/unsubscribes endpoint to return emails that have unsubscribed during the time period from `start_date` to `end_date`. You can use this endpoint to set up a bi-directional sync between Braze and other email systems or your own database.\n\n> You must provide either an email or a start_date and an end_date. <br><br>If your date range has more than `limit` number of unsubscribes, you will need to make multiple API calls, each time increasing the `offset` until a call returns either fewer than `limit` or zero results."
  },
  "response": [
  ]
}