Error invalid parameters with REST API


Trying to use the WordPress API to create a blog post with tags/categories, etc. but running into some errors. I am running the PHP code below outside of my WordPress instance and get the following:

CODE

function CreatePost($title, $content, $tag){
    $username = 'username';
    $password = 'password';
    $category = 'test category words name test';
    $rest_api_url = "https://www.urlurlurlurl.com/wp-json/wp/v2/posts";

$data_string = json_encode((
    'title'    => $title,
    'content'  => $content,
    'status'   => 'publish',
    'tags' => 'test tag',
    'category' => $category
));


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $rest_api_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);

curl_setopt($ch, CURLOPT_HTTPHEADER, (
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data_string),
    'Authorization: Basic ' . base64_encode($username . ':' . $password),
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$result = curl_exec($ch);
echo $result;
curl_close($ch);
}

ERROR

{"code":"rest_invalid_param","message":"Invalid parameter(s): tags","data":{"status":400,"params":{"tags":"tags(0) is not of type integer."}}}