Capturing the role ID

A user profile includes information such as country code, channel settings, client integration, etc.. To create a user profile, you'll make a POST request to the Create a user's profile endpoint with your created payload. Our code walks through a scenario where a form submission is used to send our POST request. We'll capture the role_id to pass along in our user profile object.

Make fetch call for roles and filter through to find matching role ID sample

const [roleId, setRoleId] = useState();
const [roles, setRoles] = useState([]);
const getRoles = async => {
    const data = await fetch("https://api.zoom.us/v2/contact_center/roles", {
    headers: {
        Authorization: "Bearer YOUR_SECRET_TOKEN",
    },
    });
    const rolesData = (await data.json()).roles;
    setRoles(rolesData);
    setRoleId(roles.find((role) => role.role_name === "Agent").role_id);
    }