> 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 create a form group

> Demonstrates how to create a form group for your Docusign Rooms for Real Estate account.

This topic demonstrates how to create a [form group](/docs/rooms-api/rooms101/forms/managing-forms-rooms) for your Docusign Rooms for Real Estate account.

> **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.                      |
| \{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. |
| Forms enabled on your Rooms account | The user role needs the **Manage form groups** permission assigned. These permissions are only available to accounts with Forms enabled. To enable this feature, contact your Account Manager or Business Development representative.                                                                         |
| 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. Construct the request body

Next, create the request body by providing a name for your form group.

**`Bash`**

```bash title="Bash"
printf \
    '
{
  "name": "Sample Room Form Group",
}' >$request_data
```

**`C#`**

```csharp title="C#"
var formGroupForCreate = new FormGroupForCreate(groupName);
```

**`Java`**

```java title="Java"
FormGroupForCreate formGroupForCreate = new FormGroupForCreate()
        .name(formGroupName);
```

**`Node.js`**

```javascript title="Node.js"
const form = new docusignRooms.FormGroupForCreate.constructFromObject({
  name: args.formGroupName,
});
```

**`PHP`**

```php title="PHP"
$form_group = new FormGroupForCreate(['name' => $args['form_group_name']]);
```

**`PowerShell`**

```text title="PowerShell"
# Construct the request body
$body = @"
  {
    "name": "Sample Room Form Group"
  }
"@
```

**`Python`**

```python title="Python"
form = FormGroupForCreate(name=args["form_group_name"])
```

**`Ruby`**

```ruby title="Ruby"
DocuSign_Rooms::RoomForCreate.new(
  {
    name: args[:group_name]
  }
)
```

## Step 4. Call the Rooms API

Now that you have constructed your API headers and request body, make a POST request to the [FormGroups:CreateFormGroup](/docs/rooms-api/reference/forms/formgroups/createformgroup) method and include the request body to create a form group for your Rooms account.

Here’s how you make the call, but make sure to substitute your base path for \{BASE_PATH} and your API account ID for \{API_ACCOUNT_ID}.

> **Note**
>
> View the source code for this example on GitHub: [Bash](https://github.com/docusign/code-examples-bash/blob/master/examples/Rooms/eg007CreateFormGroup.sh), [C#](https://github.com/docusign/code-examples-csharp/blob/master/launcher-csharp/Rooms/Examples/CreateFormGroups.cs), [Java](https://github.com/docusign/code-examples-java/blob/master/src/main/java/com/docusign/controller/rooms/examples/R007ControllerCreateFormGroup.java), [Node](https://github.com/docusign/code-examples-node/blob/master/lib/rooms/examples/createFormGroup.js), [PHP](https://github.com/docusign/code-examples-php/blob/master/src/Services/Examples/Rooms/CreateFormGroupService.php), [PowerShell](https://github.com/docusign/code-examples-powershell/blob/master/examples/Rooms/eg007CreateFormGroup.ps1), [Python](https://github.com/docusign/code-examples-python/blob/master/app/rooms/examples/eg007_create_form_group.py),  or [Ruby](https://github.com/docusign/code-examples-ruby/blob/main/app/services/room_api/eg007_create_form_group_service.rb).

**`Bash`**

```bash title="Bash"
Status=$(curl -w '%{http_code}' --request POST ${base_path}/restapi/v2/accounts/${API_ACCOUNT_ID}/form_groups \
    "${Headers[@]}" \
    --data-binary @${request_data} \
    --output ${response})
```

**`C#`**

```csharp title="C#"
var response = formGroupsApi.CreateFormGroupWithHttpInfo(accountId, formGroupForCreate);

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"
ApiResponse<FormGroup> response = formGroupsApi.createFormGroupWithHttpInfo(accountId, formGroupForCreate);

Map<String, List<String>> headers = response.getHeaders();
List<String> remaining = headers.get("X-RateLimit-Remaining");
List<String> reset = headers.get("X-RateLimit-Reset");

if (remaining != null & reset != null) {
    Instant resetInstant = Instant.ofEpochSecond(Long.parseLong(reset.get(0)));
    System.out.println("API calls remaining: " + remaining);
    System.out.println("Next Reset: " + resetInstant);
}

return response.getData();
```

**`Node.js`**

```javascript title="Node.js"
const formsGroupsApi = new docusignRooms.FormGroupsApi(dsApiClient);
const results = await new Promise((resolve, reject) => {
    formsGroupsApi.createFormGroup(args.accountId, {
      body: form,
    },
      (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"
return $clientService->createFormGroup($args["account_id"], $form_group);
```

**`PowerShell`**

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

try {
    Write-Output "Response:"
    $response = Invoke-WebRequest -uri $uri -headers $headers -method POST -body $body
    $response.Content
    $obj = $response.Content | ConvertFrom-Json
    $formGroupID = $obj.formGroupId

    # Store formGroupID into the file .\config\FORM_GROUP_ID
    $formGroupID > .\config\FORM_GROUP_ID
}
catch {
    Write-Output "Unable to create a form group"
    # 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"
form_groups_api = FormGroupsApi(api_client)
(response, status, headers) = form_groups_api.create_form_group_with_http_info(
    body=form, 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::FormGroupsApi.new(api_client)
results, _status, headers = rooms_api.create_form_group_with_http_info(args[:account_id], body(args))

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"
{
  "formGroupId": "1e7eb41b-xxxx-xxxx-xxxx-18653f67a657",
  "name": "Sample Room Form Group",
  "officeIds": [],
  "forms": []
}
```

## 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).
* Learn [Rooms API concepts](/docs/rooms-api/rooms101/concepts).
* See all available Rooms API [How-to guides](/docs/rooms-api/how-to).
* See [How to grant office access to a form group](/docs/rooms-api/how-to/access-form-group).
* See [How to add forms to a room](/docs/rooms-api/how-to/add-form-to-room).
* 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.