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

This function requires elevated permissions and runs only on the backend and on dashboard pages.

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-backend"; import { webMethod, Permissions } from "wix-web-module"; import { elevate } from "wix-auth"; // Sample draftPostId value: "2b36fbd0-f87a-43ce-ad11-e73d354b0072" const elevatedDeleteDraftPost = elevate(draftPosts.deleteDraftPost); export const myDeleteDraftPostFunction = webMethod( Permissions.Admin, async (draftPostId) => { try { await elevatedDeleteDraftPost(draftPostId); console.log( "Successfully deleted the following draft post:", draftPostId, ); return; } catch (error) { console.error(error); // Handle the error } }, ); // Promise returns void
Errors

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

Did this help?