Skip to content

Latest commit

 

History

History
125 lines (106 loc) · 2.66 KB

README.md

File metadata and controls

125 lines (106 loc) · 2.66 KB

Groups

List all groups

Official Documentation


const params = {
  limit: 25,
  page: 1,
  filter: {
    name: "dummy",
  },
  sort: "-name"
};

mailerlite.groups.get(params)
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    if (error.response) console.log(error.response.data);
  });

Create a group

Official Documentation


const params = {
  name: "Dummy group"
};

mailerlite.groups.create("GROUP_ID", params)
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    if (error.response) console.log(error.response.data);
  });

Update a group

Official Documentation


const params = {
  name: "Dummy group updated"
}

mailerlite.groups.update("GROUP_ID", params)
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    if (error.response) console.log(error.response.data);
  });

Delete group

Official Documentation


mailerlite.groups.delete("GROUP_ID")
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    if (error.response) console.log(error.response.data);
  });

Get subscribers belonging to a group

Official Documentation


const params = {
  filter: {
    status: "active" // active, unsubscribed, unconfirmed, bounced or junk
  },
  limit: 5,
  page: 1
};

mailerlite.groups.getSubscribers("GROUP_ID", params)
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    if (error.response) console.log(error.response.data);
  });

Assign subscriber to a group

Official Documentation


mailerlite.groups.assignSubscriber("SUBSCRIBER_ID", "GROUP_ID")
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    if (error.response) console.log(error.response.data);
  });

Unassign subscriber from a group

Official Documentation


mailerlite.groups.unAssignSubscriber("SUBSCRIBER_ID", "GROUP_ID")
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    if (error.response) console.log(error.response.data);
  });