> 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

# UpsertContactTaxDetails

# Package: tax

# Namespace: ContactTaxDetailsService

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/tax/contact-tax-details/upsert-contact-tax-details.md

## Permission Scopes:
Manage Orders: SCOPE.DC-STORES.MANAGE-ORDERS

## Introduction

Creates or updates a contact's tax details.

If tax details already exist for the contact specified in `id`, they're updated. Otherwise, new tax details are created. The request must include `id`, the contact ID, and `taxExemptGroupId`.

To create or update tax details for multiple contacts in a single API call, call [Bulk Upsert Contact Tax Details](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/tax/contact-tax-details/bulk-upsert-contact-tax-details.md).

---

## REST API

### Schema

```
 Method: upsertContactTaxDetails
 Description: Creates or updates a contact's tax details.  If tax details already exist for the contact specified in `id`, they're updated. Otherwise, new tax details are created. The request must include `id`, the contact GUID, and `taxExemptGroupId`.  To create or update tax details for multiple contacts in a single API call, call [Bulk Upsert Contact Tax Details](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/tax/contact-tax-details/bulk-upsert-contact-tax-details.md).
 URL: https://www.wixapis.com/billing/v1/contact-tax-details
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  contactTaxDetails, contactTaxDetails.id, contactTaxDetails.taxExemptGroupId
 Method parameters: 
   param name: contactTaxDetails | type: ContactTaxDetails | description: Contact tax details hold the tax-related information for a single contact, keyed by the contact's GUID. Their main purpose is to associate a contact with a tax exempt group, so that the contact receives the group's tax exemption automatically at checkout.  Each contact's tax details map the contact to at most one tax exempt group. During tax calculation, the buyer's contact GUID resolves their tax details, and if `taxExemptGroupId` is set, the matching exemption is applied and reported as an exempt amount in the tax breakdown.  Contacts are typically added to a group by a site owner in the dashboard, or by a VAT-validation app, such as Exemptify, that verifies a customer's VAT GUID at checkout and then associates the contact with the relevant exempt group. Once associated, later checkouts by the same contact are exempt without re-entering the VAT GUID. | required: true 
        - name: id | type: string | description: Contact GUID. Also serves as the GUID of the contact tax details, since each contact has a single set of tax details. | required: true | validation: format GUID
        - name: taxExemptGroupId | type: string | description: GUID of the tax exempt group the contact is associated with. Setting this value makes the contact eligible for the group's tax exemption at checkout. | required: true | validation: format GUID
        - name: contactDetails | type: ContactDetails | description: The contact's details, such as name, email, and VAT GUID.  Returned only when `CONTACT_DETAILS` is passed to the `fields` array in the request.  
        - name: extendedFields | type: ExtendedFields | description: Custom field data for the contact tax details.  [Extended fields](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/schema-plugins/about-schema-plugin-extensions.md) must be configured in the app dashboard before they can be accessed with API calls.  
           - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured.  You can only access fields for which you have the appropriate permissions.  Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).  | validation: format map
        - name: tags | type: Tags | description: Tags associated with the contact tax details.  
           - name: privateTags | type: TagList | description: Tags that require an additional permission in order to access them, normally not given to site members or visitors.  
              - name: tagIds | type: array<string> | description: List of tag GUIDs.  | validation: maxItems 100, maxLength 5
           - name: publicTags | type: TagList | description: Tags that are exposed to anyone who has access to the labeled entity itself, including site members and visitors.  
   param name: fields | type: array<fields> | description: Additional fields to return in the response.  Supported values: `CONTACT_DETAILS`  | validation: maxItems 10
                 - enum:
                 -     CONTACT_DETAILS: Returns the contact's details, including first name, last name, company, email, and VAT ID.
 Return type: UpsertContactTaxDetailsResponse
  - name: contactTaxDetails | type: ContactTaxDetails | description: Created or updated contact tax details.  
     - name: id | type: string | description: Contact GUID. Also serves as the GUID of the contact tax details, since each contact has a single set of tax details.  | validation: format GUID
     - name: revision | type: string | description: Revision number, which increments by 1 each time the contact tax details are updated.  | read-only: true | validation: format int64
     - name: createdDate | type: string | description: Date and time the contact tax details were created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the contact tax details were updated.  | read-only: true | validation: format date-time
     - name: taxExemptGroupId | type: string | description: GUID of the tax exempt group the contact is associated with. Setting this value makes the contact eligible for the group's tax exemption at checkout.  | validation: format GUID
     - name: contactDetails | type: ContactDetails | description: The contact's details, such as name, email, and VAT GUID.  Returned only when `CONTACT_DETAILS` is passed to the `fields` array in the request.  
        - name: firstName | type: string | description: Contact's first name.  | read-only: true | validation: maxLength 100
        - name: lastName | type: string | description: Contact's last name.  | read-only: true | validation: maxLength 100
        - name: company | type: string | description: Contact's company name.  | read-only: true | validation: maxLength 100
        - name: email | type: string | description: Contact's email address.  | read-only: true | validation: format EMAIL
        - name: vatId | type: string | description: Contact's VAT GUID. Read from the contact's `invoices.vatId` extended field, so it's empty unless that field is set on the contact.  | read-only: true | validation: maxLength 100
     - name: extendedFields | type: ExtendedFields | description: Custom field data for the contact tax details.  [Extended fields](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/schema-plugins/about-schema-plugin-extensions.md) must be configured in the app dashboard before they can be accessed with API calls.  
        - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured.  You can only access fields for which you have the appropriate permissions.  Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).  | validation: format map
     - name: tags | type: Tags | description: Tags associated with the contact tax details.  
        - name: privateTags | type: TagList | description: Tags that require an additional permission in order to access them, normally not given to site members or visitors.  
           - name: tagIds | type: array<string> | description: List of tag GUIDs.  | validation: maxItems 100, maxLength 5
        - name: publicTags | type: TagList | description: Tags that are exposed to anyone who has access to the labeled entity itself, including site members and visitors.  


```

