> 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

# QueryTemplates

# Package: studioWorkspace

# Namespace: Templates

# Method link: https://dev.wix.com/docs/api-reference/account-level/studio-workspace/template-v1/query-templates.md

## Introduction

Retrieves a list of templates, given the provided paging, filtering, and sorting.

Query Templates runs with these defaults, which you can override:

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

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: queryTemplates
 Description: Retrieves a list of templates, given the provided paging, filtering, and sorting.  Query Templates runs with these defaults, which you can override:  - `createdDate` is sorted in `DESC` order - `paging.limit` is `50`  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/wixstudio/templates/v1/templates/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 [filtering](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#filters).  
        - name: sort | type: array<Sorting> | description: Sort object.  Learn more about [sorting](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#sorting).  | 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
           - name: origin | type: AddressLocation | description: Origin point for geo-distance sorting on a GEO field results are ordered by distance from this point (ASC = nearest first, DESC = farthest first).  
              - name: latitude | type: number | description: Address latitude.  | validation: format double
              - name: longitude | type: number | description: Address longitude.  | validation: format double
 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: createdBy | operators: $eq, $ne, $exists, $in, $hasSome, $startsWith, $gt, $lt, $lte, $gte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: lastEditedBy | operators: $eq, $ne, $exists, $in, $hasSome, $startsWith, $gt, $lt, $lte, $gte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: lastEditedDate | operators: $eq, $ne, $exists, $in, $hasSome, $lt, $lte, $gt, $gte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: updatedDate | operators: $eq, $ne, $exists, $in, $hasSome, $lt, $lte, $gt, $gte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: createdDate | operators: $eq, $ne, $exists, $in, $hasSome, $lt, $lte, $gt, $gte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
 Return type: QueryTemplatesResponse
  - name: templates | type: array<Template> | description: Retrieved templates.  
     - name: id | type: string | description: Template GUID.  | validation: format GUID
     - name: name | type: string | description: Template name.  | validation: minLength 4, maxLength 20
     - name: sites | type: Sites | description: Sites created from this template within the current account.  
        - name: metaSiteIds | type: array<string> | description: IDs of the sites created from this template within the current account.  | validation: maxItems 1000, format GUID
        - name: count | type: integer | description: Number of sites created from this template within the current account.  | validation: format int32
     - name: createdBy | type: string | description: GUID of the user who created the template.  | validation: format GUID
     - name: lastEditedBy | type: string | description: GUID of the user who last edited the template's site.  | validation: format GUID
     - name: lastEditedDate | type: string | description: Date and time the template's site was last edited.  | validation: format date-time
     - name: revision | type: string | description: Revision number, which increments by 1 each time the template is updated. To prevent conflicting changes, the current revision must be passed when updating the template. Ignored when creating a template.  | validation: format int64
     - name: createdDate | type: string | description: Date and time the template was created.  | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the template was updated.  | validation: format date-time
     - name: templateType | type: TemplateType | description: Type of the template.  
         - enum:
         -     UNKNOWN: Unknown template type.
         -     STUDIO: Standard template created from a site.
         -     PUBLIC: Published template that other Wix accounts can clone.
     - name: hidden | type: boolean | description: Whether the template is hidden from template galleries and pickers. A hidden template still exists and can be used to create sites, but doesn't appear in template lists. Default: `false`.  
     - name: platform | type: Platform | description: Platform the template's site was built on. Derived automatically from the site.  
         - enum:
         -     STUDIO: Site built with Wix Studio.
         -     WIX: Site built with the Wix Editor.
  - 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 Templates
Retrieves a list of templates, given the provided paging, filtering, and sorting.

```curl
curl -X POST \
  'https://www.wixapis.com/wixstudio/templates/v1/templates/query' \
  -H 'Authorization: <AUTH>' \
  -H 'Content-Type: application/json' \
  --data-binary '{
    "query": {
      "filter": {
        "templateType": "STUDIO"
      },
      "sort": [
        { "fieldName": "createdDate", "order": "DESC" }
      ],
      "cursorPaging": {
        "limit": 50
      }
    }
  }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.templates.wixTemplatesBackend.queryTemplates(query)
 Description: Retrieves a list of templates, given the provided paging, filtering, and sorting.  Query Templates runs with these defaults, which you can override:  - `createdDate` is sorted in `DESC` order - `paging.limit` is `50`  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: TemplateQuery   | 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 [filtering](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#filters).  
        - name: sort | type: array<Sorting> | description: Sort object.  Learn more about [sorting](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#sorting).  | 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
           - name: origin | type: AddressLocation | description: Origin point for geo-distance sorting on a GEO field results are ordered by distance from this point (ASC = nearest first, DESC = farthest first).  
              - name: latitude | type: number | description: Address latitude.  
              - name: longitude | type: number | description: Address longitude.  
 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: createdBy | operators: $eq, $ne, $exists, $in, $hasSome, $startsWith, $gt, $lt, $lte, $gte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: lastEditedBy | operators: $eq, $ne, $exists, $in, $hasSome, $startsWith, $gt, $lt, $lte, $gte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: lastEditedDate | operators: $eq, $ne, $exists, $in, $hasSome, $lt, $lte, $gt, $gte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: _updatedDate | operators: $eq, $ne, $exists, $in, $hasSome, $lt, $lte, $gt, $gte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: _createdDate | operators: $eq, $ne, $exists, $in, $hasSome, $lt, $lte, $gt, $gte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
 Return type: PROMISE<QueryTemplatesResponse>
  - name: templates | type: array<Template> | description: Retrieved templates.  
     - name: _id | type: string | description: Template GUID.  | validation: format GUID
     - name: name | type: string | description: Template name.  | validation: minLength 4, maxLength 20
     - name: sites | type: Sites | description: Sites created from this template within the current account.  
        - name: metaSiteIds | type: array<string> | description: IDs of the sites created from this template within the current account.  | validation: maxItems 1000, format GUID
        - name: count | type: integer | description: Number of sites created from this template within the current account.  | validation: format int32
     - name: createdBy | type: string | description: GUID of the user who created the template.  | validation: format GUID
     - name: lastEditedBy | type: string | description: GUID of the user who last edited the template's site.  | validation: format GUID
     - name: lastEditedDate | type: Date | description: Date and time the template's site was last edited.  
     - name: revision | type: string | description: Revision number, which increments by 1 each time the template is updated. To prevent conflicting changes, the current revision must be passed when updating the template. Ignored when creating a template.  | validation: format int64
     - name: _createdDate | type: Date | description: Date and time the template was created.  
     - name: _updatedDate | type: Date | description: Date and time the template was updated.  
     - name: templateType | type: TemplateType | description: Type of the template.  
         - enum:
         -     UNKNOWN: Unknown template type.
         -     STUDIO: Standard template created from a site.
         -     PUBLIC: Published template that other Wix accounts can clone.
     - name: hidden | type: boolean | description: Whether the template is hidden from template galleries and pickers. A hidden template still exists and can be used to create sites, but doesn't appear in template lists. Default: `false`.  
     - name: platform | type: Platform | description: Platform the template's site was built on. Derived automatically from the site.  
         - enum:
         -     STUDIO: Site built with Wix Studio.
         -     WIX: Site built with the Wix Editor.
  - 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 templates //
Retrieves the account's templates, filtered, sorted, and paged

```javascript
import { wixWixstudioTemplatesV1Template } from "@wix/dev";

const query = {
  filter: {
    templateType: "STUDIO",
  },
  sort: [{ fieldName: "createdDate", order: "DESC" }],
  cursorPaging: { limit: 50 },
};

async function queryTemplates() {
  const response =
    await wixWixstudioTemplatesV1Template.queryTemplates(query);
}

/* Promise resolves to:
 * {
 *   "templates": [
 *     {
 *       "_id": "d7a341c4-196b-46e7-813c-2b0fb1847ec6",
 *       "name": "Agency Portfolio",
 *       "sites": { "metaSiteIds": ["f3e8a2d1-9c4b-4a6e-8d5f-2b1c7e9a4f68"], "count": 1 },
 *       "revision": "2",
 *       "_createdDate": "2026-06-01T09:15:00.000Z",
 *       "_updatedDate": "2026-06-03T08:05:00.000Z",
 *       "templateType": "STUDIO",
 *       "hidden": false,
 *       "platform": "STUDIO"
 *     }
 *   ],
 *   "pagingMetadata": {
 *     "count": 1,
 *     "cursors": {},
 *     "hasNext": false
 *   }
 * }
 */

```

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

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


async function queryTemplates(query) {
  const response = await myWixClient.wixTemplatesBackend.queryTemplates(query);
};
```

---