Skip to navigation

How to create a room with data

View as Markdown

This topic demonstrates how to create a Docusign room that contains populated data.

Run this code example from our Quickstart or launcher projects: Bash, C#, Java, Node.js, PHP, PowerShell, Python, or Ruby.

Required data

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

Data elementDescription
{API_ACCOUNT_ID}A GUID 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 page.
{BASE_PATH}A string value that forms the root of the URL required to make API calls. The base path value in the example code is set to target the developer environment at
https://<domain>/restapi/v2
Where <domain> is demo.rooms.docusign.com for the developer environment and rooms.docusign.com for production.
{OFFICE_ID}An optional identifier for the office location that is responsible for the room itself. Retrieve this value with the Offices:GetOffices method.
{ROLE_ID}A room-specific ID that can be allocated to a given user within a room. The role ID is necessary to set permissions on rooms for individuals within your Docusign organization. Retrieve this value with the Roles:GetRoles method.
Rooms enabled for your accountYou will need access enabled to use the Rooms API. See creating a Rooms developer account.
Rooms field dataOn room creation, you can fill out form data in advance by specifying the field data. This is the set of fields that appears on the room’s Details tab in the UI, such as contactName and phone. Retrieve the available fields that you can set with the Rooms:GetRoomFieldSet method.

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.

See Authentication 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

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}.

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

Step 3. Construct your request body

Next, create the request body. To create a room, you need to specify some room attributes.

AttributeDescription
nameA string value that identifies the room.
roleIdA string value that specifies which group of users can control the room.
transactionSideIdA string value that defines the type of transaction that is occurring (such as buy, list, or dual). You can update this up until the transaction is completed.
printf \
'
{
"name": "Sample Room Creation",
"roleId": "'"$roleId"'",
"transactionSideId": "listbuy",
"officeId": "'"$officeId"'",
"fieldData": {
"data" : {
"address1": "123 EZ Street",
"address2": "unit 10",
"city": "Galaxian",
"state": "US-HI",
"postalCode": "11112",
"companyRoomStatus": "5",
"comments": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
}
}
}' >$request_data

Step 4. Call the Rooms API

Now that you have constructed your API headers and request body, make a POST request to the Rooms:CreateRoom endpoint and include the request body to create a new room.

Here’s how you make the call, but make sure to substitute your API account ID for {ACCOUNT_ID}

View the source code for this how-to on GitHub: Bash, C#, Java, Node, PHP, PowerShell, Python, or Ruby.

Status=$(
curl -w '%{http_code}' -i --request POST https://demo.rooms.docusign.com/restapi/v2/accounts/${account_id}/rooms \
"${Headers[@]}" \
--data-binary @${request_data} \
--output ${response}
)

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
{
"roomId": "3xxxx5",
"companyId": "1xxx2",
"name": "Sample Rooms Creation",
"officeId": "3xxx2",
"createdDate": "2020-08-06T20:38:38.06",
"createdByUserId": "2xxxxs4",
"closedStatusId": "",
"fieldData":
{
"data":
{
"comments": "Lorem ipsum dolor sit amet, consectetur adi piscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo conseq uat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia de serunt mollit anim id est laborum."
}
}
}

Next steps