Javascript (Jquery) example

ⓘ This example is purely and solely for example purposes and is by no mean production ready. If you have written a library based on our API please  keep in touch.

Find below an example of using jQuery.ajax to subscribe an email address.

// Set variables
var uuid = "YOUR_LIST_UUID"
var base_url = "https://maitreapp.co/api/v2/lists/"+ uuid +"/subscribers";
var payload = {
  api_token: "YOUR_API_TOKEN",
  hosting_url: "YOUR_HOSTING_URL",
  email: "john.doe@email.com",
  name: "John Doe"
};

// POST the request
$.ajax({
  url: base_url,
  type: "POST",
  data: payload,
  success: function(data) {
    if (data.status == "ok") {
      // Email successful subscribed
    } else {
      // Handle error
    }
  }
});

Still need help? Contact Us Contact Us