### Examples

### Upsert Contact Tax Details
Associates a contact with a tax exempt group. Creates the contact tax details if none exist for the contact, or updates them if they do.

```curl
curl -X POST \
    'https://www.wixapis.com/billing/v1/contact-tax-details' \
    -H 'Authorization: <AUTH>' \
    -H 'Content-Type: application/json' \
    -d '{
    "contactTaxDetails": {
      "id": "f1c3e2a0-1b2c-4d5e-8f90-1a2b3c4d5e6f",
      "taxExemptGroupId": "8046df3c-7575-4098-a5ab-c91ad8f33c47"
    }
  }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.ecom.contactTaxDetails.upsertContactTaxDetails(contactTaxDetails, options)
 Description: Creates or updates a contact's tax details.  If tax details already exist for the contact specified in `id`, they're updated. Otherwise, new tax details are created. The request must include `id`, the contact GUID, and `taxExemptGroupId`.  To create or update tax details for multiple contacts in a single API call, call [Bulk Upsert Contact Tax Details](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/tax/contact-tax-details/bulk-upsert-contact-tax-details.md).
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  contactTaxDetails, contactTaxDetails._id, contactTaxDetails.taxExemptGroupId
 Method parameters: 
   param name: contactTaxDetails | type: ContactTaxDetails | description: Contact tax details hold the tax-related information for a single contact, keyed by the contact's GUID. Their main purpose is to associate a contact with a tax exempt group, so that the contact receives the group's tax exemption automatically at checkout.  Each contact's tax details map the contact to at most one tax exempt group. During tax calculation, the buyer's contact GUID resolves their tax details, and if `taxExemptGroupId` is set, the matching exemption is applied and reported as an exempt amount in the tax breakdown.  Contacts are typically added to a group by a site owner in the dashboard, or by a VAT-validation app, such as Exemptify, that verifies a customer's VAT GUID at checkout and then associates the contact with the relevant exempt group. Once associated, later checkouts by the same contact are exempt without re-entering the VAT GUID. | required: true 
        - name: _id | type: string | description: Contact GUID. Also serves as the GUID of the contact tax details, since each contact has a single set of tax details. | required: true | validation: format GUID
        - name: taxExemptGroupId | type: string | description: GUID of the tax exempt group the contact is associated with. Setting this value makes the contact eligible for the group's tax exemption at checkout. | required: true | validation: format GUID
        - name: contactDetails | type: ContactDetails | description: The contact's details, such as name, email, and VAT GUID.  Returned only when `CONTACT_DETAILS` is passed to the `fields` array in the request.  
        - name: extendedFields | type: ExtendedFields | description: Custom field data for the contact tax details.  [Extended fields](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/schema-plugins/about-schema-plugin-extensions.md) must be configured in the app dashboard before they can be accessed with API calls.  
           - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured.  You can only access fields for which you have the appropriate permissions.  Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).  | validation: format map
        - name: tags | type: Tags | description: Tags associated with the contact tax details.  
           - name: privateTags | type: TagList | description: Tags that require an additional permission in order to access them, normally not given to site members or visitors.  
              - name: tagIds | type: array<string> | description: List of tag GUIDs.  | validation: maxItems 100, maxLength 5
           - name: publicTags | type: TagList | description: Tags that are exposed to anyone who has access to the labeled entity itself, including site members and visitors.  
   param name: options | type: UpsertContactTaxDetailsOptions  none  
        - name: fields | type: array<ContactTaxDetailsRequestedFields> | description: Additional fields to return in the response.  Supported values: `CONTACT_DETAILS`  | validation: maxItems 10
             - enum:
             -     CONTACT_DETAILS: Returns the contact's details, including first name, last name, company, email, and VAT ID.
 Return type: PROMISE<UpsertContactTaxDetailsResponse>
  - name: contactTaxDetails | type: ContactTaxDetails | description: Created or updated contact tax details.  
     - name: _id | type: string | description: Contact GUID. Also serves as the GUID of the contact tax details, since each contact has a single set of tax details.  | validation: format GUID
     - name: revision | type: string | description: Revision number, which increments by 1 each time the contact tax details are updated.  | read-only: true | validation: format int64
     - name: _createdDate | type: Date | description: Date and time the contact tax details were created.  | read-only: true 
     - name: _updatedDate | type: Date | description: Date and time the contact tax details were updated.  | read-only: true 
     - name: taxExemptGroupId | type: string | description: GUID of the tax exempt group the contact is associated with. Setting this value makes the contact eligible for the group's tax exemption at checkout.  | validation: format GUID
     - name: contactDetails | type: ContactDetails | description: The contact's details, such as name, email, and VAT GUID.  Returned only when `CONTACT_DETAILS` is passed to the `fields` array in the request.  
        - name: firstName | type: string | description: Contact's first name.  | read-only: true | validation: maxLength 100
        - name: lastName | type: string | description: Contact's last name.  | read-only: true | validation: maxLength 100
        - name: company | type: string | description: Contact's company name.  | read-only: true | validation: maxLength 100
        - name: email | type: string | description: Contact's email address.  | read-only: true | validation: format EMAIL
        - name: vatId | type: string | description: Contact's VAT GUID. Read from the contact's `invoices.vatId` extended field, so it's empty unless that field is set on the contact.  | read-only: true | validation: maxLength 100
     - name: extendedFields | type: ExtendedFields | description: Custom field data for the contact tax details.  [Extended fields](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/schema-plugins/about-schema-plugin-extensions.md) must be configured in the app dashboard before they can be accessed with API calls.  
        - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured.  You can only access fields for which you have the appropriate permissions.  Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).  | validation: format map
     - name: tags | type: Tags | description: Tags associated with the contact tax details.  
        - name: privateTags | type: TagList | description: Tags that require an additional permission in order to access them, normally not given to site members or visitors.  
           - name: tagIds | type: array<string> | description: List of tag GUIDs.  | validation: maxItems 100, maxLength 5
        - name: publicTags | type: TagList | description: Tags that are exposed to anyone who has access to the labeled entity itself, including site members and visitors.  


```

### Examples

### upsertContactTaxDetails
```javascript
import { contactTaxDetails } from '@wix/ecom';

async function upsertContactTaxDetails(contactTaxDetails,options) {
  const response = await contactTaxDetails.upsertContactTaxDetails(contactTaxDetails,options);
};
```

### upsertContactTaxDetails (with elevated permissions)
```javascript
import { contactTaxDetails } from '@wix/ecom';
import { auth } from '@wix/essentials';

async function myUpsertContactTaxDetailsMethod(contactTaxDetails,options) {
  const elevatedUpsertContactTaxDetails = auth.elevate(contactTaxDetails.upsertContactTaxDetails);
  const response = await elevatedUpsertContactTaxDetails(contactTaxDetails,options);
}
```

### upsertContactTaxDetails (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 { contactTaxDetails } from '@wix/ecom';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { contactTaxDetails },
  // Include the auth strategy and host as relevant
});


async function upsertContactTaxDetails(contactTaxDetails,options) {
  const response = await myWixClient.contactTaxDetails.upsertContactTaxDetails(contactTaxDetails,options);
};
```

---