> 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 export data from a room

> Learn how to export data from a room through the Rooms API

This topic demonstrates how to export data from a room.

> **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. |
| \{ROOM_ID}                     | A unique integer that identifies your room. To return a list of your room IDs, use the [Rooms:GetRooms](/docs/rooms-api/reference/rooms/rooms/getrooms) method.                                                                                                                          |
| 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 roomsApi = new RoomsApi(apiClient);
```

**`Java`**

```java title="Java"
RoomsApi roomsApi = createRoomsApiClient(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. Call the Rooms API

Now that you have constructed your API headers, make a request to the Rooms API `field_data` endpoint. Here’s how you make the call, but make sure to substitute your API account ID for \{API_ACCOUNT_ID} and your intended Rooms ID for \{ROOMS_ID}.

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

**`Bash`**

```bash title="Bash"
Status=$(curl -w '%{http_code}' -i --request GET https://demo.rooms.docusign.com/restapi/v2/accounts/${account_id}/rooms/${room_id}/field_data \
    "${Headers[@]}" \
    --output ${response})

if [[ "$Status" -gt "201" ]]; then
    echo ""
    echo "Unable to retrieve field_set on roomId: $room_id"
    echo ""
    cat $response
    exit 0
fi

echo ""
echo "Response:"
cat $response
echo ""

# Remove the temporary files
rm "$response"
```

**`C#`**

```csharp title="C#"
var response = roomsApi.GetRoomFieldDataWithHttpInfo(accountId, roomId);

response.Headers.TryGetValue("X-RateLimit-Remaining", out string remaining);
response.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);
}

return response.Data;
```

**`Java`**

```java title="Java"
FieldData fieldData = ExportingDataFromRoomService.exportDataFromRoom(
        roomsApi,
        this.session.getAccountId(),
        args.getRoomId());
```

**`Node.js`**

```javascript title="Node.js"
let roomsApi = new docusignRooms.RoomsApi(dsApiClient);
  let results = null;
  results = await new Promise((resolve, reject) => {
    roomsApi.getRoomFieldData(args.accountId, args.roomsArgs.roomId, (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();
try {
    $room_details = $rooms_api->getRoomFieldDataWithHttpInfo($args['room_id'], $args["account_id"]);

    $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));
    }
} catch (ApiException $e) {
    error_log($e);
    $clientService->showErrorTemplate($e);
    exit;
}
```

**`PowerShell`**

```text title="PowerShell"
$uri = "https://demo.rooms.docusign.com/restapi/v2/accounts/$APIAccountId/rooms/$roomId/field_data"

try {
  Write-Output "Response:"
  $response = Invoke-WebRequest -uri $uri -UseBasicParsing -headers $headers -method GET
  $response.Content | ConvertFrom-Json | ConvertTo-Json
}
catch {
  Write-Output "Unable to create a new room."
  #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.Headers[$int] }
    $int++
  }
  Write-Output "Error : "$_.ErrorDetails.Message
  Write-Output "Command : "$_.InvocationInfo.Line
}
```

**`Python`**

```python title="Python"
rooms_api = RoomsApi(api_client)
(response, status, headers) = rooms_api.get_room_field_data_with_http_info(
    room_id=args['room_id'],
    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_room_field_data_with_http_info(args[:room_id], args[:account_id])

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"
{
  "data":
  {
    "buyerAgent2":
    {
      "email": "Jane@anyemail.com",
      "address2": null,
      "address1": "123 Any St",
      "company": "DS Rooms Test",
      "state": "US-CA",
      "homePhone": "415-555-1111",
      "businessPhone": "415-555-3333",
      "country": "US",
      "city": "San Francisco",
      "name": "Jane Doe",
      "postalCode": "94016",
      "cellPhone": "415-555-2222"
    }
  }
}
```

## 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 all available Rooms API [How-to guides](/docs/rooms-api/how-to).
* See [How to create a room with data](/docs/rooms-api/how-to/create-room-with-data).
* 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.