We created a new viewing experience for our SMS API documentation. It's now all in one central location. Click here to check it out!

Opt a user out of one list or all lists. Typically a user will opt out of your lists themselves however if you offer alternative methods such as handling opt out requests via telephone support, this call might be useful for you. Possible results from this method are:



OPTED_OUT - recipient was opted out succesfully.
OPTOUT FAILED - recipient was not opted out because they did not exist on the contact list.


  • list_id - integer - the list id as a numeric value, this can be found by requesting 'contact-lists.get' and using corresponding id values from the dataset
  • mobile - string - recipients mobile number in INTERNATIONAL format (the mobile number as returned in a 'contact-lists.get-recipients' call)


 




 




XML Request Example


<?xml version='1.0'?>

<request>

	<interface>PHP</interface>

	<version>0.3</version>

	<key>API_KEY</key>

	<secret>API_SECRET</secret>

	<method>contact-lists.optout-recipient</method>

	<params>

		<list_id>175</list_id>

		<mobile>6141xxxxxxx</mobile>

	</params>

</request>







XML Response Example


<?xml version='1.0'?>

<xml>

	<method>contact-lists.optout-recipient</method>

	<total>1</total>

	<time>2009-12-21 23:07:05 GMT</time>

	<timestamp>1261436825 GMT</timestamp>

	<result>OPTED_OUT</result>

</xml>







PHP Example


<?php



// change api key and secret to your own

$myAPIKey = "API_KEY";

$myAPISecret = "API_SECRET";



// include base class

require('APIclient.php');



// create new client object

$transmitsmsAPI = new transmitsmsAPI($myAPIKey, $myAPISecret);



// execute request

$methodResponse = $transmitsmsAPI->optoutContactListRecipient(0, 614xxxxx);



// parse response into xml object

$xml = @simplexml_load_string($methodResponse);



// problem with request 

if (! $xml) { 

	exit(date("y-m-d H:i:s") . " - Problem with request : " . $methodResponse);

}



// valid response has come back

else {

	

	// view contents of the request in raw dump form

	echo "<pre>";

	print_r($xml);

	echo "</pre>";

}



?>






GET Example


Using a URL based request system you can request this method by using the below URL - be sure to url encode all your variables!


http://burst.transmitsms.com/api-wrapper/contact-lists.optout-recipient?apikey=API_KEY&apisecret=API_SECRET&list_id=LIST_ID&mobile=MOBILE