I have an issue with channel.moderate erroring with code 403 Forbidden.
My code is using token/clientid from the moderating account and also in the moderator userid. Broadcaster ID is the broadcaster the account is mod for. Yes, the moderating account has all scopes needed for this subscription.
const subTypes = [
{
type: "channel.moderate",
version: "1",
token: twitchAccessToken1,
clientid: mod_clientid,
condition: {
broadcaster_user_id: broadcasterId,
moderator_user_id: "1373486129",
},
},
{
type: "channel.ban",
version: "1",
token: twitchAccessToken,
clientid: clientid,
condition: { broadcaster_user_id: broadcasterId },
},
{
type: "channel.unban",
version: "1",
token: twitchAccessToken,
clientid: clientid,
condition: { broadcaster_user_id: broadcasterId },
},
{
type: "channel.unban_request.create",
version: "1",
token: twitchAccessToken,
clientid: clientid,
condition: { broadcaster_user_id: broadcasterId, moderator_user_id: broadcasterId },
},
{
type: "channel.unban_request.resolve",
version: "1",
token: twitchAccessToken,
clientid: clientid,
condition: { broadcaster_user_id: broadcasterId, moderator_user_id: broadcasterId },
},
];
for (const sub of subTypes) {
console.log(`📡 Attempting to subscribe: ${sub.type} (v${sub.version})`);
console.log("➡️ Condition:", JSON.stringify(sub.condition, null, 2));
try {
const res = await fetch("https://api.twitch.tv/helix/eventsub/subscriptions", {
method: "POST",
headers: {
Authorization: `Bearer ${sub.token}`,
"Client-Id": sub.clientid,
"Content-Type": "application/json",
},
body: JSON.stringify({
type: sub.type,
version: sub.version,
condition: sub.condition,
transport: {
method: "websocket",
session_id: sessionId,
},
}),
});
const result = await res.json();
if (!res.ok) {
console.error(`❌ Failed to subscribe to ${sub.type} (v${sub.version}):`, result);
} else {
console.log(`âś… Successfully subscribed to ${sub.type} (v${sub.version})`);
// console.log("🔹 Twitch Response:", JSON.stringify(result, null, 2));
}
} catch (err) {
console.error(`⚠️ Error subscribing to ${sub.type}:`, err);
}
}
I keep getting this error and all other subs work.
📡 Attempting to subscribe: channel.moderate (v1)
➡️ Condition: {
"broadcaster_user_id": "1325565884",
"moderator_user_id": "1373486129"
}
❌ Failed to subscribe to channel.moderate (v1): {
error: 'Forbidden',
status: 403,
message: 'subscription missing proper authorization'
}
I am using this to use for mod actions logs.