> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> 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`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# Method name: queryDraftPosts(options: QueryDraftPostsOptions)

# Method package: wixBlogBackend

# Method menu location: wixBlogBackend --> draftPosts --> queryDraftPosts

# Method Link: https://dev.wix.com/docs/velo/apis/wix-blog-backend/draft-posts/query-draft-posts.md

# Method Description:

Retrieves a list of up to 100 draft posts, given the provided paging, filtering, and sorting.

Query Draft Posts runs with these defaults, which you can override:
- `editedDate` is sorted in `DESC` order.
- `paging.limit` is `50`.
- `paging.offset` is `0`.


|PROPERTY	|SUPPORTED FILTERS & SORTING	
|:---:|:---:|
|`_id`|[`eq()`](/draft-posts-query-builder/eq),[`ne()`](/draft-posts-query-builder/ne),[`hasSome()`](/draft-posts-query-builder/has-some),[`ascending()`](/draft-posts-query-builder/ascending),[`descending()`](/draft-posts-query-builder/descending)|
|`title`|[`eq()`](/draft-posts-query-builder/eq),[`ne()`](/draft-posts-query-builder/ne),[`startsWith()`](/draft-posts-query-builder/starts-with),[`hasSome()`](/draft-posts-query-builder/has-some),[`exists()`](/draft-posts-query-builder/exists),[`in()`](/draft-posts-query-builder/in),[`ascending()`](/draft-posts-query-builder/ascending),[`descending()`](/draft-posts-query-builder/descending)|
|`excerpt`|[`eq()`](/draft-posts-query-builder/eq),[`ne()`](/draft-posts-query-builder/ne),[`startsWith()`](/draft-posts-query-builder/starts-with),[`hasSome()`](/draft-posts-query-builder/has-some),[`exists()`](/draft-posts-query-builder/exists),[`in()`](/draft-posts-query-builder/in),[`ascending()`](/draft-posts-query-builder/ascending),[`descending()`](/draft-posts-query-builder/descending)|
|`featured`|[`eq()`](/draft-posts-query-builder/eq),[`ne()`](/draft-posts-query-builder/ne),[`ascending()`](/draft-posts-query-builder/ascending),[`descending()`](/draft-posts-query-builder/descending)|
|`categoryIds`|[`hasSome()`](/draft-posts-query-builder/has-some),[`hasAll()`](/draft-posts-query-builder/has-all)|
|`memberId`|[`eq()`](/draft-posts-query-builder/eq),[`ne()`](/draft-posts-query-builder/ne),[`hasSome()`](/draft-posts-query-builder/has-some)|
|`hashtags`|[`hasSome()`](/draft-posts-query-builder/has-some),[`hasAll()`](/draft-posts-query-builder/has-all)|
|`commentingEnabled`|[`eq()`](/draft-posts-query-builder/eq),[`ne()`](/draft-posts-query-builder/ne),[`ascending()`](/draft-posts-query-builder/ascending),[`descending()`](/draft-posts-query-builder/descending)|
|`minutesToRead`|[`eq()`](/draft-posts-query-builder/eq),[`ne()`](/draft-posts-query-builder/ne),[`lt()`](/draft-posts-query-builder/lt),[`le()`](/draft-posts-query-builder/le),[`gt()`](/draft-posts-query-builder/gt),[`ge()`](/draft-posts-query-builder/ge),[`in()`](/draft-posts-query-builder/in)|
|`tagIds`|[`hasSome()`](/draft-posts-query-builder/has-some),[`hasAll()`](/draft-posts-query-builder/has-all)|
|`pricingPlanIds`|[`hasSome()`](/draft-posts-query-builder/has-some),[`hasAll()`](/draft-posts-query-builder/has-all)|
|`translationId`|[`eq()`](/draft-posts-query-builder/eq),[`ne()`](/draft-posts-query-builder/ne),[`exists()`](/draft-posts-query-builder/exists),[`in()`](/draft-posts-query-builder/in)|
|`language`|[`eq()`](/draft-posts-query-builder/eq),[`ne()`](/draft-posts-query-builder/ne),[`hasSome()`](/draft-posts-query-builder/has-some),[`exists()`](/draft-posts-query-builder/exists),[`in()`](/draft-posts-query-builder/in)|
|`status`|[`eq()`](/draft-posts-query-builder/eq),[`ne()`](/draft-posts-query-builder/ne),[`hasSome()`](/draft-posts-query-builder/has-some),[`exists()`](/draft-posts-query-builder/exists),[`in()`](/draft-posts-query-builder/in),[`ascending()`](/draft-posts-query-builder/ascending),[`descending()`](/draft-posts-query-builder/descending)|
|`hasUnpublishedChanges`|[`eq()`](/draft-posts-query-builder/eq),[`ne()`](/draft-posts-query-builder/ne),[`ascending()`](/draft-posts-query-builder/ascending),[`descending()`](/draft-posts-query-builder/descending)|
|`editedDate`|[`eq()`](/draft-posts-query-builder/eq),[`ne()`](/draft-posts-query-builder/ne),[`lt()`](/draft-posts-query-builder/lt),[`le()`](/draft-posts-query-builder/le),[`gt()`](/draft-posts-query-builder/gt),[`ge()`](/draft-posts-query-builder/ge),[`in()`](/draft-posts-query-builder/in),[`ascending()`](/draft-posts-query-builder/ascending),[`descending()`](/draft-posts-query-builder/descending)|
|`scheduledPublishDate`|[`eq()`](/draft-posts-query-builder/eq),[`ne()`](/draft-posts-query-builder/ne),[`lt()`](/draft-posts-query-builder/lt),[`le()`](/draft-posts-query-builder/le),[`gt()`](/draft-posts-query-builder/gt),[`ge()`](/draft-posts-query-builder/ge),[`in()`](/draft-posts-query-builder/in),[`ascending()`](/draft-posts-query-builder/ascending),[`descending()`](/draft-posts-query-builder/descending)|



# Method Code Examples:

*** Note: do not assume any prop names or enum values other than the ones in the example.

## Query draft posts using options (export from backend code) 

```javascript
import { draftPosts } from 'wix-blog-backend';
import { webMethod, Permissions } from 'wix-web-module';

