Login api returns error 400 Bad Request

I am using Javascript Api login method and getting the error 400 , below is my code -

window.Tawk_API.login({
    hash : 'hashcode',    // required
    userId : '1234',            // required
    name : 'My Name',
    email : 'test@gmail.com',
  }, function(error) {
  });

Response :
{“ok”:false,“error”:{“code”:“BadRequestError”,“message”:“”}}

Generating hash in PHP
hash_hmac(‘sha256’, $user_id.$tawk_api_key, $as_binary=true);

Any help would be appreciated!

Hello,
The error 400 in your JavaScript API login method suggests a bad request due to an incorrect hash. Ensure your PHP code generates the hash correctly by using hash_hmac(‘sha256’, $user_id . $tawk_api_key, false) to get a hexadecimal string. Verify the generated hash matches the userId and is correctly passed in the login method. Double-check for typos and confirm the API key is correct.