# Rename a list

Source: https://docs.emelia.io/docs/lists/rename-list

Guide: [Lists & contacts](https://docs.emelia.io/docs/lists.md)

`PATCH https://api.emelia.io/lists/list/{listId}`

Renames a list. Only `name` can be changed through this route.

## Authentication

Send your API key in the `Authorization` header: `Authorization: <your API key>`.

## Path parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `listId` | string | yes | List id. |

## Request body

Content type: `application/json`, required.

| Field | Type | Required | Description |
|---|---|---|---|
| `name` | string | yes | New name, trimmed. Min length 1. |

```json
{
  "name": "Acme prospects Q4 (France)"
}
```

## Example request

**cURL**

```bash
curl -X PATCH "https://api.emelia.io/lists/list/65f1a2b3c4d5e6f760f68df4" \
  -H "Authorization: $EMELIA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Acme prospects Q4 (France)"
}'
```

**JavaScript**

```js
const response = await fetch('https://api.emelia.io/lists/list/65f1a2b3c4d5e6f760f68df4', {
  method: 'PATCH',
  headers: { Authorization: process.env.EMELIA_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "name": "Acme prospects Q4 (France)"
  }),
});
console.log(await response.json());
```

**Python**

```python
import os
import requests

response = requests.patch(
    "https://api.emelia.io/lists/list/65f1a2b3c4d5e6f760f68df4",
    headers={"Authorization": os.environ["EMELIA_API_KEY"]},
    json={
        "name": "Acme prospects Q4 (France)"
    },
)
print(response.json())
```

## Responses

### 200: List renamed.

| Field | Type | Required | Description |
|---|---|---|---|
| `success` | boolean | yes |  |
| `_id` | string | yes |  |
| `name` | string | yes |  |

```json
{
  "success": true,
  "_id": "66f1c0ffee5a7d3b2c4e8a10",
  "name": "Acme prospects Q4 (France)"
}
```

### 400: Invalid list id, or missing or empty name (note: 400 here, while list creation answers 422 for the same mistake).

| Field | Type | Required | Description |
|---|---|---|---|
| `message` | string | yes | English, human-readable message. |
| `code` | string | no | Stable error code, when available (for example `PAYLOAD_TOO_LARGE`, `INVALID_JSON`, `export_too_large`, `companies_only`, `enrichment_running`). |
| `params` | object | no |  |
| `error` | string | no | Raw internal message (unexpected errors only). |

```json
{
  "message": "string",
  "code": "string",
  "params": {},
  "error": "string"
}
```

### 401: Missing, unknown or disabled API key, or the account of the key no longer exists. Note the body shape: `error` and `code`, not `message`.

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | string | yes |  |
| `code` | enum: `AUTH_REQUIRED`, `ACCOUNT_NOT_FOUND` | yes |  |

```json
{
  "error": "string",
  "code": "AUTH_REQUIRED"
}
```

### 404: The list does not exist or belongs to another account.

| Field | Type | Required | Description |
|---|---|---|---|
| `message` | string | yes | English, human-readable message. |
| `code` | string | no | Stable error code, when available (for example `PAYLOAD_TOO_LARGE`, `INVALID_JSON`, `export_too_large`, `companies_only`, `enrichment_running`). |
| `params` | object | no |  |
| `error` | string | no | Raw internal message (unexpected errors only). |

```json
{
  "message": "List not found"
}
```

### 500: Unexpected server error. `error`, when present, is a raw internal message: do not parse it. Retry later.

| Field | Type | Required | Description |
|---|---|---|---|
| `message` | string | yes | English, human-readable message. |
| `code` | string | no | Stable error code, when available (for example `PAYLOAD_TOO_LARGE`, `INVALID_JSON`, `export_too_large`, `companies_only`, `enrichment_running`). |
| `params` | object | no |  |
| `error` | string | no | Raw internal message (unexpected errors only). |

```json
{
  "message": "Hmm... Something went wrong. Please try again later."
}
```