/* Sample options value: 
 * {
 *    "fieldsets": ["GENERATED_EXCERPT"]
 *  }
 */

export const myQueryDraftPostsFunction = webMethod(
  Permissions.Admin,
  async (options) => {
    try {
      const queriedDraftPosts = await draftPosts.queryDraftPosts(options);
      console.log('Successfully queried draft posts:', queriedDraftPosts);
      return queriedDraftPosts;
    } catch (error) {
      console.error(error);
      // Handle the error
    }
  }
);


/* Promise resolves to:
 *  _items: [
 *    {
 *      _id: "d12f2ef2-c0f6-4913-b04f-aeeba2165b93",
 *      _createdDate: "2024-01-09T11:46:42.933Z",
 *      categoryIds: [
 *        "c8780752-f517-4cf9-9c18-0f9a22d00926",
 *        "590635d7-cc7c-48cb-970c-f8339daa1cfe",
 *        "2b2ccb5a-e709-45a1-8353-bb3332b91297"
 *      ],
 *      changeOrigin: "PRICING_PLANS_CHANGE",
 *      commentingEnabled: true,
 *      contentId: "65afbb218a16969308f29037",
 *      editedDate: "2024-01-16T10:50:33.495Z",
 *      editingSessionId: "4e14aa41-ad7f-4e25-b4c4-df7144002aaf",
 *      excerpt: "This is a excerpt about adding a widget to blog post rich content",
 *      featured: true,
 *      firstPublishedDate: "2024-01-09T11:46:43.034Z",
 *      hashtags: [],
 *      hasUnpublishedChanges: false,
 *      language: "en",
 *      media: {
 *        custom: false,
 *        displayed: true
 *      },
 *      memberId: "c00e8a5c-322b-4e77-8813-002e3ea7e811",
 *      minutesToRead: 15,
 *      mostRecentContributorId: "c00e8a5c-322b-4e77-8813-002e3ea7e811",
 *      paidContentParagraph: 1,
 *      pricingPlanIds: [
 *        "4b265594-133c-4cb0-a3af-b31852cad5e7",
 *        "0a6230d1-fe66-4367-9cce-7d7b17ede8cc",
 *        "4c9646d6-e1fb-4559-9267-1620015082aa"
 *      ],
 *      previewTextParagraph: 1,
 *      relatedPostIds: [
 *        "d655251a-74eb-467d-9beb-1962984b8d94",
 *        "6f4d3a1e-dec6-4818-b8b0-9fb62862aa5b",
 *        "66935097-31c5-4fab-9693-aa1b53aeea77"
 *      ],
 *      seoData: {
 *        settings: {
 *          preventAutoRedirect: false,
 *          keywords: []
 *        },
 *        tags: []
 *      },
 *      seoSlug: "rocket-man",
 *      slugs: [
 *        "rocket-man"
 *      ],
 *      status: "PUBLISHED",
 *      tagIds: [
 *        "a55b2c06-cbec-4d01-a8bb-cd7029056c75",
 *        "6d2e0a31-0f5e-4de8-8fd7-e45352bdfa67",
 *        "d2b0c02b-72c1-45af-ba58-3520cec9abe3"
 *      ],
 *      title: "Arise!",
 *      translations: []
 *    },
 *    {
 *      _id: "c8d50953-b31c-435f-82ec-a53d8bff87b4",
 *      _createdDate: "2023-08-13T13:51:23.823Z",
 *      categoryIds: [],
 *      changeOrigin: "PUBLISH",
 *      commentingEnabled: true,
 *      contentId: "65b0c1aa915ccdb13907fe1f",
 *      coverMedia: {
 *        custom: false,
 *        displayed: true,
 *        enabled: true,
 *        image: "wix:image://v1/75059a_3a3953ba8daa4a419562db4e61c7bee7~mv2.jpg#originWidth=2000&originHeight=3000"
 *      },
 *      editedDate: "2024-01-24T07:52:10.511Z",
 *      editingSessionId: "65b0c1aa915ccdb13907fe1f",
 *      excerpt: "If it wasn't for grit, we wouldn't succeed.",
 *      featured: false,
 *      firstPublishedDate: "2023-03-22T14:16:01.201Z",
 *      hashtags: [
 *        "vacation",
 *        "dream",
 *        "summer",
 *        "hashtag"
 *      ],
 *      hasUnpublishedChanges: false,
 *      language: "en",
 *      media: {
 *        custom: false,
 *        displayed: true,
 *        wixMedia: {
 *          image: "wix:image://v1/75059a_3a3953ba8daa4a419562db4e61c7bee7~mv2.jpg#originWidth=2000&originHeight=3000"
 *        }
 *      },
 *      memberId: "c00e8a5c-322b-4e77-8813-002e3ea7e811",
 *      minutesToRead: 12,
 *      mostRecentContributorId: "c00e8a5c-322b-4e77-8813-002e3ea7e811",
 *      paidContentParagraph: 4,
 *      pricingPlanIds: [],
 *      previewTextParagraph: 4,
 *      relatedPostIds: [],
 *      seoData: {
 *        settings: {
 *          preventAutoRedirect: false,
 *          keywords: []
 *        },
 *        tags: []
 *      },
 *      seoSlug: "the-things-we-carry-and-what-we-can-let-go-of",
 *      slugs: [
 *        "the-things-we-carry-and-what-we-can-let-go-of"
 *      ],
 *      status: "PUBLISHED",
 *      tagIds: [],
 *      title: "Grit is the special sauce.",
 *      translations: []
 *    }
 *  ],
 *  _limit: 50,
 *  _nextCursor: "",
 *  _originQuery: {
 *    filterTree: {
 *      $and: []
 *    },
 *    invalidArguments: [],
 *    encoder: {},
 *    transformationPaths: {},
 *    sort: [
 *      {
 *        fieldName: "title",
 *        order: "ASC"
 *      }
 *    ],
 *    paging: {},
 *    pagingMethod: "CURSOR",
 *    builderOptions: {
 *      cursorWithEmptyFilterAndSort: true
 *    }
 *  },
 *  _prevCursor: "",
 *  cursors: {
 *    next: "",
 *    prev: ""
 *  }
 * };
 */
