The Delete command allows you to remove one or more Contacts from your realm. It requires the following arguments: Command, Realm, Password, and Data.
api_web?r=myrealm&p=mypass&c=delete&data=email^john.smith@domain.com
The command is ‘delete', the realm is ‘myrealm’ and the password is ‘mypass’. The contact record for the email 'john.smith@domain.com' will be deleted in the realm.
The Delete command is not list specific because it involves the entire Contact record and related information. It also generates a Global Optout record, preventing the email address from being later subscribed to any list. Any subsequent attempt to resubscribe will result in failure unless the force_sub argument is included in the command.
Note: If using the Relational Tables feature, when a contact is deleted foreign key data dependent on that contact will also be removed. This is true for both a regular table and a join table; however, not stored data in a flat table.
Example
Using all commands and arguments (please note the command is wrapped for display purposes only):
api_web?r=myrealm&p=mypass&c=delete&data=email,first ^jane@domain.com,Jayne^jane@domain.com,JD^john@domain.com,John
Three contacts will be deleted from the realm and an Optout record will be created for each.
Successful results return:
SUCCESS: 3 record(s) procesed. 3 users deleted
Please note that the Delete action cannot be undone. Be sure to double check the Contact before deleting data.
Customer Key Example
Some systems have the ability to define a unique Customer Key per contact. 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=delete&data=customer_key,email^11293,jane@domain.com
If the Customer Key is not included, the command will fail.
Results
The Delete command outputs either a SUCCESS or FAILURE message.
SUCCESS
The Delete command success message returns the SUCCESS message and includes the number of records processed. The result format is:
SUCCESS: [number_a] record(s) processed. [number_b] users deleted
If the Delete command includes records for more than one contact, all matching contacts will be deleted. The result only indicates the total number of deletions and does not return errors or reasons why some may have failed.
FAILURE
A Delete command will fail for several reasons. The result format is:
FAILURE: [Reason]
Arguments
The Delete command supports the following arguments:
Name |
Req? |
Description |
Argument |
Command |
Yes |
Defines the command to use. |
cmd=delete c=delete |
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] |
Data | Yes | Contact related data. Email is always required, and additional fields are optional. Be sure to include First Name if duplicate contacts exist with the same email address. |
data=[fields] d=[fields] |