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.

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.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function deleteContact(contactId: string): Promise<void>

deleteContact Parameters

NAME
TYPE
DESCRIPTION
contactId
string

ID of the contact to delete.

Returns

Return Type:

Promise<
void
>

Was this helpful?

Delete a contact (dashboard page code)

Copy Code
1import { contacts } from 'wix-crm.v2';
2
3/* Sample contactId value: '2712ae1d-3f64-46c2-ac3a-94a6c2e29847' */
4
5export async function myDeleteContactFunction(contactId) {
6
7 try {
8 await contacts.deleteContact(contactId);
9 console.log('Contact deleted.');
10 } catch (error) {
11 console.log(error);
12 // Handle the error
13 }
14}
15
16/* Promise resolves to void */
Delete a contact (export from backend code)

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { contacts } from 'wix-crm.v2';
3import { elevate } from 'wix-auth';
4
5/* Sample contactId value: '2712ae1d-3f64-46c2-ac3a-94a6c2e29847' */
6
7export const myDeleteContactFunction = webMethod(Permissions.Anyone, async (contactId) => {
8 try {
9 const elevatedDeleteContact = elevate(contacts.deleteContact);
10 await elevatedDeleteContact(contactId);
11 console.log('Contact deleted.');
12 } catch (error) {
13 console.log(error);
14 // Handle the error
15 }
16});
17
18/* Promise resolves to void */
19