> 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 # UpdateBusinessContact # Package: siteProperties # Namespace: SitePropertiesV4 # Method link: https://dev.wix.com/docs/api-reference/business-management/site-properties/properties/update-business-contact.md ## Permission Scopes: Manage Business Contact: SCOPE.DC-SITEPROP.MANAGE-BUSINESS-CONTACT ## Introduction Updates a site's business contact information. --- ## REST API ### Schema ``` Method: updateBusinessContact Description: Updates a site's business contact information. URL: https://www.wixapis.com/site-properties/v4/properties/business-contact Method: POST Method parameters: param name: businessContact | type: BusinessContactData - name: email | type: string | description: Publicly-available business email address. - name: phone | type: string | description: Publicly-available business phone number. - name: fax | type: string | description: Publicly-available business fax number. - name: address | type: Address | description: Publicly-available business address. - name: street | type: string | description: Street name. - name: city | type: string | description: City name. - name: country | type: string | description: Two-letter country code in an [ISO-3166 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format. - name: state | type: string | description: State. - name: zip | type: string | description: Zip or postal code. - name: hint | type: AddressHint | description: Extra information to be displayed in the address. - name: text | type: string | description: Extra text displayed next to, or instead of, the actual address. - name: placement | type: PlacementType | description: Where the extra text should be displayed. - enum: BEFORE, AFTER, REPLACE - name: isPhysical | type: boolean | description: Whether this address represents a physical location. - name: googleFormattedAddress | type: string | description: Google-formatted version of this address. - name: streetNumber | type: string | description: Street number. - name: apartmentNumber | type: string | description: Apartment number. - name: coordinates | type: GeoCoordinates | description: Geographic coordinates of location. - name: latitude | type: number | description: Latitude of the location. Must be between -90 and 90. - name: longitude | type: number | description: Longitude of the location. Must be between -180 and 180. param name: fields | type: fields | description: The properties of `businessContact` to be updated. Properties not explicitly specified here are ignored. Properties included here but excluded from `businessContact` are cleared. Return type: UpdateBusinessContactResponse EMPTY-OBJECT {} Possible Errors: HTTP Code: 401 | Status Code: UNAUTHENTICATED | Application Code: META_SITE_NOT_FOUND | Description: Couldn't find the site. HTTP Code: 403 | Status Code: PERMISSION_DENIED | Application Code: PERMISSION_DENIED | Description: The [identity](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities.md) used to call the method doesn't have the required permissions. ``` ### Examples ### Update site business contact ```curl curl -X POST \ 'https://www.wixapis.com/site-properties/v4/properties/business-contact' -H 'Content-Type: application/json' \ -H 'Authorization: ' \ --data-binary '{ "businessContact": { "email": "useremail@domain.com", "phone": "+18008000000", "fax": "12345678", "address": { "street": "", "city": "New York", "country": "US", "state": "NY", "zip": "10036", "isPhysical": true, "googleFormattedAddress": "Times Square, Manhattan, NY, USA", "streetNumber": "", "apartmentNumber": "", "coordinates": { "latitude": 40.7579747, "longitude": -73.9855426 } } }, "fields": { "paths":["phone","fax","email","address", "businessSchedule"] } }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.siteProperties.SitePropertiesV4.updateBusinessContact(businessContact, options) Description: Updates a site's business contact information. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: businessContact Method parameters: param name: businessContact | type: BusinessContactData | required: true - name: email | type: string | description: Publicly-available business email address. - name: phone | type: string | description: Publicly-available business phone number. - name: fax | type: string | description: Publicly-available business fax number. - name: address | type: Address | description: Publicly-available business address. - name: street | type: string | description: Street name. - name: city | type: string | description: City name. - name: country | type: string | description: Two-letter country code in an [ISO-3166 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format. - name: state | type: string | description: State. - name: zip | type: string | description: Zip or postal code. - name: hint | type: AddressHint | description: Extra information to be displayed in the address. - name: text | type: string | description: Extra text displayed next to, or instead of, the actual address. - name: placement | type: PlacementType | description: Where the extra text should be displayed. - enum: BEFORE, AFTER, REPLACE - name: isPhysical | type: boolean | description: Whether this address represents a physical location. - name: googleFormattedAddress | type: string | description: Google-formatted version of this address. - name: streetNumber | type: string | description: Street number. - name: apartmentNumber | type: string | description: Apartment number. - name: coordinates | type: GeoCoordinates | description: Geographic coordinates of location. - name: latitude | type: number | description: Latitude of the location. Must be between -90 and 90. - name: longitude | type: number | description: Longitude of the location. Must be between -180 and 180. param name: options | type: UpdateBusinessContactOptions none - name: fields | type: array | description: The properties of `businessContact` to be updated. Properties not explicitly specified here are ignored. Properties included here but excluded from `businessContact` are cleared. Return type: PROMISE EMPTY-OBJECT {} Possible Errors: HTTP Code: 401 | Status Code: UNAUTHENTICATED | Application Code: META_SITE_NOT_FOUND | Description: Couldn't find the site. HTTP Code: 403 | Status Code: PERMISSION_DENIED | Application Code: PERMISSION_DENIED | Description: The [identity](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities.md) used to call the method doesn't have the required permissions. ``` ### Examples ### Update Business Contact @description: ```javascript import { siteProperties } from '@wix/business-tools'; /* Sample businessContact value: * { * address: { * apartmentNumber: '', * city: 'New York', * coordinates: { * latitude: 40.7128, * longitude: -74.0060 * }, * country: 'US', * googleFormattedAddress: '123 Broadway, New York, NY 10001', * hint: { * placement: 'BEFORE', * text: 'On the corner - front entrance on 5th Avenue' * }, * isPhysical: true, * state: 'NY', * street: 'Broadway', * streetNumber: '123', * zip: '10001' * }, * email: 'mainaddress@example.com', * fax: '011-1-212-555-6789', * phone: '212-555-1234' * } * * Sample fields value: ['address', 'email', 'fax', 'phone'] */ export async function myUpdateBusinessContactFunction(businessContact, fields) { try { await siteProperties.updateBusinessContact(businessContact, fields); console.log('Successfully updated business contact'); return true; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to void */ ``` ### updateBusinessContact() for only specific fields (with $w) This code is an example of a webpage where the user updates the business' contact details. If they don't enter text for a specific field, it won't overwrite. Access to this page would be given only to managers. ```javascript /**************************************************** * Backend code - update-business-contact.web.js/ts * ***************************************************/ import { Permissions, webMethod } from '@wix/web-methods'; import { siteProperties } from '@wix/business-tools'; import { auth } from '@wix/essentials'; export const contactDetailsUpdate = webMethod(Permissions.Anyone, async (businessContact, fields) => { try { const elevatedUpdateBusinessContact = auth.elevate(siteProperties.updateBusinessContact); await elevatedUpdateBusinessContact(businessContact, fields); console.log('Success! Contact Details Updated'); return true; } catch (error) { console.error(error); throw new Error(error); } }); /************* * Page code * ************/ import { contactDetailsUpdate } from 'backend/update-business-contact.web'; $w.onReady(() => { $w('#submit').onClick(async () => { const paramDetails = getParamDetails(); if (!paramDetails.checkedFields.length) { $w('#changeAFieldsMsg').show(); setTimeout(() => { $w('#changeAFieldsMsg').hide(); }, 10000); } else { const isUpdated = await contactDetailsUpdate(paramDetails.updateDetails, paramDetails.checkedFields); if (isUpdated) { console.log('Business Contact successfully updated'); $w('#successfulUpdateMsg').show(); setTimeout(() => { $w('#successfulUpdateMsg').hide(); }, 10000); } } }); }); function getParamDetails() { const checkedFields = []; const updateDetails = {} if ($w('#address').value.length) { checkedFields.push('address'); updateDetails.address = $w('#address').value; } if ($w('#email').value.length) { checkedFields.push('email'); updateDetails.email = $w('#email').value; } if ($w('#fax').value.length) { checkedFields.push('fax'); updateDetails.fax = $w('#fax').value; } if ($w('#phone').value.length) { checkedFields.push('phone'); updateDetails.phone = $w('#phone').value; } return {updateDetails, checkedFields}; } ``` ### Update email of business contact (with elevated permissions) @description: ```javascript import { siteProperties } from '@wix/business-tools'; import { auth } from '@wix/essentials'; /* Sample businessContact value: * { * email: 'mainaddress@example.com' * } * * Sample fields value: ['email'] */ export async function myUpdateBusinessContactFunction(businessContact, fields) { try { const elevatedUpdateBusinessContact = auth.elevate(siteProperties.updateBusinessContact); await elevatedUpdateBusinessContact(businessContact, fields); console.log('Successfully updated business contact'); return true; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to void */ ``` ### Update email of business contact @description: ```javascript import { siteProperties } from '@wix/business-tools'; /* Sample businessContact value: * { * email: 'mainaddress@example.com' * } * * Sample fields value: ['email'] */ export async function myUpdateBusinessContactFunction(businessContact, fields) { try { await siteProperties.updateBusinessContact(businessContact, fields); console.log('Successfully updated business contact'); return true; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to void */ ``` ### Update Business Contact (with elevated permissions) @description: ```javascript import { siteProperties } from '@wix/business-tools'; import { auth } from '@wix/essentials'; /* Sample businessContact value: * { * address: { * apartmentNumber: '', * city: 'New York', * coordinates: { * latitude: 40.7128, * longitude: -74.0060 * }, * country: 'US', * googleFormattedAddress: '123 Broadway, New York, NY 10001', * hint: { * placement: 'BEFORE', * text: 'On the corner - front entrance on 5th Avenue' * }, * isPhysical: true, * state: 'NY', * street: 'Broadway', * streetNumber: '123', * zip: '10001' * }, * email: 'mainaddress@example.com', * fax: '011-1-212-555-6789', * phone: '212-555-1234' * } * * Sample fields value: ['address', 'email', 'fax', 'phone'] */ export async function myUpdateBusinessContactFunction(businessContact, fields) { try { const elevatedUpdateBusinessContact = auth.elevate(siteProperties.updateBusinessContact); await elevatedUpdateBusinessContact(businessContact, fields); console.log('Successfully updated business contact'); return true; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to void */ ``` ### updateBusinessContact (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 { siteProperties } from '@wix/business-tools'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { siteProperties }, // Include the auth strategy and host as relevant }); async function updateBusinessContact(businessContact,options) { const response = await myWixClient.siteProperties.updateBusinessContact(businessContact,options); }; ``` ---