You must use wp_delete_post()
with second parameter set to true
. The post will be completely deleted, not trashed.
// Use $args to get the pages you created previously
// See https://developer.wordpress.org/reference/functions/get_pages/
$pages = get_pages( $args );
if( $pages ) {
foreach( $pages as $page ) {
wp_delete_post( $page->ID, true );
}
}
After that, you can use wp_insert_post()
to create a new post with a slug previously used.
It may worth to consider to update the post instead of delete and create a new one.