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.
To use the DraftPosts API, install the @wix/blog
package using npm or Yarn:
or
Then import { draftPosts }
from @wix/blog
:
Creates multiple draft posts.
function bulkCreateDraftPosts(
draftPosts: Array<DraftPost>,
options: BulkCreateDraftPostsOptions,
): Promise<BulkCreateDraftPostsResponse>;
Draft posts to create.
Options for creating multiple draft posts.
import { draftPosts } from "@wix/blog";
async function bulkCreateDraftPosts(draftPosts, options) {
const response = await draftPosts.bulkCreateDraftPosts(draftPosts, options);
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Deletes multiple draft posts.
function bulkDeleteDraftPosts(
postIds: Array<string>,
options: BulkDeleteDraftPostsOptions,
): Promise<BulkDeleteDraftPostsResponse>;
Post IDs.
Options for deleting multiple draft posts.
import { draftPosts } from "@wix/blog";
async function bulkDeleteDraftPosts(postIds, options) {
const response = await draftPosts.bulkDeleteDraftPosts(postIds, options);
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Updates multiple draft posts.
function bulkUpdateDraftPosts(
options: BulkUpdateDraftPostsOptions,
): Promise<BulkUpdateDraftPostsResponse>;
Options for updating multiple draft posts.
import { draftPosts } from "@wix/blog";
async function bulkUpdateDraftPosts(options) {
const response = await draftPosts.bulkUpdateDraftPosts(options);
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Creates a draft post.
The draft post's memberId
is required for third-party apps.
function createDraftPost(
draftPost: DraftPost,
options: CreateDraftPostOptions,
): Promise<CreateDraftPostResponse>;
Draft post to create.
Options for creating a draft post.
import { draftPosts } from "@wix/blog";
async function createDraftPost(draftPost, options) {
const response = await draftPosts.createDraftPost(draftPost, options);
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
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.
function deleteDraftPost(
draftPostId: string,
options: DeleteDraftPostOptions,
): Promise<void>;
Draft post ID.
Options for deleting a draft post.
import { draftPosts } from "@wix/blog";
async function deleteDraftPost(draftPostId, options) {
const response = await draftPosts.deleteDraftPost(draftPostId, options);
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
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.
function getDeletedDraftPost(
draftPostId: string,
): Promise<GetDeletedDraftPostResponse>;
Draft post ID.
import { draftPosts } from "@wix/blog";
async function getDeletedDraftPost(draftPostId) {
const response = await draftPosts.getDeletedDraftPost(draftPostId);
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Gets a draft post by the provided ID.
Uses the provided draftPostId
to retrieve a draft post.
function getDraftPost(
draftPostId: string,
options: GetDraftPostOptions,
): Promise<GetDraftPostResponse>;
Draft post ID.
Options for getting a draft post.
import { draftPosts } from "@wix/blog";
async function getDraftPost(draftPostId, options) {
const response = await draftPosts.getDraftPost(draftPostId, options);
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
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
.function listDeletedDraftPosts(
options: ListDeletedDraftPostsOptions,
): Promise<ListDeletedDraftPostsResponse>;
Options for listing deleted draft posts.
import { draftPosts } from "@wix/blog";
async function listDeletedDraftPosts(options) {
const response = await draftPosts.listDeletedDraftPosts(options);
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
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
.function listDraftPosts(
options: ListDraftPostsOptions,
): Promise<ListDraftPostsResponse>;
Options for listing multiple draft posts.
import { draftPosts } from "@wix/blog";
async function listDraftPosts(options) {
const response = await draftPosts.listDraftPosts(options);
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.