Unsubscribe to your campaign

Listen to the incoming unsubscribe requests and manage your recipient mailing list accordingly.
Once a recipient number has unsubscribed from your campaign, any outbound SMS to that number will be blocked.

Send a request and see the list of phone numbers that are unsubscribed from your campaign:

//Decode the json object you retrieved when you ran the request.vardecodedResponse=JSON.parse(responseData);console.log('You sent '+decodedResponse['message-count']+' messages.\n');decodedResponse['messages'].forEach(function(message){if(message['status']==="0"){console.log('Success '+decodedResponse['message-id']);}else{console.log('Error '+decodedResponse['status']+' '+decodedResponse['error-text']);}});

<?php//Decode the json object you retrieved when you ran the request.
$decoded_response=json_decode($response,true);error_log('You sent '.$decoded_response['message-count'].' messages.');foreach($decoded_response['messages']as$message){if($message['status']==0){error_log("Success ".$message['message-id']);}else{error_log("Error {$message['status']}{$message['error-text']}");}}

importjson#Using the response object from the requestifresponse.code==200:data=response.read()#Decode JSON response from UTF-8decoded_response=json.loads(data.decode('utf-8'))# Check if your messages are successfulmessages=decoded_response["messages"]formessageinmessages:ifmessage["status"]=="0":print"success"else:#Check the errorsprint"unexpected http {code} response from nexmo api".response.code

require'json'#Decode the json object from the response object you retrieved from the request.ifresponse.kind_of?Net::HTTPOKdecoded_response=JSON.parse(response.body)messagecount=decoded_response["message-count"]decoded_response["messages"].eachdo|message|ifmessage["status"]=="0"p"message "+message["message-id"]+" sent successfully.\n"elsep"message has error "+message["status"]+" "+message["error-text"]endendelseputsresponse.code+" error sending message"end

Resubscribe to your campaign

Resubscribe requests for Event Based Alerts are handled through your Website.

//Decode the json object you retrieved when you ran the request.vardecodedResponse=JSON.parse(responseData);console.log('You sent '+decodedResponse['message-count']+' messages.\n');decodedResponse['messages'].forEach(function(message){if(message['status']==="0"){console.log('Success '+decodedResponse['message-id']);}else{console.log('Error '+decodedResponse['status']+' '+decodedResponse['error-text']);}});

<?php//Decode the json object you retrieved when you ran the request.
$decoded_response=json_decode($response,true);error_log('You sent '.$decoded_response['message-count'].' messages.');foreach($decoded_response['messages']as$message){if($message['status']==0){error_log("Success ".$message['message-id']);}else{error_log("Error {$message['status']}{$message['error-text']}");}}

importjson#Using the response object from the requestifresponse.code==200:data=response.read()#Decode JSON response from UTF-8decoded_response=json.loads(data.decode('utf-8'))# Check if your messages are successfulmessages=decoded_response["messages"]formessageinmessages:ifmessage["status"]=="0":print"success"else:#Check the errorsprint"unexpected http {code} response from nexmo api".response.code

require'json'#Decode the json object from the response object you retrieved from the request.ifresponse.kind_of?Net::HTTPOKdecoded_response=JSON.parse(response.body)messagecount=decoded_response["message-count"]decoded_response["messages"].eachdo|message|ifmessage["status"]=="0"p"message "+message["message-id"]+" sent successfully.\n"elsep"message has error "+message["status"]+" "+message["error-text"]endendelseputsresponse.code+" error sending message"end