# How to call Zoom VideoSDK Session API to use in-session events controls

**URL:** <https://devforum.zoom.us/t/how-to-call-zoom-videosdk-session-api-to-use-in-session-events-controls/101045>\
**Category:** Web\
**Tags:** api, video-sdk\
**Created:** [January 2, 2024, 11:12am UTC](https://devforum.zoom.us/t/how-to-call-zoom-videosdk-session-api-to-use-in-session-events-controls/101045 "2024-01-02T11:12:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![vishwajeetbhosale](https://avatars.discourse-cdn.com/v4/letter/v/f19dbf/32.png) [@vishwajeetbhosale](https://devforum.zoom.us/u/vishwajeetbhosale)\
**Post date:** [January 2, 2024, 11:12am UTC](https://devforum.zoom.us/t/how-to-call-zoom-videosdk-session-api-to-use-in-session-events-controls/101045/1 "2024-01-02T11:12:47Z")

</div>

**Description**  
I want to know how to call below API mostly headers in .Net Core

\*\* Use in-session events controls\*\* for **‘user.invite.room\_system\_callout’** method.  
PATCH /videosdk/sessions/{sessionId}/events

**Browser Console Error**  
NA

**Which Web Video SDK version?**  
Zoom Video SDK UIToolKit 1.9.8

**Video SDK Code Snippets**

**Additional context**  
API calling steps required

---

<div class="post-metadata">

**Author:** ![kellyjandrews](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/kellyjandrews/32/51599_2.png) [@kellyjandrews](https://devforum.zoom.us/u/kellyjandrews)\
**Post date:** [January 2, 2024, 4:59pm UTC](https://devforum.zoom.us/t/how-to-call-zoom-videosdk-session-api-to-use-in-session-events-controls/101045/2 "2024-01-02T16:59:54Z")

</div>

For details regarding making API calls with the VideoSDK, refer to this section in the documentation - [Make API requests](https://developers.zoom.us/docs/video-sdk/api-request/)

If you are using the UI Toolkit, I believe you will also need the Web VideoSDK as well.

Let me know if this helps 🙂

---

<div class="post-metadata">

**Author:** ![vishwajeetbhosale](https://avatars.discourse-cdn.com/v4/letter/v/f19dbf/32.png) [@vishwajeetbhosale](https://devforum.zoom.us/u/vishwajeetbhosale)\
**Post date:** [January 4, 2024, 9:53am UTC](https://devforum.zoom.us/t/how-to-call-zoom-videosdk-session-api-to-use-in-session-events-controls/101045/3 "2024-01-04T09:53:22Z")

</div>

Hey @kellyjandrews. I have referred the shared link and it is giving me an error.

**StatusCode:** Unauthorized  
{“code”:124,“message”:“Invalid access token.”}

Can you please look into this on some priority.

Thanks

---

<div class="post-metadata">

**Author:** ![kellyjandrews](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/kellyjandrews/32/51599_2.png) [@kellyjandrews](https://devforum.zoom.us/u/kellyjandrews)\
**Post date:** [January 4, 2024, 1:44pm UTC](https://devforum.zoom.us/t/how-to-call-zoom-videosdk-session-api-to-use-in-session-events-controls/101045/4 "2024-01-04T13:44:13Z")

</div>

Invalid Access Token can represent a couple of different scenarios - but most typically is due to using the incorrect Key/Secret.

In your VideoSDK developer account, be sure you are using the API key/secret to call the API, and not the SDK key/secret.

---

<div class="post-metadata">

**Author:** ![vishwajeetbhosale](https://avatars.discourse-cdn.com/v4/letter/v/f19dbf/32.png) [@vishwajeetbhosale](https://devforum.zoom.us/u/vishwajeetbhosale)\
**Post date:** [January 4, 2024, 2:13pm UTC](https://devforum.zoom.us/t/how-to-call-zoom-videosdk-session-api-to-use-in-session-events-controls/101045/5 "2024-01-04T14:13:31Z")

</div>

Hey @kellyjandrews ,  
I’m sure on using API and API secret, so what will be the other possible reason.  
Also I have used JWT token which is available in Video SDK APP, please refer below image

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/8/4/844000bb603f465f63b62faa0802456716159470.png)

* * *

Code to generate the token is as below, using .Net Core C#.

`using System.IdentityModel.Tokens.Jwt;`

```auto
public string GetVideoSDKAPIToken(string apiKey, string apiSecret, int accessTokenValidityInMinutes = 120, int tokenValidityInMinutes = -1)
        {
            DateTime now = DateTime.UtcNow;

            if (tokenValidityInMinutes <= 0)
            {
                tokenValidityInMinutes = accessTokenValidityInMinutes;
            }

            int tsNow = (int)(now - new DateTime(1970, 1, 1)).TotalSeconds;
            int tsAccessExp = (int)(now.AddMinutes(accessTokenValidityInMinutes) - new DateTime(1970, 1, 1)).TotalSeconds;
            int tsTokenExp = (int)(now.AddMinutes(tokenValidityInMinutes) - new DateTime(1970, 1, 1)).TotalSeconds;

            return GenrateVideoSDKAPIToken(apiSecret, new JwtPayload
                {
                    { "iss", apiKey },
                    { "exp", tsAccessExp },
                    { "iat", tsNow }                                        
            });
        }
		
public static string GenrateVideoSDKAPIToken(string apiSecret, JwtPayload payload)
        {
            // Create Security key using private key above:
            // note that latest version of JWT using Microsoft namespace instead of System
            var securityKey = new Microsoft.IdentityModel.Tokens.SymmetricSecurityKey(Encoding.UTF8.GetBytes(apiSecret));

            // Also note that securityKey length should be >256b
            // so you have to make sure that your private key has a proper length
            var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);

            // Finally create a Token
            var header = new JwtHeader(credentials);
            var secToken = new JwtSecurityToken(header, payload);
            var handler = new JwtSecurityTokenHandler();

            // Token to String so you can use it in your client
            return handler.WriteToken(secToken);
        }

```

* * *

Code to call a API,

```auto
var client = new RestClient(_zoomConfiguration.Zoom_Base_URL + "/videosdk/sessions/" + sessionid + "/events");

                var request = new RestRequest(Method.PATCH);
                request.AddHeader("content-type", "application/json");
                request.AddHeader("authorization", token);
                request.AddParameter("application/json", json, ParameterType.RequestBody);

                IRestResponse response = await client.ExecuteAsync(request);
                responseObj = JsonConvert.DeserializeObject<CallOutDTO>(response.Content);

```

---

<div class="post-metadata">

**Author:** ![vishwajeetbhosale](https://avatars.discourse-cdn.com/v4/letter/v/f19dbf/32.png) [@vishwajeetbhosale](https://devforum.zoom.us/u/vishwajeetbhosale)\
**Post date:** [January 5, 2024, 2:39pm UTC](https://devforum.zoom.us/t/how-to-call-zoom-videosdk-session-api-to-use-in-session-events-controls/101045/6 "2024-01-05T14:39:27Z")

</div>

@kellyjandrews, Thank you for you time and support, I am able to sort out the issue.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [February 5, 2024, 12:40am UTC](https://devforum.zoom.us/t/how-to-call-zoom-videosdk-session-api-to-use-in-session-events-controls/101045/7 "2024-02-05T00:40:27Z")

</div>

Closed on February 5, 2024, 12:40am UTC

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