Search.../

deleteContact( )

Deletes a contact who is not a site member or contributor.

Description

The deleteContact() function returns a Promise that resolves when the specified contact is deleted.

Note: This function replaces the deprecated wixCrmBackend.deleteContact(). The deprecated function will continue to work, but it will not receive updates. To keep any existing code compatible with future changes, see the migration instructions.

Deleting a contact permanently removes them from your Contact List.

If the contact is also a site member, the member must be deleted first, and then the contact can be deleted.

Note: Only visitors with Manage Contacts permissions can delete contacts. You can override the permissions by setting the suppressAuth option to true.

Syntax

function deleteContact(contactId: string, [options: AuthOptions]): Promise<void>

deleteContact Parameters

NAME
TYPE
DESCRIPTION
contactId
string

ID of the contact to delete.

options
Optional
AuthOptions

Authorization options.

Returns

Return Type:

Promise<void>

Was this helpful?

Delete a contact

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { contacts } from 'wix-crm-backend';
3
4export const myDeleteContactFunction = webMethod(Permissions.Anyone, () => {
5 const contactId = "43fd5f9e-d7d4-4a31-8bfc-3bdc180cc40a";
6 const options = {
7 suppressAuth: false
8 };
9
10 return contacts.deleteContact(contactId, options)
11 .then(() => {
12 console.log("Contact deleted");
13 })
14 .catch((error) => {
15 console.error(error);
16 });
17});