> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mailbreeze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create List

> Create a new contact list

Create a new contact list for organizing email recipients with optional custom field definitions.

## Request Body

<ParamField body="name" type="string" required>
  List name (max 100 characters).
</ParamField>

<ParamField body="description" type="string">
  Optional description (max 500 characters).
</ParamField>

<ParamField body="customFields" type="array">
  Custom field definitions for contacts in this list.

  <Expandable title="Custom field object">
    <ParamField body="key" type="string" required>
      Field key used in API (e.g., `company`, `plan`).
    </ParamField>

    <ParamField body="label" type="string" required>
      Display label shown in UI.
    </ParamField>

    <ParamField body="type" type="string" required>
      Field type: `text`, `number`, `date`, `boolean`, or `select`.
    </ParamField>

    <ParamField body="required" type="boolean" default="false">
      Whether field is required when creating contacts.
    </ParamField>

    <ParamField body="defaultValue" type="any">
      Default value for the field.
    </ParamField>

    <ParamField body="options" type="string[]">
      Required for `select` type. Array of valid options.
    </ParamField>
  </Expandable>
</ParamField>

## Examples

<CodeGroup>
  ```typescript JavaScript theme={null}
  import { MailBreeze } from "mailbreeze";

  const mailbreeze = new MailBreeze({ apiKey: "sk_live_xxx" });

  // Simple list
  const list = await mailbreeze.lists.create({
    name: "Newsletter Subscribers",
    description: "Weekly newsletter recipients",
  });

  // List with custom fields
  const list = await mailbreeze.lists.create({
    name: "VIP Customers",
    description: "High-value customers",
    customFields: [
      { key: "company", label: "Company", type: "text" },
      { key: "revenue", label: "Annual Revenue", type: "number" },
      { key: "plan", label: "Plan", type: "select", options: ["free", "pro", "enterprise"] },
      { key: "signupDate", label: "Signup Date", type: "date" },
      { key: "isActive", label: "Active", type: "boolean", defaultValue: true },
    ],
  });

  console.log(list.id); // "lst_xxx"
  ```

  ```python Python theme={null}
  from mailbreeze import MailBreeze

  client = MailBreeze(api_key="sk_live_xxx")

  # Simple list
  list = await client.lists.create(
      name="Newsletter Subscribers",
      description="Weekly newsletter recipients",
  )

  # List with custom fields
  list = await client.lists.create(
      name="VIP Customers",
      description="High-value customers",
      custom_fields=[
          {"key": "company", "label": "Company", "type": "text"},
          {"key": "revenue", "label": "Annual Revenue", "type": "number"},
          {"key": "plan", "label": "Plan", "type": "select", "options": ["free", "pro", "enterprise"]},
      ],
  )

  print(list.id)  # "lst_xxx"
  ```

  ```go Go theme={null}
  client := mailbreeze.NewClient("sk_live_xxx")

  // Simple list
  list, err := client.Lists.Create(ctx, &mailbreeze.CreateListParams{
      Name:        "Newsletter Subscribers",
      Description: "Weekly newsletter recipients",
  })

  // List with custom fields
  list, err := client.Lists.Create(ctx, &mailbreeze.CreateListParams{
      Name:        "VIP Customers",
      Description: "High-value customers",
      CustomFields: []mailbreeze.CustomFieldDefinition{
          {Key: "company", Label: "Company", Type: "text"},
          {Key: "plan", Label: "Plan", Type: "select", Options: []string{"free", "pro", "enterprise"}},
      },
  })

  fmt.Println(list.ID) // "lst_xxx"
  ```

  ```php PHP theme={null}
  $mailbreeze = new MailBreeze('sk_live_xxx');

  // Simple list
  $list = $mailbreeze->lists->create([
      'name' => 'Newsletter Subscribers',
      'description' => 'Weekly newsletter recipients',
  ]);

  // List with custom fields
  $list = $mailbreeze->lists->create([
      'name' => 'VIP Customers',
      'description' => 'High-value customers',
      'customFields' => [
          ['key' => 'company', 'label' => 'Company', 'type' => 'text'],
          ['key' => 'plan', 'label' => 'Plan', 'type' => 'select', 'options' => ['free', 'pro', 'enterprise']],
      ],
  ]);

  echo $list['id']; // "lst_xxx"
  ```

  ```rust Rust theme={null}
  let client = Client::new("sk_live_xxx");

  // Simple list
  let list = client.lists().create(CreateListParams {
      name: "Newsletter Subscribers".to_string(),
      description: Some("Weekly newsletter recipients".to_string()),
      custom_fields: None,
  }).await?;

  // List with custom fields
  let list = client.lists().create(CreateListParams {
      name: "VIP Customers".to_string(),
      description: Some("High-value customers".to_string()),
      custom_fields: Some(vec![
          CustomFieldDefinition {
              key: "company".to_string(),
              label: "Company".to_string(),
              field_type: "text".to_string(),
              ..Default::default()
          },
      ]),
  }).await?;

  println!("{}", list.id); // "lst_xxx"
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.mailbreeze.com/api/v1/contact-lists \
    -H "Authorization: Bearer sk_live_xxx" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Newsletter Subscribers",
      "description": "Weekly newsletter recipients",
      "customFields": [
        { "key": "company", "label": "Company", "type": "text" },
        { "key": "plan", "label": "Plan", "type": "select", "options": ["free", "pro", "enterprise"] }
      ]
    }'
  ```
</CodeGroup>

## Response

<ResponseField name="id" type="string">
  Unique list ID.
</ResponseField>

<ResponseField name="name" type="string">
  List name.
</ResponseField>

<ResponseField name="description" type="string">
  List description.
</ResponseField>

<ResponseField name="customFields" type="array">
  Custom field definitions.
</ResponseField>

<ResponseField name="contactCount" type="integer">
  Number of contacts (0 for new lists).
</ResponseField>

<ResponseField name="createdAt" type="string">
  ISO 8601 timestamp when created.
</ResponseField>

<ResponseField name="updatedAt" type="string">
  ISO 8601 timestamp when last updated.
</ResponseField>

```json Example Response theme={null}
{
  "success": true,
  "data": {
    "domainId": "6911cf4253eb3ff3b4de6215",
    "userId": "68da571fdc22fcf0773dcb33",
    "name": "VIP Customers",
    "description": "High-value customers",
    "totalContacts": 0,
    "activeContacts": 0,
    "suppressedContacts": 0,
    "tags": [],
    "createdAt": "2025-12-27T12:46:07.070Z",
    "updatedAt": "2025-12-27T12:46:07.070Z",
    "id": "694fd50f9e63563857ae96bb"
  },
  "meta": {
    "timestamp": "2025-12-27T12:46:07.123Z",
    "requestId": "abc123-def456",
    "path": "/api/v1/contact-lists"
  }
}
```

## Custom Field Types

| Type      | Description                | Example Value  |
| --------- | -------------------------- | -------------- |
| `text`    | Free-form text             | `"Acme Corp"`  |
| `number`  | Numeric value              | `99.99`        |
| `date`    | ISO 8601 date              | `"2024-01-15"` |
| `boolean` | True/false                 | `true`         |
| `select`  | Single choice from options | `"pro"`        |

<Note>
  Custom fields are defined at the list level. All contacts in a list share the same field schema.
</Note>
