Skip to content

Latest commit

 

History

History
76 lines (63 loc) · 1.52 KB

README.md

File metadata and controls

76 lines (63 loc) · 1.52 KB

Segments

List all segments

Official Documentation


const params = {
  limit: 25,
  page: 1
};

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

Get subscribers belonging to a segment

Official Documentation


const params = {
  filter: {
    status: "active",
  },
  limit: 5,
  after: "SUBSCRIBER_ID"
}

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

Update segment

Official Documentation


const params = {
  name: "Updated segment name"
};

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

Delete segment

Official Documentation


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