About Draft Posts

The Draft Posts API gives site members the ability to access and manage draft blog posts. A draft post is an unpublished article written for a blog by site collaborators.

The size limit of a single draft blog post is 400KB.

Note: For translations and multilingual support, install the Wix Multilingual app.

Did this help?

Setup

To use the DraftPosts API, install the @wix/blog package using npm or Yarn:

Copy

or

Copy

Then import { draftPosts } from @wix/blog:

Copy
Did this help?

bulkCreateDraftPosts( )


Creates multiple draft posts.

Authentication
  • When developing websites or building an app with Blocks, this method may require elevated permissions, depending on the identity of the user calling it and the calling user’s permissions.
  • When building apps without Blocks or for headless projects, you can only call this method directly when authenticated as a Wix app or Wix user identity. When authenticated as a different identity, you can call this method using elevation.
  • Elevation permits users to call methods they typically cannot access. Therefore, you should only use it intentionally and securely.
Permissions
Manage Blog
Learn more about app permissions.
Method Declaration
Copy
function bulkCreateDraftPosts(
  draftPosts: Array<DraftPost>,
  options: BulkCreateDraftPostsOptions,
): Promise<BulkCreateDraftPostsResponse>;
Method Parameters
draftPostsArray<DraftPost>Required

Draft posts to create.


optionsBulkCreateDraftPostsOptions

Options for creating multiple draft posts.

Returns
Return Type:Promise<BulkCreateDraftPostsResponse>
JavaScript
import { draftPosts } from "@wix/blog"; async function bulkCreateDraftPosts(draftPosts, options) { const response = await draftPosts.bulkCreateDraftPosts(draftPosts, options); }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

bulkDeleteDraftPosts( )


Deletes multiple draft posts.

Authentication
  • When developing websites or building an app with Blocks, this method may require elevated permissions, depending on the identity of the user calling it and the calling user’s permissions.
  • When building apps without Blocks or for headless projects, you can only call this method directly when authenticated as a Wix app or Wix user identity. When authenticated as a different identity, you can call this method using elevation.
  • Elevation permits users to call methods they typically cannot access. Therefore, you should only use it intentionally and securely.
Permissions
Manage Blog
Learn more about app permissions.
Method Declaration
Copy
function bulkDeleteDraftPosts(
  postIds: Array<string>,
  options: BulkDeleteDraftPostsOptions,
): Promise<BulkDeleteDraftPostsResponse>;
Method Parameters
postIdsArray<string>Required

Post IDs.


optionsBulkDeleteDraftPostsOptions

Options for deleting multiple draft posts.

Returns
Return Type:Promise<BulkDeleteDraftPostsResponse>
JavaScript
import { draftPosts } from "@wix/blog"; async function bulkDeleteDraftPosts(postIds, options) { const response = await draftPosts.bulkDeleteDraftPosts(postIds, options); }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

bulkUpdateDraftPosts( )


Updates multiple draft posts.

Authentication
  • When developing websites or building an app with Blocks, this method may require elevated permissions, depending on the identity of the user calling it and the calling user’s permissions.
  • When building apps without Blocks or for headless projects, you can only call this method directly when authenticated as a Wix app or Wix user identity. When authenticated as a different identity, you can call this method using elevation.
  • Elevation permits users to call methods they typically cannot access. Therefore, you should only use it intentionally and securely.
Permissions
Manage Blog
Learn more about app permissions.
Method Declaration
Copy
function bulkUpdateDraftPosts(
  options: BulkUpdateDraftPostsOptions,
): Promise<BulkUpdateDraftPostsResponse>;
Method Parameters
optionsBulkUpdateDraftPostsOptions

Options for updating multiple draft posts.

Returns
Return Type:Promise<BulkUpdateDraftPostsResponse>
JavaScript
import { draftPosts } from "@wix/blog"; async function bulkUpdateDraftPosts(options) { const response = await draftPosts.bulkUpdateDraftPosts(options); }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

createDraftPost( )


Creates a draft post.

The draft post's memberId is required for third-party apps.

Authentication
  • When developing websites or building an app with Blocks, this method may require elevated permissions, depending on the identity of the user calling it and the calling user’s permissions.
  • When building apps without Blocks or for headless projects, you can only call this method directly when authenticated as a Wix app or Wix user identity. When authenticated as a different identity, you can call this method using elevation.
  • Elevation permits users to call methods they typically cannot access. Therefore, you should only use it intentionally and securely.
Permissions
Manage Blog
Learn more about app permissions.
Method Declaration
Copy
function createDraftPost(
  draftPost: DraftPost,
  options: CreateDraftPostOptions,
): Promise<CreateDraftPostResponse>;
Method Parameters
draftPostDraftPostRequired

Draft post to create.


optionsCreateDraftPostOptions

Options for creating a draft post.

Returns
Return Type:Promise<CreateDraftPostResponse>
JavaScript
import { draftPosts } from "@wix/blog"; async function createDraftPost(draftPost, options) { const response = await draftPosts.createDraftPost(draftPost, options); }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

deleteDraftPost( )


Moves a draft post with the provided ID to the trash bin. A published post can also be deleted by its provided draftPostId.

The optional permanent field enables you to delete a post permanently, bypassing the trash bin. When a draft post is deleted this way, it can't be restored.

