Issue with INSUFFICIENT_PRIVILEGES Error When Ending Zoom Meeting Using Meeting SDK

I am currently developing a platform where students can book classes with coaches. Upon booking, a Zoom meeting is created using a main Zoom account. The flow is as follows:

  1. Class Booking: A student books a class with a coach.
  2. Meeting Creation: A Zoom meeting is created using a main Zoom account via the Zoom API.
  3. Meeting Start: The meeting is started successfully on the frontend using the Zoom Meeting SDK.
  4. Meeting End: When trying to end the meeting, an INSUFFICIENT_PRIVILEGES error is encountered.

Implementation Details:

Frontend Code:
import React, { useEffect } from ‘react’;
import { ZoomMtgEmbedded } from ‘@zoomus/websdk/embedded’;

const ZoomMeetingComponent = () => {
const client = ZoomMtgEmbedded.createClient();

useEffect(() => {
const meetConfig = {
apiKey: ‘YOUR_API_KEY’,
signature: ‘YOUR_HOST_SIGNATURE’, // Ensure this signature is generated with role 1
meetingNumber: ‘YOUR_MEETING_NUMBER’,
userName: ‘YOUR_USER_NAME’,
passWord: ‘YOUR_PASSWORD’,
role: 1, // Ensure role is 1 for host
leaveUrl: ‘YOUR_LEAVE_URL’,
webEndpoint: ‘’
};

client.init({
  debug: true,
  zoomAppRoot: document.getElementById('zoom-meeting-container'),
  language: 'en-US',
  assetPath: '',
  webEndpoint: meetConfig.webEndpoint,
});

client.join({
  apiKey: meetConfig.apiKey,
  signature: meetConfig.signature,
  meetingNumber: meetConfig.meetingNumber,
  password: meetConfig.passWord,
  userName: meetConfig.userName,
});

}, );

const endMeeting = () => {
client.leaveMeeting({
success: function () {
console.log(‘Meeting ended successfully’);
},
error: function (error) {
console.error(‘End meeting error’, error);
}
});
};

return (


<div id=“zoom-meeting-container” style={{ width: ‘100%’, height: ‘100vh’ }}>

End Meeting

);
};

export default ZoomMeetingComponent;

Backend Code for Generating Signature:

async function generateZoomSignature (req, res) {
const errors = validationResult(req);
if (!errors.isEmpty()) {
return res.status(400).send(sendResponse(1003, messages[1003], false, errors.errors));
}
try {
const { meetingNumber, role } = req.body;
const iat = Math.round((new Date().getTime() - 30000) / 1000);
const exp = iat + 60 * 60 * 2
const oHeader = { alg: ‘HS256’, typ: ‘JWT’ }

const oPayload = {
sdkKey: config.zoomMeetingSdkClientId,
mn: meetingNumber,
role: role,
iat: iat,
exp: exp,
tokenExp: exp
}
const sHeader = JSON.stringify(oHeader)
const sPayload = JSON.stringify(oPayload)
const sdkJWT = jwt.sign(sPayload, config.zoomMeetingSdkClientSecret, { header: oHeader });

return res.send(sendResponse(1097, messages[1101], true, { signature: sdkJWT } ));
} catch (error) {
console.error(‘Error handling Zoom webhook event:’, error);
return res.status(500).send(sendResponse(1000, messages[1000], false));
}
}

Issue:
I am able to start the meeting successfully with the Zoom Meeting SDK, but when attempting to end the meeting, I receive the following error:

{type: ‘IMPROPER_MEETING_STATE’, reason: ‘closed’}

Context:

  • I have a main Zoom account from which all meetings are created.
  • The coach, who is starting the meeting, is not the same user who created the meeting.
  • I have also created a Zoom Meeting SDK account and use that account’s ID to start the meeting.

Question: Is this error occurring because the main host is a different user from the coach who is trying to end the meeting? If so, what is the recommended approach to resolve this issue? Can the host role be transferred programmatically, or is there another way to grant the necessary privileges to the coach?

Any guidance or suggestions on how to address this issue would be greatly appreciated.

@ast.mm103 you need to be host to end meeting.

To transfer host, the recipient needs to be licensed as well

@chunsiong.zoom
Thank you for the response.
How can I transfer the host role or ensure the recipient has the necessary license? My scenario involves coaches whose classes are booked by students. In this case, the coach should be the host, and the students should be participants.but the meetings are created by one main account which is not of any coach or student account.

@ast.mm103 get the recipient to sign up for license account?

@chunsiong.zoom
No. i am not signing up the coach or student.

@ast.mm103 The meeting should be created under the licensed account, and the same licensed account should be the one starting the meeting.

@chunsiong.zoom
I am creating the meeting with the main Zoom account, but the coach starts the meeting using the Zoom Meeting Web SDK in a React application. The coach is able to start the meeting successfully. However, when the coach clicks “Leave Meeting” or “End for All,” I receive the following error:

{type: ‘IMPROPER_MEETING_STATE’, reason: ‘closed’}

@chunsiong.zoom
Transfer Host Role Before Ending Meeting

  • Use the API to transfer the host role to the coach before they attempt to end the meeting.

const transferHostRole = async (meetingId, newHostId, accessToken) => {
try {
const response = await axios.patch(
https://api.zoom.us/v2/meetings/${meetingId}/status,
{ action: ‘update’, host_id: newHostId },
{ headers: { Authorization: Bearer ${accessToken} } }
);
console.log(‘Host role transferred successfully:’, response.data);
} catch (error) {
console.error(‘Error transferring host role:’, error.response ? error.response.data : error.message);
}
};

// Usage example before ending the meeting
const endMeeting = async () => {
await transferHostRole(‘YOUR_MEETING_ID’, ‘NEW_HOST_ID’, ‘YOUR_ACCESS_TOKEN’);
client.leaveMeeting({
success: function () {
console.log(‘Meeting ended successfully’);
},
error: function (error) {
console.error(‘End meeting error’, error);
}
});
};

can i do this will it work ?

@ast.mm103

I’m not sure what you are trying to do with the code above. There is no such method to transfer host via the REST API.

Sharing license is not allowed anyway.

@chunsiong.zoom

How can I fix this error:

{type: 'IMPROPER_MEETING_STATE', reason: 'closed'}

In my scenario, students join the meetings, and coaches, acting as hosts, start the meetings. Both students and coaches can start the meeting without any issues. The meetings are created using a licensed Zoom account, not the student or coach accounts, and neither students nor coaches are signed up on Zoom. However, when trying to end the meeting, I encounter the above error.

@chunsiong.zoom
i was trying to do this with REST api to make coach as a host permission that now he is host and if he becomes the host then he will not get the above error.
i am not sure will this works so i asked.

@ast.mm103

The proper way is to get the host to start the meeting. you can start the meeting by using the ZAK token to authenticate yourself as host.

Coaches should be licensed host.

The API which you have shared does not have the capabilities which you have mentioned.

@chunsiong.zoom
i am using ZAKtoken to start the meeting and meeting is starting successfully before also without ZAK token from both either coach or student. but i got the issue when i end the meeting for a coach.

@chunsiong.zoom
can u provide some refference ?

@ast.mm103 I’ll close this thread for now.

You will need a host to start the meeting and end the meeting. Anything else is not adhering to the terms and conditions under normal licensing.

There reference docs for update meeting is here

If you are build a solution which requires this use case, I would recommend you to sign up for an ISV account to support your scenario