> 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

# QueryAttributeDefinitions

# Package: attributes

# Namespace: AttributeDefinitionsService

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

## Introduction

Retrieves a list of up to 1000 attribute definitions, given the provided paging, filtering, and sorting.

Query Attribute Definitions runs with these defaults, which you can override:

- `createdDate` is sorted in `DESC` order
- `paging.limit` is `50`
- `paging.offset` is `0`

Supported filter and sort fields: `id`, `name`, `valueType`, `visibility`, `tags.publicTags.tagIds`, `tags.privateTags.tagIds`.

To learn about working with Query methods, see [API Query Language](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md), [Sorting and Paging](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-sorting-and-paging.md), and [Field Projection](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-field-projection.md).

---

## REST API

### Schema

```
 Method: queryAttributeDefinitions
 Description: Retrieves a list of up to 1000 attribute definitions, given the provided paging, filtering, and sorting.  Query Attribute Definitions runs with these defaults, which you can override:  - `createdDate` is sorted in `DESC` order - `paging.limit` is `50` - `paging.offset` is `0`  Supported filter and sort fields: `id`, `name`, `valueType`, `visibility`, `tags.publicTags.tagIds`, `tags.privateTags.tagIds`.  To learn about working with Query methods, see [API Query Language](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md), [Sorting and Paging](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-sorting-and-paging.md), and [Field Projection](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-field-projection.md).
 URL: https://www.wixapis.com/_api/attributes/v1/attribute-definitions/query
 Method: POST
 Method parameters:
   param name: query | type: CursorQuery    
     - name: cursorPaging | type: CursorPaging | description: Cursor paging options.  Learn more about [cursor paging](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#cursor-paging).  
        - name: limit | type: integer | description: Maximum number of items to return in the results.  | validation: minimum 0, maximum 100, format int32
        - name: cursor | type: string | description: Pointer to the next or previous page in the list of results.  Pass the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request.  | validation: maxLength 16000
        - name: filter | type: object | description: Filter object.  Learn more about the [filter section](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#the-filter-section).  
        - name: sort | type: array<Sorting> | description: Sort object.  Learn more about the [sort section](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#the-sort-section).  | validation: maxItems 5
           - name: fieldName | type: string | description: Name of the field to sort by.  | validation: maxLength 512
           - name: order | type: SortOrder | description: Sort order.  
                 - enum: ASC, DESC
 Query fields:
   - field: id | operators: $eq, $ne, $exists, $in, $hasSome, $startsWith, $gt, $lt, $lte, $gte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: name | operators: $eq, $ne, $exists, $in, $hasSome, $startsWith, $gt, $lt, $lte, $gte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: valueType | operators: $eq, $ne, $exists, $in, $hasSome | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: visibility | operators: $eq, $ne, $exists, $in, $hasSome | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: tags.publicTags.tagIds | operators: $eq, $ne, $exists, $in, $hasSome, $hasAll | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: tags.privateTags.tagIds | operators: $eq, $ne, $exists, $in, $hasSome, $hasAll | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
 Return type: QueryAttributeDefinitionsResponse
  - name: attributeDefinitions | type: array<AttributeDefinition> | description: List of attribute definitions.  
     - 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.  
  - name: pagingMetadata | type: CursorPagingMetadata | description: Paging metadata.  
     - name: count | type: integer | description: Number of items returned in current page.  | validation: format int32
     - name: cursors | type: Cursors | description: Cursor strings that point to the next page, previous page, or both.  
        - name: next | type: string | description: Cursor string pointing to the next page in the list of results.  | validation: maxLength 16000
        - name: prev | type: string | description: Cursor pointing to the previous page in the list of results.  | validation: maxLength 16000
     - name: hasNext | type: boolean | description: Whether there are more pages to retrieve following the current page.  + `true`: Another page of results can be retrieved. + `false`: This is the last page.  


```

### Examples

