> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # UpdateContact # Package: contacts # Namespace: ContactsServiceV4 # Method link: https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/contacts/contact-v4/update-contact.md ## Permission Scopes: Manage Contacts: SCOPE.DC-CONTACTS.MANAGE-CONTACTS ## Introduction 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 specify the contact ID when calling Update Contact. --- ## REST API ### Schema ``` Method: updateContact Description: 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 GUID and contact GUID are distinct identifiers. Make sure to specify the contact GUID when calling Update Contact. URL: https://www.wixapis.com/contacts/v4/contacts/{contactId} Method: PATCH # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: revision, info Method parameters: param name: allowDuplicates | type: allowDuplicates | description: Controls whether the call will succeed if the new contact information contains an email or a phone number already used by another contact. If set to `true`, the call will succeed even if an email address or phone number is used by another contact. If set to `false`, the call will fail if the given email address is used by another contact or, if the email address is not given and the given phone number is used by another contact. Default: `false` param name: info | type: ContactInfo | required: true - name: name | type: ContactName | description: Contact's first and last name. - name: first | type: string | description: Contact's first name. - name: last | type: string | description: Contact's last name. - name: emails | type: ContactEmailsWrapper | description: Contact's email addresses. - name: items | type: array | description: List of up to 50 email addresses. - name: tag | type: EmailTag | description: Email type. `UNTAGGED` is shown as "Other" in the Contact List. - enum: UNTAGGED, MAIN, HOME, WORK - name: email | type: string | description: Email address. - name: primary | type: boolean | description: Indicates whether this is the contact's primary email address. When changing `primary` to `true` for an email, the contact's other emails become `false`. Changing the primary email of a contact also affects the subscription status to marketing emails that are decided based on the primary email. - name: phones | type: ContactPhonesWrapper | description: Contact's phone numbers. - name: items | type: array | description: List of up to 50 phone numbers. - name: tag | type: PhoneTag | description: Phone type. `UNTAGGED` is shown as "Other" in the Contact List. - enum: UNTAGGED, MAIN, HOME, MOBILE, WORK, FAX - name: countryCode | type: string | description: [ISO-3166 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code. - name: phone | type: string | description: Phone number. - name: primary | type: boolean | description: Indicates whether this is the contact's primary phone number. When changing `primary` to `true` for a phone, the contact's `primary` field for other phones becomes `false`. Changing the primary phone number also affects the subscription status to SMS messages that are decided based on the primary phone. - name: addresses | type: ContactAddressesWrapper | description: Contact's street addresses. - name: items | type: array | description: List of up to 50 addresses. - name: tag | type: AddressTag | description: Address type. `UNTAGGED` is shown as "Other" in the Contact List. - enum: UNTAGGED, HOME, WORK, BILLING, SHIPPING - name: address | type: Address | description: Street address. - ONE-OF: - name: streetAddress | type: StreetAddress | description: Street address object, with number and name in separate fields. - name: number | type: string | description: Street number. - name: name | type: string | description: Street name. - name: addressLine | type: string | description: Main address line, usually street and number, as free text. - name: country | type: string | description: 2-letter country code in an [ISO-3166 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format. - name: subdivision | type: string | description: Code for a subdivision (such as state, prefecture, or province) in an [ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2) format. - name: city | type: string | description: City name. - name: postalCode | type: string | description: Postal or zip code. - name: addressLine2 | type: string | description: Free text providing more detailed address information, such as apartment, suite, or floor. - name: company | type: string | description: Contact's company name. - name: jobTitle | type: string | description: Contact's job title. - name: birthdate | type: string | description: Birth date in `YYYY-MM-DD` format. For example, `2020-03-15`. - name: locale | type: string | description: Locale in [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. Typically, this is a lowercase 2-letter language code, followed by a hyphen, followed by an uppercase 2-letter country code. For example, `en-US` for U.S. English, and `de-DE` for Germany German. - name: labelKeys | type: LabelsWrapper | description: List of contact's labels. Labels are used to organize contacts. Labels can be added and removed using Label Contact and Unlabel Contact, respectively. To view or manage contact labels, use the Labels API. - name: items | type: array | description: List of contact label keys. Contact labels help categorize contacts. Label keys must exist to be added to the contact. Contact labels can be created or retrieved with Find or Create Label or List Labels. - name: extendedFields | type: ExtendedFieldsWrapper | description: Additional custom fields. Empty fields are not returned. - name: items | type: Map | description: Contact's extended fields, where each key is the field key, and each value is the field's value for the contact. To view and manage extended fields, use the Extended Fields API. - ONE-OF: - name: nullValue | type: | description: - name: numberValue | type: number | description: - name: stringValue | type: string | description: - name: boolValue | type: boolean | description: - name: structValue | type: object | description: - name: listValue | type: ListValue | description: - name: values | type: array | description: - name: picture | type: ContactPicture | description: Contact's profile picture. - name: image | type: Image | description: Image. This can contain an image URL or a Wix Media image GUID. - name: id | type: string | description: WixMedia image GUID. This property is written by Wix when an image is uploaded to the Wix Media Manager. - name: url | type: string | description: Image source: Either a Media Manager URL or external URL. - name: height | type: integer | description: Height of the original image. - name: width | type: integer | description: Width of the original image. - name: altText | type: string | description: Image alt text (optional). param name: revision | type: revision | description: Revision number. When updating, include the existing `revision` to prevent conflicting updates. | required: true Return type: UpdateContactResponse - name: contact | type: Contact | description: Updated contact. - name: id | type: string | description: Contact GUID. - name: revision | type: integer | description: Revision number, which increments by 1 each time the contact is updated. To prevent conflicting changes, the existing `revision` must be specified when updating a contact. - name: source | type: ContactSource | description: Details about the contact's source. - name: sourceType | type: ContactSourceType | description: Source type. - enum: OTHER, ADMIN, WIX_APP, IMPORT, THIRD_PARTY, WIX_BOOKINGS, WIX_CHAT, WIX_EMAIL_MARKETING, WIX_EVENTS, WIX_FORMS, WIX_GROUPS, WIX_HOTELS, WIX_MARKET_PLACE, WIX_MUSIC, WIX_RESTAURANTS, WIX_SITE_MEMBERS, WIX_STORES, WIX_CODE, HOPP - name: appId | type: string | description: App GUID, if the contact was created by an app. - name: createdDate | type: string | description: Date and time the contact was created. - name: updatedDate | type: string | description: Date and time the contact was last updated. - name: lastActivity | type: ContactActivity | description: Details about the contact's last action in the site. - name: activityDate | type: string | description: Date and time of the last action. - name: activityType | type: ContactActivityType | description: Contact's last action in the site. - enum: - GENERAL: Visited the site. - CONTACT_CREATED: Became a new contact. - MEMBER_LOGIN: Logged in. - MEMBER_REGISTER: Requested a site membership. - MEMBER_STATUS_CHANGED: Was approved, blocked, or unblocked. - FORM_SUBMITTED: Submitted a form. - INBOX_FORM_SUBMITTED: Started a chat. - INBOX_PAYMENT_REQUEST_PAID: Paid a payment request. - INBOX_MESSAGE_TO_CUSTOMER: Received a message from the site. - INBOX_MESSAGE_FROM_CUSTOMER: Sent a new message to the site. - NEWSLETTER_SUBSCRIPTION_FORM_SUBMITTED: Subscribed to a site newsletter through a form. - NEWSLETTER_SUBSCRIPTION_UNSUBSCRIBE: Unsubscribed from a site newsletter. - ECOM_PURCHASE: Made a purchase. - ECOM_CART_ABANDON: Abandoned a shopping cart. - ECOM_CHECKOUT_BUYER: Checked out shopping cart and submitted buyer info (but didn’t complete the purchase yet). - BOOKINGS_APPOINTMENT: Booked an appointment. - HOTELS_RESERVATION: Made a Wix Hotels reservation. - HOTELS_PURCHASE: Paid for a Wix Hotels reservation. - HOTELS_CONFIRMATION: Confirmed a Wix Hotels reservation. - HOTELS_CANCEL: Canceled a Wix Hotels reservation. - VIDEO_PURCHASE: Purchased a video. - VIDEO_RENT: Rented a video. - CASHIER_BUTTON_PURCHASE: Made a purchase with a pay button. - ARENA_NEW_LEAD: Became a new Wix Marketplace lead. - EVENTS_RSVP: RSVP'd to an event. - INVOICE_PAY: Paid an invoice. - INVOICE_OVERDUE: An invoice is now overdue. - PRICE_QUOTE_ACCEPT: Accepted a price quote. - PRICE_QUOTE_EXPIRE: A price quote has expired. - RESTAURANTS_ORDER: Ordered food with Wix Restaurants. - RESTAURANTS_RESERVATION: Made a Wix Restaurants reservation. - SHOUTOUT_OPEN: Opened an email from the site. - SHOUTOUT_CLICK: Clicked a link in an email from the site. - CONTACT_MERGED: Merged with another contact. - NEWSLETTER_SUBSCRIPTION_SUBSCRIBE: Subscribed to a site newsletter. - NEWSLETTER_SUBSCRIPTION_PENDING: Subscription status to site newsletters is pending confirmation. - NEWSLETTER_SUBSCRIPTION_NOT_SET: Subscription status to site newsletters is not set. - PHONE_SUBSCRIPTION_SUBSCRIBE: Subscribed to phone notifications. - PHONE_SUBSCRIPTION_PENDING: Subscription to phone notificatons is pending confirmation. - PHONE_SUBSCRIPTION_NOT_SET: Subscription to phone notificatons is not set. - PHONE_SUBSCRIPTION_UNSUBSCRIBE: Subscribed to phone notifications. - name: primaryInfo | type: PrimaryContactInfo | description: Contact's primary phone and email. - name: email | type: string | description: Primary email address. This property reflects the email address in `info.emails` where `primary` is `true`. - name: phone | type: string | description: Primary phone number. This property reflects the phone number in `info.phones` where `primary` is `true`. - name: info | type: ContactInfo | description: Contact's details. - name: name | type: ContactName | description: Contact's first and last name. - name: first | type: string | description: Contact's first name. - name: last | type: string | description: Contact's last name. - name: emails | type: ContactEmailsWrapper | description: Contact's email addresses. - name: items | type: array | description: List of up to 50 email addresses. - name: id | type: string | description: Email GUID. - name: tag | type: EmailTag | description: Email type. `UNTAGGED` is shown as "Other" in the Contact List. - enum: UNTAGGED, MAIN, HOME, WORK - name: email | type: string | description: Email address. - name: primary | type: boolean | description: Indicates whether this is the contact's primary email address. When changing `primary` to `true` for an email, the contact's other emails become `false`. Changing the primary email of a contact also affects the subscription status to marketing emails that are decided based on the primary email. - name: phones | type: ContactPhonesWrapper | description: Contact's phone numbers. - name: items | type: array | description: List of up to 50 phone numbers. - name: id | type: string | description: Phone GUID. - name: tag | type: PhoneTag | description: Phone type. `UNTAGGED` is shown as "Other" in the Contact List. - enum: UNTAGGED, MAIN, HOME, MOBILE, WORK, FAX - name: countryCode | type: string | description: [ISO-3166 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code. - name: phone | type: string | description: Phone number. - name: e164Phone | type: string | description: [ITU E.164-formatted](https://www.itu.int/rec/T-REC-E.164/) phone number. Automatically generated using `phone` and `countryCode`, pending both values are valid. - name: primary | type: boolean | description: Indicates whether this is the contact's primary phone number. When changing `primary` to `true` for a phone, the contact's `primary` field for other phones becomes `false`. Changing the primary phone number also affects the subscription status to SMS messages that are decided based on the primary phone. - name: addresses | type: ContactAddressesWrapper | description: Contact's street addresses. - name: items | type: array | description: List of up to 50 addresses. - name: id | type: string | description: Street address GUID. - name: tag | type: AddressTag | description: Address type. `UNTAGGED` is shown as "Other" in the Contact List. - enum: UNTAGGED, HOME, WORK, BILLING, SHIPPING - name: address | type: Address | description: Street address. - ONE-OF: - name: streetAddress | type: StreetAddress | description: Street address object, with number and name in separate fields. - name: number | type: string | description: Street number. - name: name | type: string | description: Street name. - name: addressLine | type: string | description: Main address line, usually street and number, as free text. - name: country | type: string | description: 2-letter country code in an [ISO-3166 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format. - name: subdivision | type: string | description: Code for a subdivision (such as state, prefecture, or province) in an [ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2) format. - name: city | type: string | description: City name. - name: postalCode | type: string | description: Postal or zip code. - name: addressLine2 | type: string | description: Free text providing more detailed address information, such as apartment, suite, or floor. - name: company | type: string | description: Contact's company name. - name: jobTitle | type: string | description: Contact's job title. - name: birthdate | type: string | description: Birth date in `YYYY-MM-DD` format. For example, `2020-03-15`. - name: locale | type: string | description: Locale in [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. Typically, this is a lowercase 2-letter language code, followed by a hyphen, followed by an uppercase 2-letter country code. For example, `en-US` for U.S. English, and `de-DE` for Germany German. - name: labelKeys | type: LabelsWrapper | description: List of contact's labels. Labels are used to organize contacts. Labels can be added and removed using Label Contact and Unlabel Contact, respectively. To view or manage contact labels, use the Labels API. - name: items | type: array | description: List of contact label keys. Contact labels help categorize contacts. Label keys must exist to be added to the contact. Contact labels can be created or retrieved with Find or Create Label or List Labels. - name: extendedFields | type: ExtendedFieldsWrapper | description: Additional custom fields. Empty fields are not returned. - name: items | type: Map | description: Contact's extended fields, where each key is the field key, and each value is the field's value for the contact. To view and manage extended fields, use the Extended Fields API. - ONE-OF: - name: nullValue | type: | description: - name: numberValue | type: number | description: - name: stringValue | type: string | description: - name: boolValue | type: boolean | description: - name: structValue | type: object | description: - name: listValue | type: ListValue | description: - name: values | type: array | description: - name: picture | type: ContactPicture | description: Contact's profile picture. - name: image | type: Image | description: Image. This can contain an image URL or a Wix Media image GUID. - name: id | type: string | description: WixMedia image GUID. This property is written by Wix when an image is uploaded to the Wix Media Manager. - name: url | type: string | description: Image source: Either a Media Manager URL or external URL. - name: height | type: integer | description: Height of the original image. - name: width | type: integer | description: Width of the original image. - name: altText | type: string | description: Image alt text (optional). - name: urlExpirationDate | type: string | description: Image URL expiration date (optional). - name: primaryEmail | type: PrimaryEmail | description: Contact's primary email details. - name: email | type: string | description: Primary email address. This field reflects the email address in `info.emails` where `primary` is `true`. - name: subscriptionStatus | type: SubscriptionStatus | description: Indicates the recipient's opt-in or opt-out status for marketing emails. Default: `NOT_SET` - enum: - NO_SUBSCRIPTION_STATUS: No status exists. - NOT_SET: No status specified. - PENDING: Subscription confirmation was requested, but recipient hasn't confirmed yet. - SUBSCRIBED: Recipient has opted in to marketing emails or SMS messages. - UNSUBSCRIBED: Recipient has opted out of marketing emails or SMS messages. - name: deliverabilityStatus | type: EmailDeliverabilityStatus | description: Indicates last reported status of sent emails. Default: `NOT_SET` - enum: - NOT_SET: No status reported. - VALID: Emails are being successfully delivered. - BOUNCED: The last email to the recipient bounced or was rejected. - SPAM_COMPLAINT: Recipient registered a spam complaint with their email provider. - INACTIVE: Multiple emails have been delivered without any kind of engagement from the recipient. - name: primaryPhone | type: PrimaryPhone | description: Contact's primary phone details. - name: countryCode | type: string | description: Country code of the primary phone number in [ISO-3166 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format. - name: e164Phone | type: string | description: Phone number in [ITU E.164](https://www.itu.int/rec/T-REC-E.164/) format. Automatically generated using `phone` and `countryCode` when both values are valid. - name: formattedPhone | type: string | description: Formatted phone. Automatically generated using `phone` and `countryCode`. - name: subscriptionStatus | type: SubscriptionStatus | description: Indicates the recipient's opt-in or opt-out status for SMS messages. Default: - `NOT_SET` when the phone is a valid E164 phone. - `NO_SUBSCRIPTION_STATUS` when the phone is not a valid E164 phone. - name: phone | type: string | description: Primary phone number. This field reflects the phone number in `info.phones` where `primary` is `true`. Possible Errors: HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: INVALID_EXTENDED_FIELD_VALUE | Description: Contact can't have extended fields values that are invalid or don't match the field type. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: CANNOT_HAVE_MULTIPLE_PRIMARY_INFO | Description: Contact can't have more than one primary email or phone number. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: INSUFFICIENT_UPDATE_CONTACT_DATA | Description: Not enough data passed to update contact. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: INSUFFICIENT_CONTACT_DATA | Description: Contact must have a name, phone number, or email address. HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: CONTACT_NOT_FOUND | Description: Contact not found. HTTP Code: 409 | Status Code: ALREADY_EXISTS | Application Code: CONTACT_ALREADY_CHANGED | Description: Passed contact revision is outdated. Retrieve the latest version before applying updates. HTTP Code: 409 | Status Code: ALREADY_EXISTS | Application Code: DUPLICATE_CONTACT_EXISTS | Description: A contact with the same primary email or primary phone number already exists. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: CANNOT_UPDATE_MEMBER_EMAIL | Description: The primary email of a contact that is a member can't be updated. Update the member login email to change the contact primary email. ``` ### Examples ### Update Contact Updates only the given fields (`company` and `addresses`). ```curl curl -X PATCH \ 'https://www.wixapis.com/contacts/v4/contacts/8046df3c-7575-4098-a5ab-c91ad8f33c47' \ -H 'Authorization: ' \ -H 'Content-Type: application/json' \ -d '{ "info": { "name": { "first": "Ignored", "last": "Changed" }, "company" : "Wix", }, "revision": 5, "allowDuplicates": false }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.contacts.ContactsServiceV4.updateContact(contactId, info, revision, options) Description: 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 GUID and contact GUID are distinct identifiers. Make sure to specify the contact GUID when calling Update Contact. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: contactId, revision, info Method parameters: param name: contactId | type: string | description: GUID of the contact to update. | required: true param name: info | type: ContactInfo | required: true - name: name | type: ContactName | description: Contact's first and last name. - name: first | type: string | description: Contact's first name. - name: last | type: string | description: Contact's last name. - name: emails | type: ContactEmailsWrapper | description: Contact's email addresses. - name: items | type: array | description: List of up to 50 email addresses. - name: tag | type: EmailTag | description: Email type. `UNTAGGED` is shown as "Other" in the Contact List. - enum: UNTAGGED, MAIN, HOME, WORK - name: email | type: string | description: Email address. - name: primary | type: boolean | description: Indicates whether this is the contact's primary email address. When changing `primary` to `true` for an email, the contact's other emails become `false`. Changing the primary email of a contact also affects the subscription status to marketing emails that are decided based on the primary email. - name: phones | type: ContactPhonesWrapper | description: Contact's phone numbers. - name: items | type: array | description: List of up to 50 phone numbers. - name: tag | type: PhoneTag | description: Phone type. `UNTAGGED` is shown as "Other" in the Contact List. - enum: UNTAGGED, MAIN, HOME, MOBILE, WORK, FAX - name: countryCode | type: string | description: [ISO-3166 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code. - name: phone | type: string | description: Phone number. - name: primary | type: boolean | description: Indicates whether this is the contact's primary phone number. When changing `primary` to `true` for a phone, the contact's `primary` field for other phones becomes `false`. Changing the primary phone number also affects the subscription status to SMS messages that are decided based on the primary phone. - name: addresses | type: ContactAddressesWrapper | description: Contact's street addresses. - name: items | type: array | description: List of up to 50 addresses. - name: tag | type: AddressTag | description: Address type. `UNTAGGED` is shown as "Other" in the Contact List. - enum: UNTAGGED, HOME, WORK, BILLING, SHIPPING - name: address | type: Address | description: Street address. - name: city | type: string | description: none - name: subdivision | type: string | description: none - name: country | type: string | description: none - name: postalCode | type: string | description: none - name: addressLine1 | type: string | description: none - name: addressLine2 | type: string | description: none - name: company | type: string | description: Contact's company name. - name: jobTitle | type: string | description: Contact's job title. - name: birthdate | type: string | description: Birth date in `YYYY-MM-DD` format. For example, `2020-03-15`. - name: locale | type: string | description: Locale in [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. Typically, this is a lowercase 2-letter language code, followed by a hyphen, followed by an uppercase 2-letter country code. For example, `en-US` for U.S. English, and `de-DE` for Germany German. - name: labelKeys | type: LabelsWrapper | description: List of contact's labels. Labels are used to organize contacts. Labels can be added and removed using Label Contact and Unlabel Contact, respectively. To view or manage contact labels, use the Labels API. - name: items | type: array | description: List of contact label keys. Contact labels help categorize contacts. Label keys must exist to be added to the contact. Contact labels can be created or retrieved with Find or Create Label or List Labels. - name: extendedFields | type: ExtendedFieldsWrapper | description: Additional custom fields. Empty fields are not returned. - name: items | type: Map | description: Contact's extended fields, where each key is the field key, and each value is the field's value for the contact. To view and manage extended fields, use the Extended Fields API. - ONE-OF: - name: nullValue | type: | description: - name: numberValue | type: number | description: - name: stringValue | type: string | description: - name: boolValue | type: boolean | description: - name: structValue | type: object | description: - name: listValue | type: ListValue | description: - name: values | type: array | description: - name: picture | type: ContactPicture | description: Contact's profile picture. - name: image | type: string | description: Image. This can contain an image URL or a Wix Media image GUID. param name: options | type: UpdateContactOptions none - name: allowDuplicates | type: boolean | description: Controls whether the call will succeed if the new contact information contains an email or a phone number already used by another contact. If set to `true`, the call will succeed even if an email address or phone number is used by another contact. If set to `false`, the call will fail if the given email address is used by another contact or, if the email address is not given and the given phone number is used by another contact. Default: `false` param name: revision | type: integer | description: Revision number. When updating, include the existing `revision` to prevent conflicting updates. | required: true Return type: PROMISE - name: contact | type: Contact | description: Updated contact. - name: _id | type: string | description: Contact GUID. - name: revision | type: integer | description: Revision number, which increments by 1 each time the contact is updated. To prevent conflicting changes, the existing `revision` must be specified when updating a contact. - name: source | type: ContactSource | description: Details about the contact's source. - name: sourceType | type: ContactSourceType | description: Source type. - enum: OTHER, ADMIN, WIX_APP, IMPORT, THIRD_PARTY, WIX_BOOKINGS, WIX_CHAT, WIX_EMAIL_MARKETING, WIX_EVENTS, WIX_FORMS, WIX_GROUPS, WIX_HOTELS, WIX_MARKET_PLACE, WIX_MUSIC, WIX_RESTAURANTS, WIX_SITE_MEMBERS, WIX_STORES, WIX_CODE, HOPP - name: appId | type: string | description: App GUID, if the contact was created by an app. - name: _createdDate | type: Date | description: Date and time the contact was created. - name: _updatedDate | type: Date | description: Date and time the contact was last updated. - name: lastActivity | type: ContactActivity | description: Details about the contact's last action in the site. - name: activityDate | type: Date | description: Date and time of the last action. - name: activityType | type: ContactActivityType | description: Contact's last action in the site. - enum: - GENERAL: Visited the site. - CONTACT_CREATED: Became a new contact. - MEMBER_LOGIN: Logged in. - MEMBER_REGISTER: Requested a site membership. - MEMBER_STATUS_CHANGED: Was approved, blocked, or unblocked. - FORM_SUBMITTED: Submitted a form. - INBOX_FORM_SUBMITTED: Started a chat. - INBOX_PAYMENT_REQUEST_PAID: Paid a payment request. - INBOX_MESSAGE_TO_CUSTOMER: Received a message from the site. - INBOX_MESSAGE_FROM_CUSTOMER: Sent a new message to the site. - NEWSLETTER_SUBSCRIPTION_FORM_SUBMITTED: Subscribed to a site newsletter through a form. - NEWSLETTER_SUBSCRIPTION_UNSUBSCRIBE: Unsubscribed from a site newsletter. - ECOM_PURCHASE: Made a purchase. - ECOM_CART_ABANDON: Abandoned a shopping cart. - ECOM_CHECKOUT_BUYER: Checked out shopping cart and submitted buyer info (but didn’t complete the purchase yet). - BOOKINGS_APPOINTMENT: Booked an appointment. - HOTELS_RESERVATION: Made a Wix Hotels reservation. - HOTELS_PURCHASE: Paid for a Wix Hotels reservation. - HOTELS_CONFIRMATION: Confirmed a Wix Hotels reservation. - HOTELS_CANCEL: Canceled a Wix Hotels reservation. - VIDEO_PURCHASE: Purchased a video. - VIDEO_RENT: Rented a video. - CASHIER_BUTTON_PURCHASE: Made a purchase with a pay button. - ARENA_NEW_LEAD: Became a new Wix Marketplace lead. - EVENTS_RSVP: RSVP'd to an event. - INVOICE_PAY: Paid an invoice. - INVOICE_OVERDUE: An invoice is now overdue. - PRICE_QUOTE_ACCEPT: Accepted a price quote. - PRICE_QUOTE_EXPIRE: A price quote has expired. - RESTAURANTS_ORDER: Ordered food with Wix Restaurants. - RESTAURANTS_RESERVATION: Made a Wix Restaurants reservation. - SHOUTOUT_OPEN: Opened an email from the site. - SHOUTOUT_CLICK: Clicked a link in an email from the site. - CONTACT_MERGED: Merged with another contact. - NEWSLETTER_SUBSCRIPTION_SUBSCRIBE: Subscribed to a site newsletter. - NEWSLETTER_SUBSCRIPTION_PENDING: Subscription status to site newsletters is pending confirmation. - NEWSLETTER_SUBSCRIPTION_NOT_SET: Subscription status to site newsletters is not set. - PHONE_SUBSCRIPTION_SUBSCRIBE: Subscribed to phone notifications. - PHONE_SUBSCRIPTION_PENDING: Subscription to phone notificatons is pending confirmation. - PHONE_SUBSCRIPTION_NOT_SET: Subscription to phone notificatons is not set. - PHONE_SUBSCRIPTION_UNSUBSCRIBE: Subscribed to phone notifications. - name: primaryInfo | type: PrimaryContactInfo | description: Contact's primary phone and email. - name: email | type: string | description: Primary email address. This property reflects the email address in `info.emails` where `primary` is `true`. - name: phone | type: string | description: Primary phone number. This property reflects the phone number in `info.phones` where `primary` is `true`. - name: info | type: ContactInfo | description: Contact's details. - name: name | type: ContactName | description: Contact's first and last name. - name: first | type: string | description: Contact's first name. - name: last | type: string | description: Contact's last name. - name: emails | type: ContactEmailsWrapper | description: Contact's email addresses. - name: items | type: array | description: List of up to 50 email addresses. - name: _id | type: string | description: Email GUID. - name: tag | type: EmailTag | description: Email type. `UNTAGGED` is shown as "Other" in the Contact List. - enum: UNTAGGED, MAIN, HOME, WORK - name: email | type: string | description: Email address. - name: primary | type: boolean | description: Indicates whether this is the contact's primary email address. When changing `primary` to `true` for an email, the contact's other emails become `false`. Changing the primary email of a contact also affects the subscription status to marketing emails that are decided based on the primary email. - name: phones | type: ContactPhonesWrapper | description: Contact's phone numbers. - name: items | type: array | description: List of up to 50 phone numbers. - name: _id | type: string | description: Phone GUID. - name: tag | type: PhoneTag | description: Phone type. `UNTAGGED` is shown as "Other" in the Contact List. - enum: UNTAGGED, MAIN, HOME, MOBILE, WORK, FAX - name: countryCode | type: string | description: [ISO-3166 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country code. - name: phone | type: string | description: Phone number. - name: e164Phone | type: string | description: [ITU E.164-formatted](https://www.itu.int/rec/T-REC-E.164/) phone number. Automatically generated using `phone` and `countryCode`, pending both values are valid. - name: primary | type: boolean | description: Indicates whether this is the contact's primary phone number. When changing `primary` to `true` for a phone, the contact's `primary` field for other phones becomes `false`. Changing the primary phone number also affects the subscription status to SMS messages that are decided based on the primary phone. - name: addresses | type: ContactAddressesWrapper | description: Contact's street addresses. - name: items | type: array | description: List of up to 50 addresses. - name: _id | type: string | description: Street address GUID. - name: tag | type: AddressTag | description: Address type. `UNTAGGED` is shown as "Other" in the Contact List. - enum: UNTAGGED, HOME, WORK, BILLING, SHIPPING - name: address | type: Address | description: Street address. - name: city | type: string | description: none - name: subdivision | type: string | description: none - name: country | type: string | description: none - name: postalCode | type: string | description: none - name: addressLine1 | type: string | description: none - name: addressLine2 | type: string | description: none - name: company | type: string | description: Contact's company name. - name: jobTitle | type: string | description: Contact's job title. - name: birthdate | type: string | description: Birth date in `YYYY-MM-DD` format. For example, `2020-03-15`. - name: locale | type: string | description: Locale in [IETF BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. Typically, this is a lowercase 2-letter language code, followed by a hyphen, followed by an uppercase 2-letter country code. For example, `en-US` for U.S. English, and `de-DE` for Germany German. - name: labelKeys | type: LabelsWrapper | description: List of contact's labels. Labels are used to organize contacts. Labels can be added and removed using Label Contact and Unlabel Contact, respectively. To view or manage contact labels, use the Labels API. - name: items | type: array | description: List of contact label keys. Contact labels help categorize contacts. Label keys must exist to be added to the contact. Contact labels can be created or retrieved with Find or Create Label or List Labels. - name: extendedFields | type: ExtendedFieldsWrapper | description: Additional custom fields. Empty fields are not returned. - name: items | type: Map | description: Contact's extended fields, where each key is the field key, and each value is the field's value for the contact. To view and manage extended fields, use the Extended Fields API. - ONE-OF: - name: nullValue | type: | description: - name: numberValue | type: number | description: - name: stringValue | type: string | description: - name: boolValue | type: boolean | description: - name: structValue | type: object | description: - name: listValue | type: ListValue | description: - name: values | type: array | description: - name: picture | type: ContactPicture | description: Contact's profile picture. - name: image | type: string | description: Image. This can contain an image URL or a Wix Media image GUID. - name: primaryEmail | type: PrimaryEmail | description: Contact's primary email details. - name: email | type: string | description: Primary email address. This field reflects the email address in `info.emails` where `primary` is `true`. - name: subscriptionStatus | type: SubscriptionStatus | description: Indicates the recipient's opt-in or opt-out status for marketing emails. Default: `NOT_SET` - enum: - NO_SUBSCRIPTION_STATUS: No status exists. - NOT_SET: No status specified. - PENDING: Subscription confirmation was requested, but recipient hasn't confirmed yet. - SUBSCRIBED: Recipient has opted in to marketing emails or SMS messages. - UNSUBSCRIBED: Recipient has opted out of marketing emails or SMS messages. - name: deliverabilityStatus | type: EmailDeliverabilityStatus | description: Indicates last reported status of sent emails. Default: `NOT_SET` - enum: - NOT_SET: No status reported. - VALID: Emails are being successfully delivered. - BOUNCED: The last email to the recipient bounced or was rejected. - SPAM_COMPLAINT: Recipient registered a spam complaint with their email provider. - INACTIVE: Multiple emails have been delivered without any kind of engagement from the recipient. - name: primaryPhone | type: PrimaryPhone | description: Contact's primary phone details. - name: countryCode | type: string | description: Country code of the primary phone number in [ISO-3166 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format. - name: e164Phone | type: string | description: Phone number in [ITU E.164](https://www.itu.int/rec/T-REC-E.164/) format. Automatically generated using `phone` and `countryCode` when both values are valid. - name: formattedPhone | type: string | description: Formatted phone. Automatically generated using `phone` and `countryCode`. - name: subscriptionStatus | type: SubscriptionStatus | description: Indicates the recipient's opt-in or opt-out status for SMS messages. Default: - `NOT_SET` when the phone is a valid E164 phone. - `NO_SUBSCRIPTION_STATUS` when the phone is not a valid E164 phone. - name: phone | type: string | description: Primary phone number. This field reflects the phone number in `info.phones` where `primary` is `true`. Possible Errors: HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: INVALID_EXTENDED_FIELD_VALUE | Description: Contact can't have extended fields values that are invalid or don't match the field type. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: CANNOT_HAVE_MULTIPLE_PRIMARY_INFO | Description: Contact can't have more than one primary email or phone number. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: INSUFFICIENT_UPDATE_CONTACT_DATA | Description: Not enough data passed to update contact. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: INSUFFICIENT_CONTACT_DATA | Description: Contact must have a name, phone number, or email address. HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: CONTACT_NOT_FOUND | Description: Contact not found. HTTP Code: 409 | Status Code: ALREADY_EXISTS | Application Code: CONTACT_ALREADY_CHANGED | Description: Passed contact revision is outdated. Retrieve the latest version before applying updates. HTTP Code: 409 | Status Code: ALREADY_EXISTS | Application Code: DUPLICATE_CONTACT_EXISTS | Description: A contact with the same primary email or primary phone number already exists. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: CANNOT_UPDATE_MEMBER_EMAIL | Description: The primary email of a contact that is a member can't be updated. Update the member login email to change the contact primary email. ``` ### Examples ### Force update a contact (with $w) The page code passes a contact ID with updated contact information to the backend `overwriteContactInfo()` function. The `overwriteContactInfo()` function retrieves the contact, extracts the revision number, then passes it to `contacts.updateContact()`. This allows the contact to be updated without needing to specify the revision. >**Note:** This code example always retrieves the latest revision before updating a contact. ```javascript /************************************* * Backend code - contacts.web.js/ts * ************************************/ import { Permissions, webMethod } from '@wix/web-methods'; import { contacts } from '@wix/crm'; import { auth } from '@wix/essentials'; export const overwriteContactInfo = webMethod(Permissions.Anyone, async (contactId, updatedContactInfo) => { try { // Retrieve the contact const elevateGetContact = auth.elevate(contacts.getContact); const contact = await elevateGetContact(contactId); // Extract revision number const revisionNumber = contact.revision; // Update the contact const elevateUpdateContact = auth.elevate(contacts.updateContact); const updatedContact = await elevateUpdateContact(contactId, updatedContactInfo, revisionNumber); return updatedContact; } catch (error) { console.log(error); // Handle the error } }); /************* * Page code * *************/ import { overwriteContactInfo } from 'backend/contacts.web'; $w.onReady(async function () { const contactId = "2712ae1d-3f64-46c2-ac3a-94a6c2e29847"; const updatedContactInfo = { name: { first: "John", last: "Mitchell" } }; async function updateContactName(){ try { const updatedContact = await overwriteContactInfo(contactId, updatedContactInfo); return updatedContact; } catch(error){ console.log(error); // Handle the error } } const result = await updateContactName(); const first = result.contact.info.name.first; const last = result.contact.info.name.last; console.log(`Updated contact name: ${first} ${last}`); }); ``` ### Update a contact by adding a phone number (with elevated permissions) ```javascript import { contacts } from '@wix/crm'; import { auth } from '@wix/essentials'; /* 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" * } * ] * } * } */ const elevatedUpdateContact = auth.elevate(contacts.updateContact); export async function myUpdateContactFunction(contactId, info, revision, options) { try { const updatedContact = await elevatedUpdateContact(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" * } * } */ ``` ### Update a contact by adding a phone number ```javascript import { contacts } from '@wix/crm'; /* 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" * } * } */ ``` ### updateContact (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { contacts } from '@wix/crm'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { contacts }, // Include the auth strategy and host as relevant }); async function updateContact(contactId,info,revision,options) { const response = await myWixClient.contacts.updateContact(contactId,info,revision,options); }; ``` ---