This suggests you didn’t specify a username and valid oAuth token to login to chat with.
And/or you used a Client Credentials token that doesn’t represent a user.
Therefore you are not logged in as a user whom can send messages.
You need to generate and user a user token with the needed chat scopes.
If you call validate
And the response does not have a user_id then your token is of the wrong type.