--- title: "Apex API reference guide" slug: "salesforce-apex-api-reference" description: "Explore the ScreenMeet Apex API for seamless session management, including creating, scheduling, and closing sessions with ease." updated: 2022-11-03T15:38:43Z published: 2022-11-03T15:38:43Z canonical: "docs.screenmeet.com/salesforce-apex-api-reference" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.screenmeet.com/llms.txt > Use this file to discover all available pages before exploring further. # Apex API Reference ## Under the Hood The ScreenMeet Apex API is a wrapper around a REST interface that makes callouts to the ScreenMeet REST API. The Apex wrapper takes care of things like authentication and message serialization for you automatically. If you use the ScreenMeet API with any kind of synchronous code, such as **Triggers** or **Flow Processes**, you will need to add the *@future(Callout=true)* annotation to any helper functions which call methods from the ScreenMeet API. [Read more about @future annotations here](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_future.htm). ## screenmeet.ScreenMeetAPI.ScreenMeetSessionParams This object is used to define properties for a session which you are trying to either **create** or **schedule**. ### Properties | Property | Type | Description | | --- | --- | --- | | parentObject | Map | This map will contain properties describing the parent object. The constructor generates this object automatically. | | metaData | Map | This object contains extra metadata about the session request and stores data such as the version of the interface being used. This property is also auto-populated by the constructor. | | agentPrefs | ScreenMeetSessionAgentPrefs | This object contains the settings which the agent can toggle for this session. | | label | String | The label/description for this session. | | type | String (enum) | An enum that supports four values: *support*, *cobrowse*, *live,* and *replay*. | | externalMapping | String | This field is created automatically during construction. It acts as a globally unique identifier in the ScreenMeet system to determine which sessions are associated with the parent object. It will generally be a concatenation of the *Organization Id* and *parentObjectId*. | | startTime | String (ISO Date format) | This field contains the desired start time of this call and is only used for scheduled sessions. | | userDescription | String | The description of the user. Usually this will be the name of the agent who created the session. It will be shown to the end-user in support and co-browse sessions during the permission-consent process. | ### Constructor | Property | Type | Description | | --- | --- | --- | | sessionType | String (enum) | An enum that supports four values describing the type of session to create: *support*, *cobrowse*, *live*, and *replay*. | | parentObjectId | String | The Salesforce ID of the Object with which this session is to be associated. | | parentObjectType | String | The type of object with which this session is associated, e.g., *case*, *opportunity*, *serviceappointment*, and *user*. | | label | String | The label/description for this session. | | userDesc | String | The description of the user. Usually, this will be the name of the agent who created the session and will be shown to the end-user in support and co-browse sessions during the permission-consent process. | ### Example Usage ``` JavaJavascreenmeet.ScreenMeetAPI.ScreenMeetSessionParams newSessionParams = new screenmeet.ScreenMeetAPI.ScreenMeetSessionParams( 'live', //session type '5001R00000xgLmIQAU', //parentObjectId 'case', //owner object type UserInfo.getUserId(), //Logged in user ID 'My Support Session', //session description UserInfo.getName() //name of currently logged in USER ); ``` ## screenmeet.ScreenMeetAPI.ScreenMeetSessionAgentPrefs This object contains the settings which the agent can toggle for this session. | Property | Type | Description | | --- | --- | --- | | record | Boolean | Whether or not the session should be recorded. | | knock | Boolean | Supported only by *Live* sessions. Indicates the Host must approve the attendee before joining. | | startwithrc | Boolean | Supported only by *Remote Support* sessions. Requests remote-control entitlement on start. | | startwithadmin | Boolean | Supported only by *Remote Support* sessions. Requests admin permissions to the device on start. | ### Example Usage ``` JavaJavascreenmeet.ScreenMeetAPI.ScreenMeetSessionAgentPrefs prefs = new screenmeet.ScreenMeetAPI.ScreenMeetSessionAgentPrefs(); prefs.record = true; prefs.startwithadmin = true; prefs.startwithrc = true; //set the agentPrefs of our session params object newSessionParams.agentPrefs = prefs; ``` ## Methods ### createSession This method is used to create a new session. **Signature** Map screenmeet.ScreenMeetApi.createSession(**ScreenMeetSessionParams** newSession) **Example** ``` JavaJavascreenmeet.ScreenMeetApi.createSession(newSessionParams); ``` --- ### scheduleSession This method is used to schedule a session that starts in the future. **Signature** Map screenmeet.ScreenMeetApi.scheduleSession(**ScreenMeetSessionParams** newSession, **string** ISODateTime) **Example** ``` JavaJavascreenmeet.ScreenMeetApi.scheduleSession(myNewSessionParams, '2021-05-20T23:30:00.000Z'); ``` --- ### rescheduleRemoteSession This method is used to change the starting time of a previously scheduled session. **Signature** Map screenmeet.ScreenMeetApi.rescheduleRemoteSession(**String** SmSessionId, **string** ISODateTime) **Example** ``` JavaJava screenmeet.ScreenMeetApi.rescheduleRemoteSession('gJ3Sjv6sXkrS', '2021-05-20T23:30:00.000Z'); ``` --- ### closeRemoteSession This method is used to close a session which is either *scheduled*, *new*, or *active*. If the session is active, all connected users will be dropped and the session will be closed. **Signature** Map screenmeet.ScreenMeetApi.closeRemoteSession(**String** SmSessionId); **Example** ``` JavaJava screenmeet.ScreenMeetApi.closeRemoteSession('gJ3Sjv6sXkrS'); ``` ## Putting it Together The example below will create a ScreenMeet Live session with recording and knock to join enabled from a Case object record. You can call this in a Flow for any event: ```java //create the newSessionParams screenmeet.ScreenMeetAPI.ScreenMeetSessionParams newSessionParams = new screenmeet.ScreenMeetAPI.ScreenMeetSessionParams( 'live', //session type '5001R00000xgLmIQAU', //parentObjectId 'case', //owner object type UserInfo.getUserId(), //Logged in user ID 'My Support Session', //session description UserInfo.getName() //name of currently logged in USER ); //configure agent user preferences (optional) screenmeet.ScreenMeetAPI.ScreenMeetSessionAgentPrefs prefs = new screenmeet.ScreenMeetAPI.ScreenMeetSessionAgentPrefs(); prefs.record = true; prefs.knock = true; //set the agentPrefs of our session params object newSessionParams.agentPrefs = prefs; //make the REST API call to create the session screenmeet.ScreenMeetApi.createSession(newSessionParams); ``` ## Related - [Apex API Overview](/salesforce-apex-api-overview.md) - [ScreenMeet Live Session Object](/salesforce-sm-session-object.md)