Create a Long Term Meeting Room
This code snippet shows how to create a long term meeting room using the Meetings API.
See the API Reference for more information.
Example Request
Where needed, replace the following variables in the sample code with your own values:
| Key | Description |
|---|---|
JWT | Used to authenticate your request. See Authentication for more information, including how to generate a JWT. |
ROOM_DISPLAY_NAME | The name of the meeting room. |
EXPIRATION_DATE | The time for when the room will be expired, expressed in ISO 8601 format. Required only for long-term room creation. |
VONAGE_APPLICATION_ID | The Vonage Application ID. |
VONAGE_APPLICATION_PRIVATE_KEY_PATH | Private key path. |
Write the code
Add the following to create-long-term-room.sh:
curl -X POST https://api-eu.vonage.com/meetings/rooms \
-H "Authorization: Bearer $JWT" \
-H "Content-Type: application/json" \
-d '{
"display_name":"'$ROOM_DISPLAY_NAME'",
"type":"long_term",
"expires_at":"'$EXPIRATION_DATE'"
}'Run your code
Save this file to your machine and run it:
Prerequisites
npm install @vonage/server-sdkCreate a file named request.js and add the following code:
const { Auth } = require('@vonage/auth');
const { Meetings, MeetingType } = require('@vonage/meetings');
const credentials = new Auth({
privateKey: VONAGE_APPLICATION_PRIVATE_KEY_PATH,
applicationId: VONAGE_APPLICATION_ID,
});
const meetingsClient = new Meetings(credentials);Write the code
Add the following to request.js:
meetingsClient.createRoom({
type: MeetingType.LONG_TERM,
displayName: ROOM_DISPLAY_NAME,
expiresAt: ROOM_EXPIRATION_DATE,
})
.then((room) => console.log(room))
.catch((error) => console.error(error));Run your code
Save this file to your machine and run it:
Prerequisites
composer require VonageWrite the code
Add the following to create-long-term-room.php:
<?php
require_once __DIR__ . '/../config.php';
require_once __DIR__ . '/../vendor/autoload.php';
$client = new Vonage\Client(
new Vonage\Client\Credentials\Keypair(VONAGE_APPLICATION_PRIVATE_KEY_PATH, VONAGE_APPLICATION_ID),
);
$room = new \Vonage\Meetings\Room();
$room->fromArray([
'display_name' => ROOM_DISPLAY_NAME,
'type' => 'long_term',
'expires_at' => '2023-01-30T00:47:04+0000'
]);
$meeting = $client->meetings()->createRoom($room);Run your code
Save this file to your machine and run it:
Prerequisites
pip install vonageCreate a file named request.py and add the following code:
import vonage
client = vonage.Client(
application_id=VONAGE_APPLICATION_ID,
private_key=VONAGE_PRIVATE_KEY,Write the code
Add the following to request.py:
expiration_date = (datetime.utcnow() + timedelta(days=30)).isoformat()
params = {
'display_name': ROOM_DISPLAY_NAME,
'type': 'long_term',
'expires_at': expiration_date,
}
Run your code
Save this file to your machine and run it:
Prerequisites
gem install vonageCreate a file named create-long-term-room.rb and add the following code:
Run your code
Save this file to your machine and run it:
Example Response
Your Long Term Room has been created.
You will receive a response similar to the following:
{
"id": "bc41d742-b336-4bf6-8643-aa97b5f5025c",
"display_name": "New Meeting Room",
"metadata": null,
"type": "long_term",
"expires_at": "2022-10-21T18:45:50.901Z",
"join_approval_level": "abc123",
"recording_options": {
"auto_record": true
},
"meeting_code": "117744699",
"_links": {
"host_url": {
"href": "https://meetings.vonage.com/?room_token=117744699&participant_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjYyNjdkNGE5LTlmMTctNGVkYi05MzBmLTJlY2FmMThjODdjOSJ9.eyJwYXJ0aWNpcGFudElkIjoiZmVlNDVmMDItMDhmOC00ZTdmLWE1MjAtZmYwYjYyZGI2NWM3IiwiaWF0IjoxNjM0NjY3NzQ1fQ.CDHtC3nW2B_jIXhfRTPzznH1j7kzcH3-gbL5h9bxIEE"
},
"guest_url": {
"href": "https://meetings.vonage.com/117744699"
}
},
"created_at": "2022-10-19T18:22:24.965Z",
"is_available": true,
"expire_after_use": false,
"theme_id": "e8b1d80b-8f78-4578-94f2-328596e01387",
"initial_join_options": {
"microphone_state": "default"
}