Generally a code flow token is valid for 4 hours and a implicit token valid for 60 days.
TTGcom tends to provide an implicit token, so the token you get shouldn’t be dead yet.
Check the body of the response when deleting as the HTTP code is only half the info and the body describes the error
This soulds like you gave generated an app access/client credentials token rather than a usertoken.
For a chat bot you would generally use Getting OAuth Access Tokens | Twitch Developers
Which provides a code to exchange for an token and refresh token then when the token expires after around 4 hours, you use the refresh token to get a new token to operate with.
So
Check the body of the respose.
For a delete message this could be
- invalid msg id
- wrong token type
- the user in the token isn’t the user in the query string params
- the user in the token (and this the user in the query string) isn’t a moderator on the channel
The body will describe the problem.
The HTTP code if half the information needed to debug the issue