> 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

# UpdateAttributeDefinition

# Package: attributes

# Namespace: AttributeDefinitionsService

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/bookings/resources/attributes/attribute-definition/update-attribute-definition.md

## Introduction

Updates an attribute definition.

Each time the attribute definition is updated, `revision` increments by 1. The current `revision` must be passed when updating the attribute definition. This ensures you're working with the latest attribute definition and prevents unintended overwrites.

`valueType` is immutable. The request is rejected if a different `valueType` is passed.

Changing the attribute's `config` (a string attribute's `allowedValues`, or a number attribute's `min`/`max`) re-validates every stored attribute value for this definition across all entities: any value that no longer conforms to the new configuration is reset to the attribute's `defaultValue`.

---

## REST API

### Schema

```
 Method: updateAttributeDefinition
 Description: Updates an attribute definition.  Each time the attribute definition is updated, `revision` increments by 1. The current `revision` must be passed when updating the attribute definition. This ensures you're working with the latest attribute definition and prevents unintended overwrites.  `valueType` is immutable. The request is rejected if a different `valueType` is passed.  Changing the attribute's `config` (a string attribute's `allowedValues`, or a number attribute's `min`/`max`) re-validates every stored attribute value for this definition across all entities: any value that no longer conforms to the new configuration is reset to the attribute's `defaultValue`.
 URL: https://www.wixapis.com/_api/attributes/v1/attribute-definitions/{attributeDefinition.id}
 Method: PATCH
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  attributeDefinition, attributeDefinition.id, attributeDefinition.revision
 Method parameters: 
   param name: attributeDefinition | type: AttributeDefinition | description: An attribute definition is a typed custom property (string, number, or boolean) that can be applied to entities. Each definition has a display name shown to end users, a value type, optional type-specific configuration (such as a list of allowed string values), and a default value.  Attribute definitions are defined once per site. To set a value for a specific entity, call Bulk Upsert Attribute Values; to read an entity's values together with their definitions, call List Entity Attributes. | required: true 
    - ONE-OF: - required: true
     - name: stringConfig | type: StringConfig | description: String configuration: the list of allowed string values.  
        - name: allowedValues | type: array<string> | description: Allowed string values for this attribute. Values can be added, removed, or renamed; on update, any entity value that no longer matches the allowed values is reset to the attribute's default.  | validation: minItems 1, maxItems 50, maxLength 40
     - name: numberConfig | type: NumberConfig | description: Number configuration: the valid integer range.  
        - name: min | type: integer | description: Minimum allowed value (integer).  
        - name: max | type: integer | description: Maximum allowed value (integer). Must be greater than or equal to `min`.  
        - name: id | type: string | description: Attribute definition GUID. | required: true | validation: format GUID
        - name: revision | type: string | description: Revision number, which increments by 1 each time the attribute definition is updated. To prevent conflicting changes, the current revision must be passed when updating. Ignored when creating an attribute definition. | required: true | validation: format int64
        - name: name | type: string | description: Display name for the attribute, shown to end users (for example, `Capacity`).  Must be unique within the site. Required when creating an attribute definition.  | validation: minLength 1, maxLength 40
        - name: valueType | type: ValueType | description: Value type of this attribute. Immutable after creation. `UpdateAttributeDefinition` rejects requests that change `value_type`. Required when creating an attribute definition.  
             - enum:
             -     STRING: String attribute: single-select from a predefined list of allowed string values.
             -     NUMBER: Integer number attribute with a required min/max range.
             -     BOOL: Boolean attribute (true/false).
        - name: visibility | type: boolean | description: Whether this attribute is shown to end users on the public site.  - `true`: shown in the UI and available for filtering. - `false`: hidden from end users. Back-office admins can still see and edit the attribute.  Default: `true`.  
        - name: defaultValue | type: AttributeDefaultValue | description: Default value for the attribute. When a configuration change leaves a stored attribute value out of range or outside the allowed values, that value is reset to this default (see Update Attribute Definition).  The variant must match `valueType`. Required when creating an attribute definition.  
           - ONE-OF: 
              - name: stringDefault | type: string | description: Default value for a STRING-type attribute. Must be in StringConfig.allowed_values.  | validation: maxLength 40
              - name: numberDefault | type: integer | description: Default value for a NUMBER-type attribute. Must be within NumberConfig [min, max].  
              - name: boolDefault | type: boolean | description: Default value for a BOOL-type attribute.  
        - name: extendedFields | type: ExtendedFields | description: Custom field data for the attribute definition. [Extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.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: Custom tags for organizing and filtering attribute definitions. Manage tags using `BulkUpdateAttributeDefinitionTags` or `BulkUpdateAttributeDefinitionTagsByFilter`.  
           - 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.  
 Return type: UpdateAttributeDefinitionResponse
  - name: attributeDefinition | type: AttributeDefinition | description: Updated attribute definition.  
     - ONE-OF: 
        - name: stringConfig | type: StringConfig | description: String configuration: the list of allowed string values.  
           - name: allowedValues | type: array<string> | description: Allowed string values for this attribute. Values can be added, removed, or renamed; on update, any entity value that no longer matches the allowed values is reset to the attribute's default.  | validation: minItems 1, maxItems 50, maxLength 40
        - name: numberConfig | type: NumberConfig | description: Number configuration: the valid integer range.  
           - name: min | type: integer | description: Minimum allowed value (integer).  
           - name: max | type: integer | description: Maximum allowed value (integer). Must be greater than or equal to `min`.  
     - name: id | type: string | description: Attribute definition GUID.  | validation: format GUID
     - name: revision | type: string | description: Revision number, which increments by 1 each time the attribute definition is updated. To prevent conflicting changes, the current revision must be passed when updating. Ignored when creating an attribute definition.  | validation: format int64
     - name: createdDate | type: string | description: Date and time the attribute definition was created.  | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the attribute definition was last updated.  | validation: format date-time
     - name: name | type: string | description: Display name for the attribute, shown to end users (for example, `Capacity`).  Must be unique within the site. Required when creating an attribute definition.  | validation: minLength 1, maxLength 40
     - name: valueType | type: ValueType | description: Value type of this attribute. Immutable after creation. `UpdateAttributeDefinition` rejects requests that change `value_type`. Required when creating an attribute definition.  
         - enum:
         -     STRING: String attribute: single-select from a predefined list of allowed string values.
         -     NUMBER: Integer number attribute with a required min/max range.
         -     BOOL: Boolean attribute (true/false).
     - name: visibility | type: boolean | description: Whether this attribute is shown to end users on the public site.  - `true`: shown in the UI and available for filtering. - `false`: hidden from end users. Back-office admins can still see and edit the attribute.  Default: `true`.  
     - name: defaultValue | type: AttributeDefaultValue | description: Default value for the attribute. When a configuration change leaves a stored attribute value out of range or outside the allowed values, that value is reset to this default (see Update Attribute Definition).  The variant must match `valueType`. Required when creating an attribute definition.  
        - ONE-OF: 
           - name: stringDefault | type: string | description: Default value for a STRING-type attribute. Must be in StringConfig.allowed_values.  | validation: maxLength 40
           - name: numberDefault | type: integer | description: Default value for a NUMBER-type attribute. Must be within NumberConfig [min, max].  
           - name: boolDefault | type: boolean | description: Default value for a BOOL-type attribute.  
     - name: extendedFields | type: ExtendedFields | description: Custom field data for the attribute definition. [Extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.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: Custom tags for organizing and filtering attribute definitions. Manage tags using `BulkUpdateAttributeDefinitionTags` or `BulkUpdateAttributeDefinitionTagsByFilter`.  
        - 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.  

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: DEFAULT_VALUE_NO_LONGER_VALID | Description: After the config or default change, the default value no longer conforms to the configuration.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: NUMBER_CONFIG_MAX_LESS_THAN_MIN | Description: The number configuration is invalid: `max` is less than `min`.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: VALUE_TYPE_IMMUTABLE | Description: none
   HTTP Code: 409 | Status Code: ALREADY_EXISTS | Application Code: DUPLICATE_ATTRIBUTE_NAME | Description: Another attribute definition on the site already uses this name.


```

