---
type: api
title: Apply a bulk action to anonymization fields
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v9/operation/operation-performanonymizationfieldsbulkaction
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v9/operation/operation-performanonymizationfieldsbulkaction
products:
  - Kibana
---

# Apply a bulk action to anonymization fields

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

## Paths

- `POST` `/api/security_ai_assistant/anonymization_fields/_bulk_action`
- `POST` `/s/{space_id}/api/security_ai_assistant/anonymization_fields/_bulk_action`

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

## Description

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

Apply a bulk action to multiple anonymization fields. The bulk action is applied to all anonymization fields that match the filter or to the list of anonymization fields by their IDs.

## Request Body

`application/json`

- `create` ([] object) — optional
  Array of anonymization fields to create.
  - `allowed` (boolean) — optional
    Whether this field is allowed to be sent to the model.
  - `anonymized` (boolean) — optional
    Whether this field should be anonymized.
  - `field` (string) — required
    Name of the anonymization field to create.
- `delete` (object) — optional
  Object containing the query to filter anonymization fields and/or an array of anonymization field IDs to delete.
  - `ids` ([] string · min: 1) — optional
    Array of IDs to apply the action to.
  - `query` (string) — optional
    Query to filter the bulk action.
- `update` ([] object) — optional
  Array of anonymization fields to update.
  - `allowed` (boolean) — optional
    Whether this field is allowed to be sent to the model.
  - `anonymized` (boolean) — optional
    Whether this field should be anonymized.
  - `id` (string) — required
    The ID of the anonymization field to update.

## Responses

#### `200`

Indicates a successful call.

`application/json`

- `anonymization_fields_count` (integer)
  Total number of anonymization fields processed.
- `attributes` (object)
  - `errors` ([] object)
    List of errors that occurred during the bulk operation.
    - `anonymization_fields` ([] object)
      Array of anonymization fields that caused the error.
      - `id` (string)
        The ID of the anonymization field.
      - `name` (string)
        Name of the anonymization field.
    - `err_code` (string)
      Error code indicating the type of failure.
    - `message` (string)
      Error message.
    - `status_code` (integer)
      Status code of the response.
  - `results` ({})
    - `created` ([] object)
      List of anonymization fields successfully created.
      - `allowed` (boolean)
        Whether this field is allowed to be sent to the model.
      - `anonymized` (boolean)
        Whether this field should be anonymized.
      - `createdAt` (string)
        Timestamp of when the anonymization field was created.
      - `createdBy` (string)
        Username of the person who created the anonymization field.
      - `field` (string)
        Name of the anonymization field.
      - `id` (string · min: 1)
        A string that does not contain only whitespace characters.
      - `namespace` (string)
        Kibana space in which this anonymization field exists.
      - `timestamp` (string · min: 1)
        A string that represents a timestamp in ISO 8601 format and does not contain only whitespace characters.
      - `updatedAt` (string)
        Timestamp of the last update.
      - `updatedBy` (string)
        Username of the person who last updated the field.
    - `deleted` ([] string)
    - `skipped` ([] object)
      List of anonymization fields that were skipped during the operation.
      - `id` (string)
        The ID of the anonymization field that was not modified.
      - `name` (string)
        Name of the anonymization field that was not modified.
      - `skip_reason` (enum)
        Reason why the anonymization field was not modified.
        Values: `ANONYMIZATION_FIELD_NOT_MODIFIED`
    - `updated` ([] object)
      List of anonymization fields successfully updated.
      Same fields as `created` in `results`
  - `summary` ({})
    - `failed` (integer)
      The number of failed actions.
    - `skipped` (integer)
      The number of skipped actions.
    - `succeeded` (integer)
      The number of successfully performed actions.
    - `total` (integer)
      The total number of actions attempted.
- `message` (string)
  Message providing information about the bulk action result.
- `status_code` (integer)
  HTTP status code returned.
- `success` (boolean)
  Indicates if the bulk action was successful.
#### `400`

Bad Request response.

`application/json`

- `error` (string)
  Error type or name.
- `message` (string)
  Detailed error message.
- `statusCode` (number)
  Status code of the response.
## Code Examples

#### curl

```curl
curl \
 --request POST 'http://localhost:5601/api/security_ai_assistant/anonymization_fields/_bulk_action' \
 --header "Authorization: $API_KEY" \
 --header "Content-Type: application/json" \
 --data '{"create":[{"field":"host.name","allowed":true,"anonymized":false}]}'
```

## Request Examples

#### Perform anonymization fields bulk action

```json
{
  "create": [
    {
      "allowed": true,
      "anonymized": false,
      "field": "host.name"
    },
    {
      "allowed": false,
      "anonymized": true,
      "field": "user.name"
    }
  ],
  "delete": {
    "ids": [
      "field5",
      "field6"
    ],
    "query": "field: host.name"
  },
  "update": [
    {
      "allowed": true,
      "anonymized": false,
      "id": "field8"
    },
    {
      "allowed": false,
      "anonymized": true,
      "id": "field9"
    }
  ]
}
```

## Response Examples

#### Perform anonymization fields bulk action response200

```json
{
  "anonymization_fields_count": 4,
  "attributes": {
    "results": {
      "created": [
        {
          "allowed": false,
          "anonymized": true,
          "createdAt": "2023-10-31T12:00:00Z",
          "createdBy": "user1",
          "field": "host.name",
          "id": "field2",
          "namespace": "default",
          "timestamp": "2023-10-31T12:00:00Z",
          "updatedAt": "2023-10-31T12:00:00Z",
          "updatedBy": "user1"
        }
      ],
      "deleted": [
        "field3"
      ],
      "skipped": [
        {
          "id": "field4",
          "name": "user.name",
          "skip_reason": "ANONYMIZATION_FIELD_NOT_MODIFIED"
        }
      ],
      "updated": [
        {
          "allowed": true,
          "anonymized": false,
          "createdAt": "2023-10-31T12:00:00Z",
          "createdBy": "user1",
          "field": "url.domain",
          "id": "field8",
          "namespace": "default",
          "timestamp": "2023-10-31T12:00:00Z",
          "updatedAt": "2023-10-31T12:00:00Z",
          "updatedBy": "user1"
        }
      ]
    },
    "summary": {
      "failed": 0,
      "skipped": 1,
      "succeeded": 3,
      "total": 4
    }
  },
  "message": "Bulk action completed successfully",
  "status_code": 200,
  "success": true
}
```

#### Perform anonymization fields bulk action response400

```json
{
  "error": "Bad Request",
  "message": "Invalid request body",
  "statusCode": 400
}
```

