---
type: api
title: Import an exception list
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana-serverless/operation/operation-importexceptionlist
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana-serverless/operation/operation-importexceptionlist
products:
  - Kibana
---

# Import an exception list

- Server: `https://{kibana_url}`

## Paths

- `POST` `/api/exception_lists/_import`
- `POST` `/s/{space_id}/api/exception_lists/_import`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/kibana-serverless/authentication#apikeyauth)

## Description

Refer to [Spaces](https://www.elastic.co/docs/deploy-manage/manage-spaces) for more information.

Import an exception list and its associated items from an NDJSON file.

## Query String Parameters

- `overwrite` (boolean · default: false)
  Determines whether existing exception lists with the same `list_id` are overwritten.
If any exception items have the same `item_id`, those are also overwritten.
- `as_new_list` (boolean · default: false)
  Determines whether the list being imported will have a new `list_id` generated.
Additional `item_id`'s are generated for each exception item. Both the exception
list and its items are overwritten.

## Request Body

`multipart/form-data`

- `file` (string) — optional
  A `.ndjson` file containing the exception list

## Responses

#### `200`

Successful response

`application/json`

- `errors` ([] object)
  - `error` (object)
    - `message` (string)
    - `status_code` (integer)
  - `id` (string · min: 1)
    Exception list's identifier.
  - `item_id` (string · min: 1)
    Human readable string identifier, e.g. `trusted-linux-processes`
  - `list_id` (string · min: 1)
    The exception list's human-readable string identifier.

For endpoint artifacts, use one of the following values:

* `endpoint_list`: Elastic Endpoint exceptions list
* `endpoint_trusted_apps`: Trusted applications list
* `endpoint_trusted_devices`: Trusted devices list
* `endpoint_event_filters`: Event filters list
* `endpoint_host_isolation_exceptions`: Host isolation exceptions list
* `endpoint_blocklists`: Blocklist
- `success` (boolean)
- `success_count` (integer · min: 0)
- `success_count_exception_list_items` (integer · min: 0)
- `success_count_exception_lists` (integer · min: 0)
- `success_exception_list_items` (boolean)
- `success_exception_lists` (boolean)
#### `400`

Invalid input data response

`application/json`

One of:
- **PlatformErrorResponse**
  - `error` (string)
  - `message` (string)
  - `statusCode` (integer)
- **SiemErrorResponse**
  - `message` (string)
  - `status_code` (integer)
#### `401`

Unsuccessful authentication response

`application/json`

- `error` (string)
- `message` (string)
- `statusCode` (integer)
#### `403`

Not enough privileges response

`application/json`

- `error` (string)
- `message` (string)
- `statusCode` (integer)
#### `500`

Internal server error response

`application/json`

- `message` (string)
- `status_code` (integer)
## Code Examples

#### Console

```console
POST /api/exception_lists/_import
{
  "file": "exception_lists.ndjson"
}
```

#### curl

```curl
curl -X POST "https://{kibana_url}/api/exception_lists/_import" \
  -H "Content-Type: multipart/form-data" \
  -d '{
  "file": "exception_lists.ndjson"
}'
```

## Response Examples

#### With errors

```json
{
  "errors": [
    {
      "error": {
        "message": "Error found importing exception list: Invalid value \\\u00224\\\u0022 supplied to \\\u0022list_id\\\u0022",
        "status_code": 400
      },
      "list_id": "(unknown list_id)"
    },
    {
      "error": {
        "message": "Found that item_id: \\\u0022f7fd00bb-dba8-4c93-9d59-6cbd427b6330\\\u0022 already exists. Import of item_id: \\\u0022f7fd00bb-dba8-4c93-9d59-6cbd427b6330\\\u0022 skipped.",
        "status_code": 409
      },
      "item_id": "f7fd00bb-dba8-4c93-9d59-6cbd427b6330",
      "list_id": "7d7cccb8-db72-4667-b1f3-648efad7c1ee"
    }
  ],
  "success": "false,",
  "success_count": "0,",
  "success_count_exception_list_items": 0,
  "success_count_exception_lists": "0,",
  "success_exception_list_items": "false,",
  "success_exception_lists": "false,"
}
```

#### Without errors

```json
{
  "errors": [],
  "success": true,
  "success_count": 2,
  "success_count_exception_list_items": 1,
  "success_count_exception_lists": 1,
  "success_exception_list_items": true,
  "success_exception_lists": "true,"
}
```

#### Bad

```json
{
  "error": "Bad Request",
  "message": "Multipart part \u0060file\u0060 is required and must contain a valid .ndjson exception list export",
  "statusCode": 400
}
```

#### Unauthorized

```json
{
  "error": "Unauthorized",
  "message": "[security_exception\\n\\tRoot causes:\\n\\t\\tsecurity_exception: unable to authenticate user [elastic] for REST request [/_security/_authenticate]]: unable to authenticate user [elastic] for REST request [/_security/_authenticate]",
  "statusCode": 401
}
```

#### Forbidden

```json
{
  "error": "Forbidden",
  "message": "API [POST /api/exception_lists/_import] is unauthorized for user, this action is granted by the Kibana privileges [lists-all]",
  "statusCode": 403
}
```

#### Server error

```json
{
  "message": "Internal Server Error",
  "status_code": 500
}
```

