0

Create Online Meeting

by
Published today

Create a Teams online meeting organized by the connected user and return its join link (`joinWebUrl`). Start and end are ISO 8601 date-times with an offset; without them the meeting starts now. It does not appear on any calendar: use Outlook's create calendar event for an invitation. Requires OnlineMeetings.ReadWrite (a connection default).

Script ms_teams Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 2 hours ago
1
//native
2

3
/**
4
 * Create Online Meeting
5
 * Create a Teams online meeting organized by the connected user and return its join link (`joinWebUrl`). Start and end are ISO 8601 date-times with an offset; without them the meeting starts now. It does not appear on any calendar: use Outlook's create calendar event for an invitation. Requires OnlineMeetings.ReadWrite (a connection default).
6
 */
7
export async function main(
8
  auth: RT.MsTeams,
9
  subject: string,
10
  start_date_time: string | undefined,
11
  end_date_time: string | undefined
12
) {
13
  const payload: { [key: string]: any } = { subject }
14
  if (start_date_time != null && start_date_time !== "") {
15
    payload.startDateTime = start_date_time
16
  }
17
  if (end_date_time != null && end_date_time !== "") {
18
    payload.endDateTime = end_date_time
19
  }
20

21
  const response = await fetch(
22
    `https://graph.microsoft.com/v1.0/me/onlineMeetings`,
23
    {
24
      method: "POST",
25
      headers: {
26
        Authorization: `Bearer ${auth.token}`,
27
        "Content-Type": "application/json",
28
        Accept: "application/json",
29
      },
30
      body: JSON.stringify(payload),
31
    }
32
  )
33

34
  if (!response.ok) {
35
    throw new Error(`${response.status} ${await response.text()}`)
36
  }
37

38
  return await response.json()
39
}
40