# Configure the Maximum Participant Duration for a Room

Twilio Video Rooms allow you to configure the maximum amount of time that a Participant can be connected to the Room. The default maximum Participant duration for Video Rooms is four hours and the maximum amount of time a Participant can be connected to a Room is [24 hours](/docs/video/programmable-video-limits). Once a Participant has been connected to a Room for the Room's maximum Participant duration, they will be disconnected from the Room.

If you wish to configure the maximum Participant duration for you Video Rooms, you can do so in two ways: via the Twilio REST API, or via the Twilio Console.

## REST API

You can configure the maximum Participant duration for Video Rooms on a per-Room basis during Room creation using the REST API. When creating the Room, you can specify the maximum Participant duration in seconds.

Configure a Room's maximum Participant duration

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function createRoom() {
  const room = await client.video.v1.rooms.create({
    maxParticipantDuration: 86400,
    uniqueName: "My Video Room",
  });

  console.log(room.sid);
}

createRoom();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

room = client.video.v1.rooms.create(
    max_participant_duration=86400, unique_name="My Video Room"
)

print(room.sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Video.V1;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var room = await RoomResource.CreateAsync(
            maxParticipantDuration: 86400, uniqueName: "My Video Room");

        Console.WriteLine(room.Sid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.video.v1.Room;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Room room = Room.creator().setMaxParticipantDuration(86400).setUniqueName("My Video Room").create();

        System.out.println(room.getSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	video "github.com/twilio/twilio-go/rest/video/v1"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &video.CreateRoomParams{}
	params.SetMaxParticipantDuration(86400)
	params.SetUniqueName("My Video Room")

	resp, err := client.VideoV1.CreateRoom(params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Sid != nil {
			fmt.Println(*resp.Sid)
		} else {
			fmt.Println(resp.Sid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$room = $twilio->video->v1->rooms->create([
    "maxParticipantDuration" => 86400,
    "uniqueName" => "My Video Room",
]);

print $room->sid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

room = @client
       .video
       .v1
       .rooms
       .create(
         max_participant_duration: 86400,
         unique_name: 'My Video Room'
       )

puts room.sid
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:video:v1:rooms:create \
   --max-participant-duration 86400 \
   --unique-name "My Video Room"
```

```bash
curl -X POST "https://video.twilio.com/v1/Rooms" \
--data-urlencode "MaxParticipantDuration=86400" \
--data-urlencode "UniqueName=My Video Room" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "date_created": "2015-07-30T20:00:00Z",
  "date_updated": "2015-07-30T20:00:00Z",
  "status": "in-progress",
  "type": "peer-to-peer",
  "sid": "RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "enable_turn": true,
  "unique_name": "My Video Room",
  "max_concurrent_published_tracks": 0,
  "max_participants": 10,
  "max_participant_duration": 86400,
  "duration": 0,
  "status_callback_method": "POST",
  "status_callback": null,
  "record_participants_on_connect": false,
  "video_codecs": [
    "VP8"
  ],
  "media_region": "us1",
  "audio_only": false,
  "empty_room_timeout": 5,
  "unused_room_timeout": 5,
  "end_time": "2015-07-30T20:00:00Z",
  "large_room": false,
  "url": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "links": {
    "participants": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants",
    "recordings": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings",
    "transcriptions": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions",
    "recording_rules": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RecordingRules"
  }
}
```

## Console

In the Twilio Console, you can update the default maximum Participant duration for all of the Video Rooms created in your account. After you update this value in the Console, any new Rooms that you create without explicitly setting the maximum Participant duration will take this configured value.

To update this value, navigate to [Room Settings](https://www.twilio.com/console/video/configure) section in the Console, where you will be able to update the value. Note that the duration should be specified in seconds.

By default, [PSTN Participants](/docs/video/adding-programmable-voice-participants-video-rooms) are limited to a four-hour maximum duration. You can enable the 24-hour maximum duration in your Programmable Voice [Settings console.](https://www.twilio.com/console/voice/settings)
