updateContact( )


Updates a contact.

Each time the contact is updated, revision increments by 1. The existing revision must be included when updating the contact. This ensures you're working with the latest contact information, and it prevents unintended overwrites.

You can't call Update Contact to update the primaryEmail of a contact who is also a member. Instead, use the Members API to update the member's login email, which will also update the contact's primary email.

Members are typically linked to contacts, and while they share a relationship, the member ID and contact ID are distinct identifiers. Make sure to specifiy the contact ID when calling Update Contact.

Authentication

This function requires elevated permissions and runs only on the backend and on dashboard pages.

Permissions
Manage Members and Contacts - all permissions
Manage Contacts
Learn more about app permissions.
Method Declaration
Copy
function updateContact(
  contactId: string,
  info: ContactInfo,
  revision: number,
  options: UpdateContactOptions,
): Promise<UpdateContactResponse>;
Method Parameters
contactIdstringRequired

ID of the contact to update.


infoContactInfoRequired

Contact info.


revisionnumberRequired

Revision number. When updating, include the existing revision to prevent conflicting updates.


optionsUpdateContactOptions

Contact update options.

Returns
Return Type:Promise<UpdateContactResponse>
JavaScript
import { contacts } from "wix-crm.v2"; /* Sample contactId value: '2712ae1d-3f64-46c2-ac3a-94a6c2e29847' * * Sample revision value: '5' * * Sample info object: * { * phones: { * items: [ * { * countryCode:"US", * phone:"6465676359", * primary:true, * tag:"MOBILE" * }, * { * phone: "2421642341", * countryCode: "US", * primary: false, * tag: "HOME" * } * ] * } * } */ export async function myUpdateContactFunction( contactId, info, revision, options, ) { try { const updatedContact = await contacts.updateContact( contactId, info, revision, options, ); console.log("Successfully updated contact:", updatedContact); return updatedContact; } catch (error) { console.log(error); // Handle the error } } /* Promise resolves to: * { * "contact": { * "revision": 17, * "source": { * "sourceType": "WIX_CODE", * "appId": "151e476a-715e-ec33-db9a-a7ff4d51f70a" * }, * "lastActivity": { * "activityDate": "2023-12-24T11:50:46.048Z", * "activityType": "CONTACT_CREATED" * }, * "primaryInfo": { * "email": "johndoe1@example.com", * "phone": "646-567-6359" * }, * "info": { * "name": { * "first": "John", * "last": "Doe" * }, * "emails": { * "items": [ * { * "tag": "UNTAGGED", * "email": "johndoe1@example.com", * "primary": true, * "_id": "37db3bde-83c0-4ca2-8097-88964a2f343b" * }, * { * "tag": "UNTAGGED", * "email": "john.doe.at.home@example.com", * "primary": false, * "_id": "06eef938-13d2-49f3-8097-60686ab4ddd2" * } * ] * }, * "phones": { * "items": [ * { * "tag": "MOBILE", * "countryCode": "US", * "phone": "646-567-6359", * "e164Phone": "+16465676359", * "primary": true, * "_id": "01e597c0-76c6-4791-bb77-8b3309f893d1" * }, * { * "tag": "HOME", * "countryCode": "US", * "phone": "2421642341", * "primary": false, * "_id": "cbbae95c-e1d5-48c4-a3ec-531ee2bf51fb" * } * ] * }, * "addresses": { * "items": [ * { * "tag": "HOME", * "address": { * "formatted": "3 Park Ave\nNY, New York 10010\nUnited States", * "addressLine1": "3 Park Ave", * "city": "NY", * "subdivision": "US-NY", * "country": "US", * "postalCode": "10010" * }, * "_id": "eeb4e174-fd0f-4ce8-8cac-dc152f284228" * } * ] * }, * "company": "Wix", * "jobTitle": "Writer", * "birthdate": "1995-04-25", * "locale": "en-us", * "labelKeys": { * "items": [ * "custom.contact" * ] * }, * "extendedFields": { * "items": { * "contacts.displayByLastName": "Doe John", * "invoices.vatId": "", * "emailSubscriptions.deliverabilityStatus": "NOT_SET", * "emailSubscriptions.subscriptionStatus": "UNSUBSCRIBED", * "contacts.displayByFirstName": "John Doe", * "custom.nickname": "Jonny" * } * } * }, * "_id": "2712ae1d-3f64-46c2-ac3a-94a6c2e29847", * "_createdDate": "2023-12-24T11:50:46.049Z", * "_updatedDate": "2023-12-25T07:31:48.270Z" * } * } */
Errors
400Invalid Argument

There are 4 errors with this status code.

404Not Found

There is 1 error with this status code.

409Already Exists

There are 2 errors with this status code.

428Failed Precondition

There is 1 error with this status code.

This method may also return standard errors. Learn more about standard Wix errors.

Did this help?