You can add it this way, you send the tags separated by commas.
// text add
$my_post = array();
$my_post['post_title'] = 'title';
$my_post['post_content'] = 'text.';
$my_post['post_status'] = 'publish';
$my_post['post_author'] = 1;
$my_post['post_category'] = array(8,39);
//database add
wp_insert_post( $my_post );