Authentication
  • When developing websites or building an app with Blocks, this method may require elevated permissions, depending on the identity of the user calling it and the calling user’s permissions.
  • When building apps without Blocks or for headless projects, you can only call this method directly when authenticated as a Wix app or Wix user identity. When authenticated as a different identity, you can call this method using elevation.
  • Elevation permits users to call methods they typically cannot access. Therefore, you should only use it intentionally and securely.
Permissions
Manage Blog
Learn more about app permissions.
Method Declaration
Copy
function deleteDraftPost(
  draftPostId: string,
  options: DeleteDraftPostOptions,
): Promise<void>;
Method Parameters
draftPostIdstringRequired

Draft post ID.


optionsDeleteDraftPostOptions

Options for deleting a draft post.

JavaScript
import { draftPosts } from "@wix/blog"; async function deleteDraftPost(draftPostId, options) { const response = await draftPosts.deleteDraftPost(draftPostId, options); }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

getDeletedDraftPost( )


Gets a deleted draft post from the trash bin by the provided ID.

Uses the provided draftPostId to retrieve a previously deleted draft post from the trash bin.

Authentication
  • When developing websites or building an app with Blocks, this method may require elevated permissions, depending on the identity of the user calling it and the calling user’s permissions.
  • When building apps without Blocks or for headless projects, you can only call this method directly when authenticated as a Wix app or Wix user identity. When authenticated as a different identity, you can call this method using elevation.
  • Elevation permits users to call methods they typically cannot access. Therefore, you should only use it intentionally and securely.
Permissions
Manage Blog
Learn more about app permissions.
Method Declaration
Copy
function getDeletedDraftPost(
  draftPostId: string,
): Promise<GetDeletedDraftPostResponse>;
Method Parameters
draftPostIdstringRequired

Draft post ID.

Returns
Return Type:Promise<GetDeletedDraftPostResponse>
JavaScript
import { draftPosts } from "@wix/blog"; async function getDeletedDraftPost(draftPostId) { const response = await draftPosts.getDeletedDraftPost(draftPostId); }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

getDraftPost( )


Gets a draft post by the provided ID.

Uses the provided draftPostId to retrieve a draft post.

Authentication
  • When developing websites or building an app with Blocks, this method may require elevated permissions, depending on the identity of the user calling it and the calling user’s permissions.
  • When building apps without Blocks or for headless projects, you can only call this method directly when authenticated as a Wix app or Wix user identity. When authenticated as a different identity, you can call this method using elevation.
  • Elevation permits users to call methods they typically cannot access. Therefore, you should only use it intentionally and securely.
Permissions
Manage Blog
Learn more about app permissions.
Method Declaration
Copy
function getDraftPost(
  draftPostId: string,
  options: GetDraftPostOptions,
): Promise<GetDraftPostResponse>;
Method Parameters
draftPostIdstringRequired

Draft post ID.


optionsGetDraftPostOptions

Options for getting a draft post.

Returns
Return Type:Promise<GetDraftPostResponse>
JavaScript
import { draftPosts } from "@wix/blog"; async function getDraftPost(draftPostId, options) { const response = await draftPosts.getDraftPost(draftPostId, options); }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

listDeletedDraftPosts( )


Retrieves a list of up to 100 deleted draft posts.

List Deleted Draft Posts runs with these defaults, which you can override:

  • editedDate is sorted in descending order. In this case,editedDate implies the date the post was deleted.
  • paging.limit is 50.
  • paging.offset is 0.
Authentication
  • When developing websites or building an app with Blocks, this method may require elevated permissions, depending on the identity of the user calling it and the calling user’s permissions.
  • When building apps without Blocks or for headless projects, you can only call this method directly when authenticated as a Wix app or Wix user identity. When authenticated as a different identity, you can call this method using elevation.
  • Elevation permits users to call methods they typically cannot access. Therefore, you should only use it intentionally and securely.
Permissions
Manage Blog
Learn more about app permissions.
Method Declaration
Copy
function listDeletedDraftPosts(
  options: ListDeletedDraftPostsOptions,
): Promise<ListDeletedDraftPostsResponse>;
Method Parameters
optionsListDeletedDraftPostsOptions

Options for listing deleted draft posts.

Returns
Return Type:Promise<ListDeletedDraftPostsResponse>
JavaScript
import { draftPosts } from "@wix/blog"; async function listDeletedDraftPosts(options) { const response = await draftPosts.listDeletedDraftPosts(options); }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

listDraftPosts( )


Retrieves a list of up to 100 draft posts per request.

List Draft Posts runs with these defaults, which you can override:

  • editedDate is sorted in descending order.
  • paging.limit is 50.
  • paging.offset is 0.
Authentication
  • When developing websites or building an app with Blocks, this method may require elevated permissions, depending on the identity of the user calling it and the calling user’s permissions.
  • When building apps without Blocks or for headless projects, you can only call this method directly when authenticated as a Wix app or Wix user identity. When authenticated as a different identity, you can call this method using elevation.
  • Elevation permits users to call methods they typically cannot access. Therefore, you should only use it intentionally and securely.
Permissions
Manage Blog
Learn more about app permissions.
Method Declaration
Copy
function listDraftPosts(
  options: ListDraftPostsOptions,
): Promise<ListDraftPostsResponse>;
Method Parameters
optionsListDraftPostsOptions

Options for listing multiple draft posts.

Returns
Return Type:Promise<ListDraftPostsResponse>
JavaScript
import { draftPosts } from "@wix/blog"; async function listDraftPosts(options) { const response = await draftPosts.listDraftPosts(options); }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?