### Examples

### Update an attribute definition's name.
```curl
curl -X PATCH \
'https://www.wixapis.com/attributes/v1/attribute-definitions/d7a341c4-196b-46e7-813c-2b0fc1847ec6' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "attributeDefinition": {
    "id": "d7a341c4-196b-46e7-813c-2b0fc1847ec6",
    "revision": "1",
    "name": "Maximum capacity"
  }
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.bookings.attributeDefinition.updateAttributeDefinition(_id, attributeDefinition)
 Description: Updates an attribute definition.  Each time the attribute definition is updated, `revision` increments by 1. The current `revision` must be passed when updating the attribute definition. This ensures you're working with the latest attribute definition and prevents unintended overwrites.  `valueType` is immutable. The request is rejected if a different `valueType` is passed.  Changing the attribute's `config` (a string attribute's `allowedValues`, or a number attribute's `min`/`max`) re-validates every stored attribute value for this definition across all entities: any value that no longer conforms to the new configuration is reset to the attribute's `defaultValue`.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  attributeDefinition, _id, attributeDefinition.revision
 Method parameters: 
   param name: _id | type: string | description: Attribute definition GUID. | required: true | validation: format GUID
   param name: attributeDefinition | type: UpdateAttributeDefinition | description: An attribute definition is a typed custom property (string, number, or boolean) that can be applied to entities. Each definition has a display name shown to end users, a value type, optional type-specific configuration (such as a list of allowed string values), and a default value.  Attribute definitions are defined once per site. To set a value for a specific entity, call Bulk Upsert Attribute Values; to read an entity's values together with their definitions, call List Entity Attributes. | required: true 
    - ONE-OF: - required: true
     - name: stringConfig | type: StringConfig | description: String configuration: the list of allowed string values.  
        - name: allowedValues | type: array<string> | description: Allowed string values for this attribute. Values can be added, removed, or renamed; on update, any entity value that no longer matches the allowed values is reset to the attribute's default.  | validation: minItems 1, maxItems 50, maxLength 40
     - name: numberConfig | type: NumberConfig | description: Number configuration: the valid integer range.  
        - name: min | type: integer | description: Minimum allowed value (integer).  
        - name: max | type: integer | description: Maximum allowed value (integer). Must be greater than or equal to `min`.  
        - name: revision | type: string | description: Revision number, which increments by 1 each time the attribute definition is updated. To prevent conflicting changes, the current revision must be passed when updating. Ignored when creating an attribute definition. | required: true | validation: format int64
        - name: name | type: string | description: Display name for the attribute, shown to end users (for example, `Capacity`).  Must be unique within the site. Required when creating an attribute definition.  | validation: minLength 1, maxLength 40
        - name: valueType | type: ValueType | description: Value type of this attribute. Immutable after creation. `UpdateAttributeDefinition` rejects requests that change `value_type`. Required when creating an attribute definition.  
             - enum:
             -     STRING: String attribute: single-select from a predefined list of allowed string values.
             -     NUMBER: Integer number attribute with a required min/max range.
             -     BOOL: Boolean attribute (true/false).
        - name: visibility | type: boolean | description: Whether this attribute is shown to end users on the public site.  - `true`: shown in the UI and available for filtering. - `false`: hidden from end users. Back-office admins can still see and edit the attribute.  Default: `true`.  
        - name: defaultValue | type: AttributeDefaultValue | description: Default value for the attribute. When a configuration change leaves a stored attribute value out of range or outside the allowed values, that value is reset to this default (see Update Attribute Definition).  The variant must match `valueType`. Required when creating an attribute definition.  
           - ONE-OF: 
              - name: stringDefault | type: string | description: Default value for a STRING-type attribute. Must be in StringConfig.allowed_values.  | validation: maxLength 40
              - name: numberDefault | type: integer | description: Default value for a NUMBER-type attribute. Must be within NumberConfig [min, max].  
              - name: boolDefault | type: boolean | description: Default value for a BOOL-type attribute.  
        - name: extendedFields | type: ExtendedFields | description: Custom field data for the attribute definition. [Extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.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: Custom tags for organizing and filtering attribute definitions. Manage tags using `BulkUpdateAttributeDefinitionTags` or `BulkUpdateAttributeDefinitionTagsByFilter`.  
           - 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.  
 Return type: PROMISE<AttributeDefinition>
  - ONE-OF: 
     - name: stringConfig | type: StringConfig | description: String configuration: the list of allowed string values.  
        - name: allowedValues | type: array<string> | description: Allowed string values for this attribute. Values can be added, removed, or renamed; on update, any entity value that no longer matches the allowed values is reset to the attribute's default.  | validation: minItems 1, maxItems 50, maxLength 40
     - name: numberConfig | type: NumberConfig | description: Number configuration: the valid integer range.  
        - name: min | type: integer | description: Minimum allowed value (integer).  
        - name: max | type: integer | description: Maximum allowed value (integer). Must be greater than or equal to `min`.  
  - name: _id | type: string | description: Attribute definition GUID.  | validation: format GUID
  - name: revision | type: string | description: Revision number, which increments by 1 each time the attribute definition is updated. To prevent conflicting changes, the current revision must be passed when updating. Ignored when creating an attribute definition.  | validation: format int64
  - name: _createdDate | type: Date | description: Date and time the attribute definition was created.  
  - name: _updatedDate | type: Date | description: Date and time the attribute definition was last updated.  
  - name: name | type: string | description: Display name for the attribute, shown to end users (for example, `Capacity`).  Must be unique within the site. Required when creating an attribute definition.  | validation: minLength 1, maxLength 40
  - name: valueType | type: ValueType | description: Value type of this attribute. Immutable after creation. `UpdateAttributeDefinition` rejects requests that change `value_type`. Required when creating an attribute definition.  
     - enum:
     -     STRING: String attribute: single-select from a predefined list of allowed string values.
     -     NUMBER: Integer number attribute with a required min/max range.
     -     BOOL: Boolean attribute (true/false).
  - name: visibility | type: boolean | description: Whether this attribute is shown to end users on the public site.  - `true`: shown in the UI and available for filtering. - `false`: hidden from end users. Back-office admins can still see and edit the attribute.  Default: `true`.  
  - name: defaultValue | type: AttributeDefaultValue | description: Default value for the attribute. When a configuration change leaves a stored attribute value out of range or outside the allowed values, that value is reset to this default (see Update Attribute Definition).  The variant must match `valueType`. Required when creating an attribute definition.  
     - ONE-OF: 
        - name: stringDefault | type: string | description: Default value for a STRING-type attribute. Must be in StringConfig.allowed_values.  | validation: maxLength 40
        - name: numberDefault | type: integer | description: Default value for a NUMBER-type attribute. Must be within NumberConfig [min, max].  
        - name: boolDefault | type: boolean | description: Default value for a BOOL-type attribute.  
  - name: extendedFields | type: ExtendedFields | description: Custom field data for the attribute definition. [Extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.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: Custom tags for organizing and filtering attribute definitions. Manage tags using `BulkUpdateAttributeDefinitionTags` or `BulkUpdateAttributeDefinitionTagsByFilter`.  
     - 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.  

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: DEFAULT_VALUE_NO_LONGER_VALID | Description: After the config or default change, the default value no longer conforms to the configuration.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: NUMBER_CONFIG_MAX_LESS_THAN_MIN | Description: The number configuration is invalid: `max` is less than `min`.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: VALUE_TYPE_IMMUTABLE | Description: none
   HTTP Code: 409 | Status Code: ALREADY_EXISTS | Application Code: DUPLICATE_ATTRIBUTE_NAME | Description: Another attribute definition on the site already uses this name.


```

### Examples

### Update an attribute definition's name
```javascript
import { attributeDefinition } from "@wix/bookings";

const attributeDefinitionId = "d7a341c4-196b-46e7-813c-2b0fc1847ec6";
const updatedDefinition = {
  revision: "1",
  name: "Maximum capacity",
};

async function updateAttributeDefinition() {
  const response = await attributeDefinition.updateAttributeDefinition(attributeDefinitionId, updatedDefinition);
}

/* Promise resolves to:
 * {
 *   "_id": "d7a341c4-196b-46e7-813c-2b0fc1847ec6",
 *   "revision": "2",
 *   "_createdDate": "2024-01-15T10:30:00.000Z",
 *   "_updatedDate": "2024-01-16T09:12:00.000Z",
 *   "name": "Maximum capacity",
 *   "valueType": "NUMBER",
 *   "numberConfig": { "min": 1, "max": 20 },
 *   "defaultValue": { "numberDefault": 2 },
 *   "visibility": true
 * }
 */

```

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

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


async function updateAttributeDefinition(_id,attributeDefinition) {
  const response = await myWixClient.attributeDefinition.updateAttributeDefinition(_id,attributeDefinition);
};
```

---