Setup

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

Copy
1
npm install @wix/blog

or

Copy
1
yarn add @wix/blog

Then import { draftPosts } from @wix/blog:

Copy
1
import { draftPosts } from '@wix/blog'
Was this helpful?
Yes
No

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.

Was this helpful?
Yes
No

bulkUpdateDraftPosts( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Updates multiple draft posts.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Blog
Manage Members
Manage Bookings Services and Settings
Read Members and Contacts - all read permissions
Read Members
Manage Members and Contacts - all permissions
Learn more about permission scopes.
Copy
function bulkUpdateDraftPosts(options: BulkUpdateDraftPostsOptions): Promise<BulkUpdateDraftPostsResponse>
Method Parameters
optionsBulkUpdateDraftPostsOptions
Options for updating multiple draft posts.
Returns
Return Type:Promise<BulkUpdateDraftPostsResponse>
Was this helpful?
Yes
No

createDraftPost( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Creates a draft post.

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

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Blog
Learn more about permission scopes.
Copy
function createDraftPost(draftPost: DraftPost, options: CreateDraftPostOptions): Promise<DraftPost>
Method Parameters
draftPostDraftPostRequired
Draft post to create.

optionsCreateDraftPostOptions
Options for creating a draft post.
Returns
Return Type:Promise<DraftPost>
Was this helpful?
Yes
No

deleteDraftPost( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

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.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Blog
Learn more about permission scopes.
Copy
function deleteDraftPost(draftPostId: string, options: DeleteDraftPostOptions): Promise<void>
Method Parameters
draftPostIdstringRequired
Draft post ID.

optionsDeleteDraftPostOptions
Options for deleting a draft post.
Returns
Return Type:Promise<void>
Was this helpful?
Yes
No

getDeletedDraftPost( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

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.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Blog
Learn more about permission scopes.
Copy
function getDeletedDraftPost(draftPostId: string): Promise<GetDeletedDraftPostResponse>
Method Parameters
draftPostIdstringRequired
Draft post ID.
Returns
Return Type:Promise<GetDeletedDraftPostResponse>
Was this helpful?
Yes
No

getDraftPost( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Gets a draft post by the provided ID.

Uses the provided draftPostId to retrieve a draft post.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Blog
Learn more about permission scopes.
Copy
function getDraftPost(draftPostId: string, options: GetDraftPostOptions): Promise<DraftPost>
Method Parameters
draftPostIdstringRequired
Draft post ID.

optionsGetDraftPostOptions
Options for getting a draft post.
Returns
Return Type:Promise<DraftPost>
Was this helpful?
Yes
No

listDeletedDraftPosts( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

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.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Blog
Learn more about permission scopes.
Copy
function listDeletedDraftPosts(options: ListDeletedDraftPostsOptions): Promise<ListDeletedDraftPostsResponse>
Method Parameters
optionsListDeletedDraftPostsOptions
Options for listing deleted draft posts.
Returns
Return Type:Promise<ListDeletedDraftPostsResponse>
Was this helpful?
Yes
No

listDraftPosts( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

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.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Blog
Learn more about permission scopes.
Copy
function listDraftPosts(options: ListDraftPostsOptions): Promise<ListDraftPostsResponse>
Method Parameters
optionsListDraftPostsOptions
Options for listing multiple draft posts.
Returns
Return Type:Promise<ListDraftPostsResponse>
Was this helpful?
Yes
No

publishDraftPost( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Publishes a specified draft post by ID. This creates a new post entity with the data from the draft post.

If the specified draft post was already published, the published post will be updated with the latest values from the draft post entity.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Blog
Learn more about permission scopes.
Copy
function publishDraftPost(draftPostId: string): Promise<PublishDraftPostResponse>
Method Parameters
draftPostIdstringRequired
Draft post ID.
Returns
Return Type:Promise<PublishDraftPostResponse>
Was this helpful?
Yes
No

queryDraftPosts( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

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.
PROPERTYSUPPORTED FILTERS & SORTING
_ideq(),ne(),hasSome(),ascending(),descending()
titleeq(),ne(),startsWith(),hasSome(),exists(),in(),ascending(),descending()
excerpteq(),ne(),startsWith(),hasSome(),exists(),in(),ascending(),descending()
featuredeq(),ne(),ascending(),descending()
categoryIdshasSome(),hasAll()
memberIdeq(),ne(),hasSome()
hashtagshasSome(),hasAll()
commentingEnabledeq(),ne(),ascending(),descending()
minutesToReadeq(),ne(),lt(),le(),gt(),ge(),in()
tagIdshasSome(),hasAll()
pricingPlanIdshasSome(),hasAll()
translationIdeq(),ne(),exists(),in()
languageeq(),ne(),hasSome(),exists(),in()
statuseq(),ne(),hasSome(),exists(),in(),ascending(),descending()
hasUnpublishedChangeseq(),ne(),ascending(),descending()
editedDateeq(),ne(),lt(),le(),gt(),ge(),in(),ascending(),descending()
scheduledPublishDateeq(),ne(),lt(),le(),gt(),ge(),in(),ascending(),descending()

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Blog
Learn more about permission scopes.
Copy
function queryDraftPosts(options: QueryDraftPostsOptions): DraftPostsQueryBuilder
Method Parameters
optionsQueryDraftPostsOptions
Options for querying draft posts.
Returns
Return Type:DraftPostsQueryBuilder
Was this helpful?
Yes
No

removeFromTrashBin( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Permanently deletes a draft post by the provided ID from the trash bin.

Uses the provided draftPostId to permanently delete a draft post from the trash bin. This action is permanent and cannot be reversed.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Blog
Learn more about permission scopes.
Copy
function removeFromTrashBin(draftPostId: string): Promise<void>
Method Parameters
draftPostIdstringRequired
Draft post ID.
Returns
Return Type:Promise<void>
Was this helpful?
Yes
No

restoreFromTrashBin( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

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

Uses the draftPostId to restore a deleted draft post from the trash bin.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Blog
Learn more about permission scopes.
Copy
function restoreFromTrashBin(draftPostId: string): Promise<RestoreFromTrashBinResponse>
Method Parameters
draftPostIdstringRequired
Draft post ID.
Returns
Return Type:Promise<RestoreFromTrashBinResponse>
Was this helpful?
Yes
No

updateDraftPost( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Updates a specified draft post.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Blog
Manage Members
Manage Bookings Services and Settings
Read Members and Contacts - all read permissions
Read Members
Manage Members and Contacts - all permissions
Learn more about permission scopes.
Copy
function updateDraftPost(_id: string, draftPost: UpdateDraftPost, options: UpdateDraftPostOptions): Promise<DraftPost>
Method Parameters
_idstringRequired
Draft post ID.

draftPostUpdateDraftPostRequired
Draft Post info.

optionsUpdateDraftPostOptions
Options for updating a draft post.
Returns
Return Type:Promise<DraftPost>
Was this helpful?
Yes
No