### Query number attribute definitions.
```curl
curl -X POST \
'https://www.wixapis.com/attributes/v1/attribute-definitions/query' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "query": {
    "filter": {
      "valueType": "NUMBER"
    },
    "cursorPaging": {
      "limit": 50
    }
  }
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.bookings.attributeDefinition.queryAttributeDefinitions(query)
 Description: Retrieves a list of up to 1000 attribute definitions, given the provided paging, filtering, and sorting.  Query Attribute Definitions runs with these defaults, which you can override:  - `createdDate` is sorted in `DESC` order - `paging.limit` is `50` - `paging.offset` is `0`  Supported filter and sort fields: `id`, `name`, `valueType`, `visibility`, `tags.publicTags.tagIds`, `tags.privateTags.tagIds`.  To learn about working with Query methods, see [API Query Language](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md), [Sorting and Paging](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-sorting-and-paging.md), and [Field Projection](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-field-projection.md).
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  query
 Method parameters: 
   param name: query | type: AttributeDefinitionQuery   | required: true 
     - name: cursorPaging | type: CursorPaging | description: Cursor paging options.  Learn more about [cursor paging](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#cursor-paging).  
        - name: limit | type: integer | description: Maximum number of items to return in the results.  | validation: minimum 0, maximum 100, format int32
        - name: cursor | type: string | description: Pointer to the next or previous page in the list of results.  Pass the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request.  | validation: maxLength 16000
        - name: filter | type: object | description: Filter object.  Learn more about the [filter section](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#the-filter-section).  
        - name: sort | type: array<Sorting> | description: Sort object.  Learn more about the [sort section](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#the-sort-section).  | validation: maxItems 5
           - name: fieldName | type: string | description: Name of the field to sort by.  | validation: maxLength 512
           - name: order | type: SortOrder | description: Sort order.  
                 - enum: ASC, DESC
 Query fields:
   - field: _id | operators: $eq, $ne, $exists, $in, $hasSome, $startsWith, $gt, $lt, $lte, $gte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: name | operators: $eq, $ne, $exists, $in, $hasSome, $startsWith, $gt, $lt, $lte, $gte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: valueType | operators: $eq, $ne, $exists, $in, $hasSome | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: visibility | operators: $eq, $ne, $exists, $in, $hasSome | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: tags.publicTags.tagIds | operators: $eq, $ne, $exists, $in, $hasSome, $hasAll | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: tags.privateTags.tagIds | operators: $eq, $ne, $exists, $in, $hasSome, $hasAll | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
 Return type: PROMISE<QueryAttributeDefinitionsResponse>
  - name: attributeDefinitions | type: array<AttributeDefinition> | description: List of attribute definitions.  
     - 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.  
  - name: pagingMetadata | type: CursorPagingMetadata | description: Paging metadata.  
     - name: count | type: integer | description: Number of items returned in current page.  | validation: format int32
     - name: cursors | type: Cursors | description: Cursor strings that point to the next page, previous page, or both.  
        - name: next | type: string | description: Cursor string pointing to the next page in the list of results.  | validation: maxLength 16000
        - name: prev | type: string | description: Cursor pointing to the previous page in the list of results.  | validation: maxLength 16000
     - name: hasNext | type: boolean | description: Whether there are more pages to retrieve following the current page.  + `true`: Another page of results can be retrieved. + `false`: This is the last page.  


```

### Examples

### Query number attribute definitions
```javascript
import { attributeDefinition } from "@wix/bookings";

const query = {
  filter: { valueType: "NUMBER" },
  cursorPaging: { limit: 50 },
};

async function queryAttributeDefinitions() {
  const response = await attributeDefinition.queryAttributeDefinitions(query);
}

/* Promise resolves to:
 * {
 *   "attributeDefinitions": [
 *     {
 *       "_id": "d7a341c4-196b-46e7-813c-2b0fc1847ec6",
 *       "revision": "1",
 *       "name": "Capacity",
 *       "valueType": "NUMBER",
 *       "numberConfig": { "min": 1, "max": 20 },
 *       "defaultValue": { "numberDefault": 2 },
 *       "visibility": true
 *     }
 *   ],
 *   "pagingMetadata": { "count": 1, "cursors": {} }
 * }
 */

```

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

---