Modify Post URL Programmatically

When you are using wp_insert_post() there is a param post_name.
If you do not pass it then it will sanitise your post title and update.

You only have control to add post_name but the full URL is created based on your Permalink settings.

tech