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
using System;
using System.Configuration;
using etAPI;
public partial class SubscriberDelete : System.Web.UI.Page
{
//Global Variables
private SoapClient client = new SoapClient();
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
Subscriber sub = new Subscriber();
// Use one of the following to identify the subscriber
sub.SubscriberKey = "12345"; // Preferred method
sub.EmailAddress = "acruz@example.com";
sub.ID = 123456789;
try
{
string requestID = String.Empty;
string status = String.Empty;
DeleteResult[] results = null;
//Call the Delete method on the Subscriber object
results = client.Delete(null, new APIObject[] { sub }, out requestID, out status);
//Display Results
lblMessage.Text += "Overall Status: " + status;
lblMessage.Text += "<br/>";
lblMessage.Text += "Number of Results: " + results.Length;
lblMessage.Text += "<br/>";
//Loop through each object returned and display the StatusMessage
foreach (DeleteResult result in results)
{
lblMessage.Text += "Status Message: " + result.StatusMessage;
lblMessage.Text += "<br/>";
}
}
catch (Exception ex)
{
lblMessage.Text += "<br/><br/>UPDATE ERROR:<br/>" + ex.Message;
}
}
catch (Exception exc)
{
lblMessage.Text += "<br/><br/>###ERROR<br/>" + exc.Message;
}
}
}
Java (CXF) Code Example
public void testDeleteSubscriber() throws RemoteException {
try {
Soap stub = init();
Subscriber subscriber = new Subscriber();
subscriber.setSubscriberKey("jdoe@example.com");
DeleteRequest deleteRequest = new DeleteRequest();
APIObject[] apiObjects = {subscriber};
deleteRequest.getObjects().addAll(Arrays.asList(apiObjects));
deleteRequest.setOptions(new DeleteOptions());
DeleteResponse deleteResponse = stub.delete(deleteRequest);
System.out.println("Deleted Subscriber ::: " + deleteResponse.getOverallStatus());
} catch (Exception e) {
e.printStackTrace(); //Change the exception body at File > Settings > File Templates.
}
}
Sample SOAP Envelope
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header>
<fueloauth>YOUR_ACCESS_TOKEN</fueloauth>
</Header>
<Body>
<DeleteRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
<Objects xsi:type="Subscriber">
<PartnerKey xsi:nil="true"/>
<ObjectID xsi:nil="true"/>
<EmailAddress>example@example.com</EmailAddress>
</Objects>
</DeleteRequest>
</Body>
</Envelope>
Related Items
- Salesforce Help: Delete a Subscriber
- Unsubscriber Subscriber from an Email List