> 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

# GetAttributeDefinition

# Package: attributes

# Namespace: AttributeDefinitionsService

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

## Introduction

Retrieves an attribute definition by its ID.

---

## REST API

### Schema

```
 Method: getAttributeDefinition
 Description: Retrieves an attribute definition by its GUID.
 URL: https://www.wixapis.com/_api/attributes/v1/attribute-definitions/{attributeDefinitionId}
 Method: GET
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  attributeDefinitionId
 Method parameters: 
   param name: attributeDefinitionId | type:   none | required: true 
 Return type: GetAttributeDefinitionResponse
  - name: attributeDefinition | type: AttributeDefinition | description: The requested 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.  


```

### Examples

### Retrieve an attribute definition by ID.
```curl
curl -X GET \
'https://www.wixapis.com/attributes/v1/attribute-definitions/d7a341c4-196b-46e7-813c-2b0fc1847ec6' \
-H 'Authorization: <AUTH>'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.bookings.attributeDefinition.getAttributeDefinition(attributeDefinitionId)
 Description: Retrieves an attribute definition by its GUID.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  attributeDefinitionId
 Method parameters: 
   param name: attributeDefinitionId | type: string | description: GUID of the attribute definition to retrieve. | required: true | validation: format GUID
 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.  


```

### Examples

### Retrieve an attribute definition by ID
```javascript
import { attributeDefinition } from "@wix/bookings";

const attributeDefinitionId = "d7a341c4-196b-46e7-813c-2b0fc1847ec6";

async function getAttributeDefinition() {
  const response = await attributeDefinition.getAttributeDefinition(attributeDefinitionId);
}

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

```

### getAttributeDefinition (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 getAttributeDefinition(attributeDefinitionId) {
  const response = await myWixClient.attributeDefinition.getAttributeDefinition(attributeDefinitionId);
};
```

---