# Automatically group grants into workspace

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

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

Configures automatic grouping settings for new or existing workspaces, depending on the filters
set. If you don't set any filters, Nylas considers all grants.

**Authentication:** NYLAS_API_KEY

## Request body

Content-Type: application/json

- `after_created_at` (number) - Applies automatic grouping settings to grants created at or after the specified time,
in seconds using the Unix timestamp format.
- `invalid_also` (boolean) - When `true`, applies automatic grouping settings to both invalid and valid grants. When
`false`, applies settings to valid grants only.
- `specific_domain` (string) - Applies automatic grouping settings to grants with the specified email domain only.

## Responses

### 200 - Success. Returns a information about automatic grouping job.

- `request_id` (string) - The request ID.
- `data` (object)
  - `job_id` (string) - The ID of the automatic grouping job.
  - `message` (string) - Information about the background automatic grouping job.

### 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/auto-group" \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <NYLAS_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
    "after_created_at": 1725273600,
    "invalid_also": true,
    "specific_domain": "nylas.com"
  }'
```
