> You are reading the Docusign Developer Documentation. For clean Markdown of any page, append .md to the page URL.
>
> Documentation indexes by section:
> - APIs and SDKs: https://docusign.docs.buildwithfern.com/docs/llms.txt
> - Platform 101: https://docusign.docs.buildwithfern.com/platform/llms.txt
> - Extension Apps: https://docusign.docs.buildwithfern.com/extension-apps/llms.txt
> - Docusign CLI: https://docusign.docs.buildwithfern.com/docusign-cli/llms.txt
>
> Authentication (OAuth, JWT Grant, M2M): https://docusign.docs.buildwithfern.com/platform/auth
> Webhooks and Connect: https://docusign.docs.buildwithfern.com/platform/webhooks
>
> OpenAPI specifications: https://docusign.docs.buildwithfern.com/openapi.json
> MCP server: https://docusign.docs.buildwithfern.com/_mcp/server

# How to get a room with filters

> Describes how to return rooms filtered by parameters using the Rooms API

This topic demonstrates how to return rooms filtered by your parameters using the [Rooms API](/docs/rooms-api/rooms101). The sample code for this topic filters for all rooms that have had their field data updated within the last 10 days, as shown on the **Details** tab in the UI.

> **Note**
>
> Run this code example from our [Quickstart](/docs/esign-rest-api/quickstart) or launcher projects: [Bash](https://github.com/docusign/code-examples-bash), [C#](https://github.com/docusign/code-examples-csharp), [Java](https://github.com/docusign/code-examples-java), [Node.js](https://github.com/docusign/code-examples-node), [PHP](https://github.com/docusign/code-examples-php), [PowerShell](https://github.com/docusign/code-examples-powershell), [Python](https://github.com/docusign/code-examples-python), or [Ruby](https://github.com/docusign/code-examples-ruby).

## Required data

Running the code in this how-to requires this data:

| Data element                   | Description                                                                                                                                                                                                                                                                              |
| ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| \{API_ACCOUNT_ID}              | A [GUID](http://guid.one/) value that identifies your account. This value is automatically generated by Docusign for any account you create. Copy the value from the **API Account ID** field on the [Apps and Keys](https://admindemo.docusign.com/authenticate?goTo=appsAndKeys) page. |
| Rooms enabled for your account | You will need access enabled to use the Rooms API. See [creating a Rooms developer account](/docs/rooms-api/rooms101/create-account).                                                                                                                                                    |

## Step 1. Obtain your OAuth token

To make the API call shown in this how-to, you need a valid OAuth access token with the `dtr.rooms.write` scope enabled. Docusign supports access tokens for three different recommended OAuth grant types: Public Authorization Code Grant, Confidential Authorization Code Grant, and JSON Web Token (JWT) Grant. Choose the OAuth grant type appropriate for your scenario.

> **Note**
>
> See [Authentication](/docs/rooms-api/rooms101/auth) for guidance on your options to get an OAuth token.

![Three icons that represent the three methods a user can use to obtain an OAuth token: JSON Web Token (JWT), Public Authorization Code Grant (ACG), and Confidential Authorization Code grant](/_fern-files/_img/64f473773042ee439449a096bf7673292b1585b86a4ccc55f82ba0dda41f61a1.webp)

## Step 2. Construct your API headers

After you have a valid OAuth access token, you are ready to construct the API headers that you will pass to the API call. Construct your headers like this, but make sure to substitute your valid OAuth access token for \{ACCESS_TOKEN}.

**`Bash`**

```bash title="Bash"
declare -a Headers=('--header' "Authorization: Bearer ${ACCESS_TOKEN}"
    '--header' "Accept: application/json"
    '--header' "Content-Type: application/json")
```

**`C#`**

```csharp title="C#"
var apiClient = new DocuSignClient(basePath);
apiClient.Configuration.DefaultHeader.Add("Authorization", $"Bearer {accessToken}");
var formGroupsApi = new FormGroupsApi(apiClient);
```

**`Java`**

```java title="Java"
FormGroupsApi formGroupsApi = createFormGroupsApi(
        this.session.getBasePath(), this.user.getAccessToken()
);
```

**`Node.js`**

```javascript title="Node.js"
let dsApiClient = new docusignRooms.ApiClient();
dsApiClient.setBasePath(args.basePath);
dsApiClient.addDefaultHeader('Authorization', 'Bearer ' + args.accessToken);
```

**`PHP`**

```php title="PHP"
$config = new Configuration();
$config->setHost('https://demo.rooms.docusign.com/restapi');
$config->addDefaultHeader('Authorization', 'Bearer ' . $args['ds_access_token']);
$this->apiClient = new ApiClient($config);
```

**`PowerShell`**

```text title="PowerShell"
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.add("Authorization", "Bearer $accessToken")
$headers.add("Accept", "application/json")
$headers.add("Content-Type", "application/json")
```

**`Python`**

```python title="Python"
api_client = create_rooms_api_client(access_token=args["access_token"])
```

**`Ruby`**

```ruby title="Ruby"
configuration = DocuSign_Rooms::Configuration.new
configuration.host = Rails.configuration.rooms_host

api_client = DocuSign_Rooms::ApiClient.new(configuration)
api_client.set_default_header('Authorization', "Bearer #{args[:access_token]}")
```

## Step 3. Prepare your request parameters

Next, prepare your request by populating your query parameters. For this how-to, you will use two dates to filter for all rooms with updated field data after a given date that is set dynamically to 10 days in the past.

> **Note**
>
> Date filtering format can be set using either **mm-dd-yyyy hh:mm:ss** format or **mm-dd-yyyy** format. When filtering by **mm-dd-yyyy,** the midnight time of 0:00:00 is used. This example has the end date set forward one day to account for updates occurring on today’s date.

**`Bash`**

```bash title="Bash"
if date -v -10d &>/dev/null; then
    # Mac
    # past=`date -v -10d '+%Y-%m-%dT%H:%M:%S%z'`
    past=$(date -v -10d '+%Y-%m-%d')
    # Set the date 1 day forward to account for changes made today
    # current=`date -v +1d '+%Y-%m-%dT%H:%M:%S%z'`
    current=$(date -v +1d '+%Y-%m-%d')
else
    # Not a Mac
    # past=`date --date='-10 days' '+%Y-%m-%dT%H:%M:%S%z'`
    past=$(date --date='-10 days' '+%Y-%m-%d')
    # Set the date 1 day forward to account for changes made today
    # current=`date --date='+1 days' '+%Y-%m-%dT%H:%M:%S%z'`
    current=$(date --date='+1 days' '+%Y-%m-%d')
fi
```

**`C#`**

```csharp title="C#"
var fieldDataChangedStartDate = roomFilterModel.FieldDataChangedStartDate.ToString(CultureInfo.InvariantCulture);
var fieldDataChangedEndDate = roomFilterModel.FieldDataChangedEndDate.ToString(CultureInfo.InvariantCulture);
```

**`Java`**

```java title="Java"
RoomsApi.GetRoomsOptions options = roomsApi.new GetRoomsOptions();
options.setFieldDataChangedStartDate(startDate);
options.setFieldDataChangedEndDate(endDate);
```

**`Node.js`**

```javascript title="Node.js"
const roomsArgs = {
    fieldDataChangedStartDate: moment().subtract(30, 'days').format(),
    fieldDataChangedEndDate: moment().format()
};
```

**`PHP`**

```php title="PHP"
$options = new GetRoomsOptions();
$options->setFieldDataChangedStartDate($args['start_date']);
$options->setFieldDataChangedEndDate($args['end_date']);
```

**`PowerShell`**

```text title="PowerShell"
# Set your filtering parameters
$past = (Get-Date (Get-Date).AddDays(-10) -Format "yyyy-MM-dd")
# Set the date 1 day forward to account for changes made today
$current = (Get-Date (Get-Date).AddDays(1) -Format "yyyy-MM-dd")
```

**`Python`**

```python title="Python"
field_data_changed_start_date=dt.strptime(args['start_date'], "%Y-%m-%d"),
field_data_changed_end_date=dt.strptime(args['end_date'], "%Y-%m-%d"),
```

**`Ruby`**

```ruby title="Ruby"
filters = DocuSign_Rooms::GetRoomsOptions.new
filters.field_data_changed_start_date = args[:date_from]
filters.field_data_changed_end_date = args[:date_to]
```

## Step 4. Call the Rooms API

Now that you have constructed your API headers and request body, you can, make a GET request to the Rooms API to return a filtered set of rooms. Here’s how you make the call, but make sure to substitute your API account ID for \{ACCOUNT_ID}.

> **Note**
>
> View the source code for this how-to on GitHub: [Bash](https://github.com/docusign/code-examples-bash/blob/master/examples/Rooms/eg005GetRoomsWithFiltersController.sh), [C#](https://github.com/docusign/code-examples-csharp/blob/master/launcher-csharp/Rooms/Examples/GetRoomsWithFilters.cs), [Java](https://github.com/docusign/code-examples-java/blob/master/src/main/java/com/docusign/controller/rooms/services/GetRoomsWithFiltersService.java), [Node.js](https://github.com/docusign/code-examples-node/blob/master/lib/rooms/examples/getRoomsWithFilters.js), [PHP](https://github.com/docusign/code-examples-php/blob/master/src/Services/Examples/Rooms/GetRoomsWithFiltersService.php), [PowerShell](https://github.com/docusign/code-examples-powershell/blob/master/examples/Rooms/eg005GetRoomsWithFiltersController.ps1), [Python](https://github.com/docusign/code-examples-python/blob/master/app/rooms/examples/eg005_get_rooms_with_filters.py), or [Ruby](https://github.com/docusign/code-examples-ruby/blob/master/app/services/room_api/eg005_get_rooms_with_filters_service.rb).

**`Bash`**

```bash title="Bash"
response=$(mktemp /tmp/response-cw.XXXXXX)
curl -w '%{http_code}' -i --request GET "https://demo.rooms.docusign.com/restapi/v2/accounts/${account_id}/rooms?fieldDataChangedStartDate=${past}&fieldDataChangedEndDate=${current}" \
    "${Headers[@]}" \
    --output ${response}
```

**`C#`**

```csharp title="C#"
var rooms = roomsApi.GetRoomsWithHttpInfo(accountId, new RoomsApi.GetRoomsOptions
{
    fieldDataChangedStartDate = fieldDataChangedStartDate,
    fieldDataChangedEndDate = fieldDataChangedEndDate,
});

rooms.Headers.TryGetValue("X-RateLimit-Remaining", out string remaining);
rooms.Headers.TryGetValue("X-RateLimit-Reset", out string reset);

if (reset != null && remaining != null)
{
    DateTime resetDate = DateTimeOffset.FromUnixTimeSeconds(long.Parse(reset)).UtcDateTime;
    Console.WriteLine("API calls remaining: " + remaining);
    Console.WriteLine("Next Reset: " + resetDate);
}
```

**`Java`**

```java title="Java"
RoomSummaryList rooms = GetRoomsWithFiltersService.getRoomsWithFilters(
        roomsApi,
        this.session.getAccountId(),
        args.getStartDate(),
        args.getEndDate());
```

**`Node.js`**

```javascript title="Node.js"
let roomsApi = new docusignRooms.RoomsApi(dsApiClient);
  let results = null;

  results = await new Promise((resolve, reject) => {
    roomsApi.getRooms(args.accountId, args.roomsArgs,
      (err, data, response) => {
      if (err) return reject(err);
      resolve({ data, response });
    });
  });

  let headers = results.response.headers;
  let remaining = headers['x-ratelimit-remaining'];
  let reset = headers['x-ratelimit-reset'];

  if (remaining && reset) {
    const resetInstant = new Date(Number(reset) * 1000);
    console.log(`API calls remaining: ${remaining}`);
    console.log(`Next Reset: ${resetInstant.toISOString()}`);
  }
```

**`PHP`**

```php title="PHP"
$rooms_api = $clientService->getRoomsApi();
    $rooms = $rooms_api->getRoomsWithHttpInfo($args['account_id'], $options);
    $remaining = $response[2]['x-ratelimit-remaining'] ?? null;
    $reset = $response[2]['x-ratelimit-reset'] ?? null;

    if ($remaining !== null && $reset !== null) {
        $resetInstant = (new DateTime())->setTimestamp((int)$reset);
        error_log("API calls remaining: $remaining");
        error_log("Next Reset: " . $resetInstant->format(\DateTime::ATOM));
    }
```

**`PowerShell`**

```text title="PowerShell"
$uri = "https://demo.rooms.docusign.com/restapi/v2/accounts/$APIAccountId/rooms?fieldDataChangedStartDate=$past&fieldDataChangedEndDate=$current"

try {
  Write-Output "Response:"
  $response = Invoke-WebRequest -uri $uri -UseBasicParsing -headers $headers
  $response.Content | ConvertFrom-Json | ConvertTo-Json
}
catch {
  Write-Output "Unable to retrieve filtered rooms:"
  # On failure, display a notification, X-DocuSign-TraceToken, error message, and the command that triggered the error
  foreach ($header in $_.Exception.Response.Headers) {
    if ($header -eq "X-DocuSign-TraceToken") { Write-Output "TraceToken : " $_.Exception.Response }
    $int++
  }
  Write-Output "Error : "$_
  Write-Output "Command : "$_.InvocationInfo.Line
}
```

**`Python`**

```python title="Python"
rooms_api = RoomsApi(api_client)
(rooms, status, headers) = rooms_api.get_rooms_with_http_info(account_id=args["account_id"])

remaining = headers.get("X-RateLimit-Remaining")
reset = headers.get("X-RateLimit-Reset")

if remaining is not None and reset is not None:
    reset_date = dt.fromtimestamp(int(reset), tz=timezone.utc)
    print(f"API calls remaining: {remaining}")
    print(f"Next Reset: {reset_date}")
```

**`Ruby`**

```ruby title="Ruby"
rooms_api = DocuSign_Rooms::RoomsApi.new(api_client)
results, _status, headers = rooms_api.get_rooms_with_http_info(args[:account_id], filters)

remaining = headers['X-RateLimit-Remaining']
reset = headers['X-RateLimit-Reset']

if remaining && reset
  reset_date = Time.at(reset.to_i).utc
  puts "API calls remaining: #{remaining}"
  puts "Next Reset: #{reset_date}"
end
```

## Expected response

If you run this code example from our Quickstart or launcher projects, you should see a JSON response similar to the code shown.

**`Sample response`**

```json title="Sample response"
{
  "rooms":
  [
    {
      "roomId": 3xxxx5,
      "name": "Sample Rooms Creation",
      "officeId": 3xxx2,
      "createdDate": "2020-08-06T15:38:38",
      "createdByUserId": 0,
      "closedStatusId": "",
      "fieldDataLastUpdatedDate": "2020-08-06T20:38:38.56"
    },
    {
      "roomId": 3xxxx4,
      "name": "Sample Rooms Creation from Template",
      "officeId": 3xxx2,
      "createdDate": "2020-08-06T15:33:29",
      "createdByUserId": 0,
      "closedStatusId": "",
      "fieldDataLastUpdatedDate": "2020-08-06T20:33:30.107"
    },
    {
      "roomId": 3xxxx6,
      "name": "Sample Rooms Creation",
      "officeId": 3xxx2,
      "createdDate": "2020-08-06T13:54:15",
      "createdByUserId": 0,
      "closedStatusId": "",
      "fieldDataLastUpdatedDate": "2020-08-06T19:10:32.92"
    }
  ],
  "resultSetSize": 3,
  "startPosition": 0,
  "endPosition": 2
}
```

## Next steps

* Run this code example from our [Quickstart](/docs/esign-rest-api/quickstart) or launcher projects:    [Bash](https://github.com/docusign/code-examples-bash), [C#](https://github.com/docusign/code-examples-csharp), [Java](https://github.com/docusign/code-examples-java), [Node.js](https://github.com/docusign/code-examples-node), [PHP](https://github.com/docusign/code-examples-php), [PowerShell](https://github.com/docusign/code-examples-powershell), [Python](https://github.com/docusign/code-examples-python), or [Ruby](https://github.com/docusign/code-examples-ruby).
* See [How to create a room with a template](/docs/rooms-api/how-to/create-room-with-template).
* See [How to add forms to a room](/docs/rooms-api/how-to/add-form-to-room).
* Learn more about [Using room templates and task lists](/docs/rooms-api/rooms101/templates).
* See how to [Go-Live](/docs/rooms-api/go-live)  with a completed app and find the base path for API calls in the production environment.