Access token issue

I got stucked when i try send announce with twitch helix api, always got this error:

Error sending Twitch announcement: {
 error: 'Unauthorized',
 status: 401,
 message: 'incorrect user authorization'

I took the token from the link:

async function sendTwitchAnnouncement(message: string) {
  const url = ``;
  const accessToken = "tokenFromLink";
  const headers = {
    'Authorization': `Bearer ${accessToken}`,
    'Client-Id': 'myAppClientId',

  const body = {
    "broadcaster_id": "channelNickname",
    "moderator_id": "botNickname",
    "message": message,
    "color": "primary"

  try {
    await, body, { headers });
    console.log("Twitch announcement sent successfully");
  } catch (error) {
    console.error("Error sending Twitch announcement:",;

thanks a lot for any help c:

These should be numerics, the ID’s of the users in question

So to use the API to send an announcments

as barrycarlyon on the cohhcarnage channel I use 15185913 and 26610234 respectively, not the wordy names


  const body = {
    "broadcaster_id": "26610234",
    "moderator_id": "15185913",
    "message": message,
    "color": "primary"

Thanks for answer
Where can i get numerics channel id’s?

Get Users will let you convert any username to a ID

The userID for the token can be gotten from here of the Validate Token endpoint

Wow, i love you.
Very grateful to you <3

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.