```

## Query draft posts (export from backend code) 

```javascript
import { draftPosts } from 'wix-blog-backend';
import { webMethod, Permissions } from 'wix-web-module';

export const myQueryDraftPostsFunction = webMethod(
  Permissions.Admin,
  async () => {
    try {
      const queriedDraftPosts = await draftPosts.queryDraftPosts();
      console.log('Successfully queried draft posts:', queriedDraftPosts);
      return queriedDraftPosts;
    } catch (error) {
      console.error(error);
      // Handle the error
    }
  }
);

/* Promise resolves to:
 * {
 *   "filterTree": {
 *     "$and": []
 *   },
 *   "invalidArguments": [],
 *   "encoder": {},
 *   "transformationPaths": {},
 *   "sort": [],
 *   "paging": {},
 *   "pagingMethod": "CURSOR",
 *   "builderOptions": {
 *     "cursorWithEmptyFilterAndSort": true
 *   }
 * }
 */
```

## Query draft posts (dashboard page code) 

```javascript
import { draftPosts } from 'wix-blog-backend';

export async function myQueryDraftPostsFunction() {
    try {
      const queriedDraftPosts = await draftPosts.queryDraftPosts();
      console.log('Successfully queried draft posts:', queriedDraftPosts);
      return queriedDraftPosts;
    } catch (error) {
      console.error(error);
      // Handle the error
    }
  }

/* Promise resolves to:
 * {
 *   "filterTree": {
 *     "$and": []
 *   },
 *   "invalidArguments": [],
 *   "encoder": {},
 *   "transformationPaths": {},
 *   "sort": [],
 *   "paging": {},
 *   "pagingMethod": "CURSOR",
 *   "builderOptions": {
 *     "cursorWithEmptyFilterAndSort": true
 *   }
 * }
 */
```

---