Deleting A Subscriber

Use this API call to delete a subscriber’s information from your account.

You don’t need to delete a subscriber in order to unsubscribe that subscriber from an email list.

When you delete a subscriber, your account also loses all tracking information related to that subscriber and a new instance of that subscriber could be added to lists from which that subscriber has previously unsubscribed. For this reason, we recommend that you unsubscribe subscribers rather than delete them.

Use these code examples to create your own API call.

Sample .NET Code 

1using System;
2using System.Configuration;
3using etAPI;
4public partial class SubscriberDelete : System.Web.UI.Page
5{
6    //Global Variables
7    private SoapClient client = new SoapClient();
8    protected void btnSubmit_Click(object sender, EventArgs e)
9    {
10        try
11        {
12            Subscriber sub = new Subscriber();
13            // Use one of the following to identify the subscriber
14            sub.SubscriberKey = "12345"; // Preferred method
15            sub.EmailAddress = "acruz@example.com";
16            sub.ID = 123456789;
17            try
18            {
19                string requestID = String.Empty;
20                string status = String.Empty;
21                DeleteResult[] results = null;
22                //Call the Delete method on the Subscriber object
23                results = client.Delete(null, new APIObject[] { sub }, out requestID, out status);
24                //Display Results
25                lblMessage.Text += "Overall Status: " + status;
26                lblMessage.Text += "<br/>";
27                lblMessage.Text += "Number of Results: " + results.Length;
28                lblMessage.Text += "<br/>";
29                //Loop through each object returned and display the StatusMessage
30                foreach (DeleteResult result in results)
31                {
32                    lblMessage.Text += "Status Message: " + result.StatusMessage;
33                    lblMessage.Text += "<br/>";
34                }
35            }
36            catch (Exception ex)
37            {
38                lblMessage.Text += "<br/><br/>UPDATE ERROR:<br/>" + ex.Message;
39            }
40        }
41        catch (Exception exc)
42        {
43            lblMessage.Text += "<br/><br/>###ERROR<br/>" + exc.Message;
44        }
45    }
46}

Java (CXF) Code Example 

1public void testDeleteSubscriber() throws RemoteException {
2    try {
3            Soap stub = init();
4            Subscriber subscriber = new Subscriber();
5            subscriber.setSubscriberKey("jdoe@example.com");
6            DeleteRequest deleteRequest = new DeleteRequest();
7            APIObject[] apiObjects = {subscriber};
8            deleteRequest.getObjects().addAll(Arrays.asList(apiObjects));
9            deleteRequest.setOptions(new DeleteOptions());
10            DeleteResponse deleteResponse = stub.delete(deleteRequest);
11            System.out.println("Deleted Subscriber ::: " + deleteResponse.getOverallStatus());
12        } catch (Exception e) {
13            e.printStackTrace();  //Change the exception body at File > Settings > File Templates.
14    }
15}

Sample SOAP Envelope 

1<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2     <Header>
3          <fueloauth>YOUR_ACCESS_TOKEN</fueloauth>
4     </Header>
5     <Body>
6          <DeleteRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
7               <Objects xsi:type="Subscriber">
8                    <PartnerKey xsi:nil="true"/>
9                    <ObjectID xsi:nil="true"/>
10                    <EmailAddress>example@example.com</EmailAddress>
11               </Objects>
12          </DeleteRequest>
13     </Body>
14</Envelope>

Related Items