Delete Posts Trough CLI


There’s a way to delete all posts using ghost-cli or API?

If not exist something like it, Can I delete all items of a specific table to delete all posts?


Are you trying to delete all posts or all content? If you’re trying to delete all your content, there’s an option to do that via the labs (/ghost/#/settings/labs).

If you’re looking to delete just posts, it might be easier to do that via the API.

// This code has not been tested. Use at your own risk!
const api = new GhostAdminAPI({
  url: 'http://localhost:2368',
  version: "v3"

const {posts} = await api.posts.browse({limit: 'all'});

for (const post of posts) {
  console.log('Deleting %s - %s',, post.title);
  await api.posts.delete({id:})

Thanks for your reply, @vikaspotluri123!

I’m trying to delete all posts. I’m gonna test it!

I did create an entire IaC(Terraform + AWS) to provide and configure Ghost. I will create a serverless function to delete all posts for admin users. To do it, I will use lambda.

aws lambda invoke --function-name DeleteAllPosts --payload '{“admin_api_key”:“YOUR_ADMIN_API_KEY”} output.txt