# Create a list

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

Source: https://developer.nylas.com/docs/reference/api/lists/create-list/

Creates a list for your application. Lists are typed collections of values (domains, TLDs, or email addresses)
that can be referenced by rules using the `in_list` condition operator.

The list's `type` is set at creation and cannot be changed.

**Authentication:** NYLAS_API_KEY

## Request body

Content-Type: application/json

- `name` (string) **(required)**
- `description` (string)
- `type` (string) **(required)** - The kind of values the list holds. Immutable after creation.

## Responses

### 201 - Created

- `request_id` (string) - ID of the request.
- `data` (object)
  - `id` (string) - Globally unique identifier for the list (UUID).
  - `name` (string) - A human-readable name for the list. 1–256 characters. Required on create.
  - `description` (string) - An optional description of the list's purpose.
  - `type` (string) - The kind of values the list holds and which rule condition fields it can be used with. Required on create and
immutable after creation. `domain` holds domain names (matched against `from.domain` or `recipient.domain`),
`tld` holds top-level domains (matched against `from.tld` or `recipient.tld`), and `address` holds full email
addresses (matched against `from.address` or `recipient.address`).
  - `items_count` (integer) - The number of items currently in the list. Read-only; maintained by the system.
  - `application_id` (string) - The ID of the application that owns the list. Read-only; derived from the authenticated API key.
  - `organization_id` (string) - The ID of the Nylas organization that owns the list. Read-only; derived from the authenticated API key.
  - `created_at` (integer) - When the list was created, in seconds using the Unix timestamp format.
  - `updated_at` (integer) - When the list was last updated, in seconds using the Unix timestamp format.

### 400 - Bad Request

- `request_id` (string) - The request ID.
- `error` (object) - The response error object.
  - `type` (string) - The error type.
  - `message` (string) - The error message.
  - `provider_error` (object) - The error from the provider.

### 401 - Unauthorized

- `request_id` (string) - The request ID.
- `error` (object) - The response error object.
  - `type` (string) - The error type.
  - `message` (string) - The error message.
  - `provider_error` (object) - The error from the provider.

### 429 - Rate Limit

- `request_id` (string) - The request ID.
- `error` (object) - The response error object.
  - `type` (string) - The error type.
  - `message` (string) - The error message.

## Code samples

### cURL

```bash
curl -X POST "https://api.us.nylas.com/v3/lists" \
  -H "Authorization: Bearer <NYLAS_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Blocked domains",
    "description": "Domains we have identified as sending unwanted mail.",
    "type": "domain"
  }'

```

### Node.js SDK

```javascript
import Nylas from "nylas";

const nylas = new Nylas({
  apiKey: "<NYLAS_API_KEY>",
  apiUri: "<NYLAS_API_URI>",
});

async function createList() {
  try {
    const list = await nylas.lists.create({
      requestBody: {
        name: "Blocked domains",
        description: "Domains we have identified as sending unwanted mail.",
        type: "domain",
      },
    });

    console.log("List:", list);
  } catch (error) {
    console.error("Error creating list:", error);
  }
}

createList();

```

### Python SDK

```python
from nylas import Client

nylas = Client(
    "<NYLAS_API_KEY>",
    "<NYLAS_API_URI>",
)

nylas_list = nylas.lists.create(
    request_body={
        "name": "Blocked domains",
        "description": "Domains we have identified as sending unwanted mail.",
        "type": "domain",
    },
)

print(nylas_list)

```
