Follow

Unsubscribe from List

The Unsubscribe command allows you to remove one or more subscribers from a single list.  It requires the following arguments: Command, Realm, Password, List, and Data.

api_web?r=myrealm&p=mypass&c=unsub&list_id=5&data=email^john.smith@domain.com

The command is ‘unsub', the realm is ‘myrealm’ and the password is ‘mypass’.  The subscriber with email 'john.smith@domain.com'  will be unsubscribed from list_id = '5'.  No other changes will be made to the Subscriber record.

The Unsubscribe command expects as least one field in the Data argument.  The email address of the subscriber is always required to remove a subscription record. 

In addition to the ability to unsubscribe from a single list, you can set the list_id to ‘0’ and the optout flag to ‘1’ (true) to generate a Global Opt Out.  This removes the specified subscriber from all lists in the realm.  It also generates a Global Opt Out record so the Subscriber will not be added to any lists in the future without a forced override.

Example

Using all commands and arguments (please note the command is wrapped for display purposes only):

api_web?r=myrealm&p=mypass&c=unsub&list_id=5&optout=1&data=email,first^jane@domain.com,Jane  

One subscriber will be removed from the list_id='5' and an opt out record will be created for the subscriber.

Successful results return:

SUCCESS: 1 record(s) processed. 1 users unsubscribed from list(s) 5 (1 total subscribers), Records Failed Other Error 0

Global Opt Out Example

To remove a subscriber from all Lists, use the Global Opt Out method:

api_web?r=myrealm&p=mypass&c=unsubscribe&list_id=0&optout=1&data=email,first ^jane@domain.com,Jayne

The subscriber will be removed from every list for which a subscription exists in the realm, and a global opt out record will be created.

Successful results return:

SUCCESS: 1 record(s) processed. 1 users unsubscribed from list(s) 0 (1 total subscribers), Records Failed Other Error 0

Multiple Subscriber Example

To remove more than one subscriber from a List, define each Subscriber in the data argument separated by the caret '^' character:

api_web?r=myrealm&p=mypass&c=unsubscribe&list_id=5&data=email,first^jane@domain.com,Jayne^jane.doe@domain.com,Jane^jdoe@domain.com,Jane

Each subscriber will be removed from the list.  Any failures are reported in a count along with the successful removals.  Successful results return:

SUCCESS: 3 record(s) processed. 2 users unsubscribed from list(s) 5 (2 total subscribers), Records Failed Other Error 1

NOTE:  The ability to unsubscribe multiple Subscribers in a single command is available in v12.05 and newer.

Customer Key Example

Some systems have the ability to define a unique Customer Key per subscriber.  If your realm has Customer Key enabled, then you must include the customer_key in the data argument along with email.  For example:

api_web?r=myrealm&p=mypass&c=unsubscribe&list_id=5&data=customer_key,email^11293,jane@domain.com

If the Customer Key is not included, the command will fail.

Results

The Unsubscribe command outputs either a SUCCESS or FAILURE message. 

As of v12.05, the number of Failures is also included.  If the Unsubscribe command includes records for more than one subscriber, all matching subscribers will be unsubscribed.  The result indicates the total number of unsubscribes and number of failures, but does not return reasons why some may have failed.

SUCCESS

The Unsubscribe command success message returns the SUCCESS message and includes the number of records processed and the list id.  The result format is:

SUCCESS: [number_a] record(s) processed. [number_b] users unsubscribed from list(s) [list_id] ([number_c] total subscribers), Records Failed Other Error [number_d]

FAILURE

A Unsubscribe command will fail for several reasons.  The result format is:

FAILURE: [Reason]  

Such as:

FAILURE: [number_a] record(s) processed. [number_b] users unsubscribed from list(s) [list_id] ([number_c] total subscribers), Records Failed Other Error [number_d]

Arguments

The Unsubscribe command supports the following arguments:

Name

Req?

Description

Argument

Command

Yes

Defines the command to use.

cmd=unsub
c=unsub

Realm

Yes

Name of the realm to run the command.  This is required, and the command will fail if the realm and password do not match.

realm=[realm_name]
r=[realm_name]

Password

Yes

Authentication code for API access.  This is required, and the command will fail if the realm and password do not match.

pwd=[password]
p=[password]

List ID

Yes

Identifier of the list to apply the command.

list_id=[list_id]

Force Optout

 

If enabled (1), an optout record will be created for the list, preventing the email address later being subscribed to the list.

optout=[0,1]

DEFAULT==0 

Data Yes Subscriber related data.  Email is always required, and additional fields are optional.

data=[fields]
d=[fields]

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk