# Create a workspace

> **POST** `https://api.us.nylas.com/v3/workspaces`

Source: https://developer.nylas.com/docs/reference/api/workspaces/create-workspace/

Creates a workspace.

**Authentication:** NYLAS_API_KEY

## Request body

Content-Type: application/json

- `auto_group` (boolean) - When `true`, specifies that newly created grants in the application are automatically
assigned to the workspace if their email address' domain matches the `domain`.
- `domain` (string) **(required)** - The top-level domain associated with the workspace. You can't change the domain after
the workspace is created.
- `name` (string) **(required)** - A short, descriptive name for the workspace.
- `policy_id` (string) - The ID of the [policy](/docs/v3/agent-accounts/policies-rules-lists/) to attach to the
workspace.
- `rule_ids` (array) - The IDs of any [rules](/docs/v3/agent-accounts/policies-rules-lists/#rules) to attach to
the workspace.

## Responses

### 200 - Success. Returns new Workspace object.

- `request_id` (string) - The request ID.
- `data` (object)
  - `application_id` (string) - The ID of the application the workspace is associated with.
  - `auto_group` (boolean) - When `true`, specifies that newly created grants in the application are automatically assigned
to the workspace if their email address' domain matches the `domain`.
  - `created_at` (integer) - When the workspace was created, in seconds using the Unix timestamp format.
  - `default` (boolean) - When `true`, the workspace is the application's default workspace, which Nylas creates and
manages. Nylas includes this field when you retrieve workspaces. For more information, see
the [Workspaces overview](/docs/reference/api/workspaces/).
  - `domain` (string) - The top-level domain associated with the workspace.
  - `name` (string) - The name of the workspace.
  - `policy_id` (string) - The ID of the [policy](/docs/v3/agent-accounts/policies-rules-lists/) attached to the workspace.
The policy applies to Agent Accounts in the workspace.
  - `rule_ids` (array) - The IDs of any [rules](/docs/v3/agent-accounts/policies-rules-lists/#rules) attached to the
workspace. The rules apply to Agent Accounts in the workspace.
  - `updated_at` (integer) - When the workspace was last updated, in seconds using the Unix timestamp format. Initially, this
value is the same as `created_at`.
  - `workspace_id` (string) - The workspace ID.

### 400 - Error: Bad request. For example, the request body was invalid, or a workspace already exists
for the application and domain.

- `request_id` (string) **(required)** - ID of the request
- `error` (object) **(required)** - Error object
  - `type` (string) - Type of error
  - `message` (string) - Informative error message
  - `provider_error` (object) - (OPTIONAL) informative error message from provider's side

### 401 - Error: Not authenticated

- `request_id` (string) **(required)** - ID of the request
- `error` (object) **(required)** - Error object
  - `type` (string) - Type of error
  - `message` (string) - Informative error message
  - `provider_error` (object) - (OPTIONAL) informative error message from provider's side

### 404 - Error: Not found

- `request_id` (string) **(required)** - ID of the request
- `error` (object) **(required)** - Error object
  - `type` (string) - Type of error
  - `message` (string) - Informative error message
  - `provider_error` (object) - (OPTIONAL) informative error message from provider's side

## Code samples

### cURL

```bash
curl --request POST \
  --url "https://api.us.nylas.com/v3/workspaces" \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <NYLAS_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "The Nylas Workspace",
    "domain": "nylas.com",
    "auto_group": true,
    "policy_id": "<POLICY_ID>",
    "rule_ids": ["<RULE_ID>"]
  }'

```
