> 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`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # DeleteDraftPost # Package: blog # Namespace: DraftPostService # Method link: https://dev.wix.com/docs/api-reference/business-solutions/blog/draft-posts/delete-draft-post.md ## Permission Scopes: Manage Blog: SCOPE.DC-BLOG.MANAGE-BLOG ## Introduction Moves a draft post to the trash bin. A published post can also be deleted by the `post.id`. See the [Posts API](https://dev.wix.com/docs/rest/business-solutions/blog/posts-stats/post-object.md) for more information about posts. To permanently delete a post bypassing the trash bin, set the `permanent` field value to `true`. The post can't be restored after this. --- ## REST API ### Schema ``` Method: deleteDraftPost Description: Moves a draft post to the trash bin. A published post can also be deleted by the `post.id`. See the [Posts API](https://dev.wix.com/docs/rest/business-solutions/blog/posts-stats/post-object.md) for more information about posts. To permanently delete a post bypassing the trash bin, set the `permanent` field value to `true`. The post can't be restored after this. URL: https://www.wixapis.com/blog/v3/draft-posts/{draftPostId} Method: DELETE # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: draftPostId Method parameters: param name: draftPostId | type: none | required: true query param name: permanent | type: permanent | description: Whether to bypass the trash bin and delete the post permanently. Default: `false` Return type: DeleteDraftPostResponse EMPTY-OBJECT {} ``` ### Examples ### DeleteDraftPost ```curl ~~~cURL curl -X DELETE 'https://www.wixapis.com/blog/v3/draft-posts/0eed85df-8332-4d7b-9184-164a482f0b41' \ -H 'Content-Type: application/json' \ -H 'Authorization: ' ~~~ ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.blog.DraftPostService.deleteDraftPost(draftPostId, options) Description: Moves a draft post to the trash bin. A published post can also be deleted by the `post.id`. See the [Posts API](https://dev.wix.com/docs/rest/business-solutions/blog/posts-stats/post-object.md) for more information about posts. To permanently delete a post bypassing the trash bin, set the `permanent` field value to `true`. The post can't be restored after this. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: draftPostId Method parameters: param name: draftPostId | type: string | description: Draft post GUID. | required: true param name: options | type: DeleteDraftPostOptions none - name: permanent | type: boolean | description: Whether to bypass the trash bin and delete the post permanently. Default: `false` Return type: PROMISE EMPTY-OBJECT {} ``` ### Examples ### Delete a draft post (with elevated permissions) ```javascript import { draftPosts } from '@wix/blog'; import { auth } from '@wix/essentials'; const elevatedDeleteDraftPost = auth.elevate(draftPosts.deleteDraftPost); // Sample draftPostId value: "2b36fbd0-f87a-43ce-ad11-e73d354b0072" export async function myDeleteDraftPostFunction(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 ``` ### Delete a draft post ```javascript import { draftPosts } from '@wix/blog'; // Sample draftPostId value: "2b36fbd0-f87a-43ce-ad11-e73d354b0072" export async function myDeleteDraftPostFunction(draftPostId) { try { await draftPosts.deleteDraftPost(draftPostId); console.log('Successfully deleted the following draft post:', draftPostId); return; } catch (error) { console.error(error); // Handle the error } } // Promise returns void ``` ### Delete a draft post using options (with elevated permissions) ```javascript import { draftPosts } from '@wix/blog'; import { auth } from '@wix/essentials'; /* * Sample draftPostId value: "d1ce1aad-edcc-43a8-b36f-d6c4ca76ef70"; * * Sample options value: * { * permanent: true * } */ const elevatedDeleteDraftPost = auth.elevate(draftPosts.deleteDraftPost); export async function myDeleteDraftPostFunction(draftPostId, options) { try { await elevatedDeleteDraftPost(draftPostId, options); console.log('Permanently deleted the following draft post:', draftPostId); return; } catch (error) { console.error(error); // Handle the error } } // Promise returns void ``` ### Delete a draft post using options ```javascript import { draftPosts } from '@wix/blog'; /* * Sample draftPostId value: "d1ce1aad-edcc-43a8-b36f-d6c4ca76ef70"; * * Sample options value: * { * permanent: true * } */ export async function myDeleteDraftPostFunction(draftPostId, options) { try { await draftPosts.deleteDraftPost(draftPostId, options); console.log('Permanently deleted the following draft post:', draftPostId); return; } catch (error) { console.error(error); // Handle the error } } // Promise returns void ``` ### deleteDraftPost (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { draftPosts } from '@wix/blog'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { draftPosts }, // Include the auth strategy and host as relevant }); async function deleteDraftPost(draftPostId,options) { const response = await myWixClient.draftPosts.deleteDraftPost(draftPostId,options); }; ``` ---