The Delete Contact by ID command allows you to remove a single Contact based on a specific Contact ID. It requires the following arguments: Command, Realm, Password, and Contact ID.
api_web?r=myrealm&p=mypass&c=deletesubid&subscriber_id=3121
The command is ‘deletesubid', the realm is ‘myrealm’ and the password is ‘mypass’. The contact record with the ID '3121' will be deleted in the realm.
The Delete Contact by ID command is not list specific because it involves the entire Contact record and related information. It can also generate a Global Optout record by adding the argument optout=1, 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=deletebyid&subscriber_id=3121&optout=1
The contact will be deleted from the realm and an Optout record will be created.
Successful results return:
SUCCESS: subscriber_id 3121 successfully 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 ID of the record processed. The result format is:
SUCCESS: subscriber_id [id] successfully deleted.
FAILURE
A Delete command will fail for several reasons. The result format is:
FAILURE: [Reason]
Arguments
The Delete Contact by ID command supports the following arguments:
Name |
Req? |
Description |
Argument |
Command |
Yes |
Defines the command to use. |
cmd=deletesubid c=deletesubid |
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] |
Contact ID | Yes | Contact identification. |
subscriber_id=[id] |
Force Opt Out | If enabled (1), an optout record will be created for the contact, preventing the email address later being subscribed to any list. |
optout=[0,1] DEFAULT==0 |
*Added in release v12.05.0