Here is a solution.
//Your args to Gather post data.
$args = array(
\'post_title\' => \'My post\',
\'post_content\' => \'This is my post.\',
\'post_status\' => \'publish\',
\'post_author\' => 1,
);
//Retrieve Id back after new post is made.
$post_id = wp_insert_post( $args, true );
//Check for errors, before updating meta fields
if (is_wp_error($post_id)):
$errors = $post_id->get_error_messages();
foreach ($errors as $error):
//log errors
echo $error;
endforeach;
else:
//If updating WP meta
update_post_meta( $post_id, meta_key1, \'add this\');
update_post_meta( $post_id, meta_key2, \'add something\');
//if updating ACF meta
//update_field( \'meta_key1\', \'add this\', $post_id );
//update_field( \'meta_key2\', \'add something\', $post_id );
endif;