Prerequisite: Customer support or any other employees on the client’s end that are unsubscribing (canceling and refunding) users through the Piano dashboard leave a note on the customer’s record (for example “CS unsubscribed”).
As a first thing, the endpoint /publisher/subscription/list should be called to get an array of unsubscribed users.
Then, the endpoint /publisher/user/note/list needs to be called for every user from the previous step. If this user will have a note from Customer Service, you can add him to some DB/file. If not, just skip him.
You can take a look at this pseudocode example, which will return users that have been unsubscribed via the dashboard and have a note containing the text “CS unsubscribed” associated with their account:
let cancelledUsers = https://api.piano.io/api/v3/publisher/subscription/list?aid=XXXXX&api_token=XXXX&status=cancelled&offset=0&limit=10000&start_date=XX.XX.XXXX&end_date=XX.XX.XXXX;
let userNote = https://api.piano.io/api/v3/publisher/subscription/list?aid=XXX&api_token&limit=100&offset=0&uid=;
fetch(cancelledUsers).then(response => response.json()).then(data => {
data.forEach(user {
let uid = user.uid;
fetch(userNote + uid).then(response => response.json()).then(notes =>{
notes.forEach(note => {
if(note.content == "CS unsubscribed"){
write.user.to.db;
}else{
return skip.him;
}
});
});
});
});
All available base URLs for other Production locales are listed here.