---
updatedAt: 2025-06-08T14:10:53.000Z
agentTools:
  projectIndex: https://developers.kommo.com/llms.txt
---

# Events filtration

There are two more parameters that you can use for events filtration: `"value_before"` and `"value_after"`.

The following values are available for the filter by before/after values at the moment:

* `leads_statuses` – filter by the lead stage, available for the `lead_status_changed event`
* `responsible_user_id` – filter by the responsible user, available for the `entity_responsible_changed event`
* `custom_field_values` – filter by the enum field value,\
  available for the `custom_field_{FIELD_ID}_value_changed` event, no more than 1 event type should be passed
* `value` – filter by the exact value, available for the\
  `nps_rate_added`, `sale_field_changed`, `name_field_changed`, `ltv_field_changed`, `custom_field_value_changed` events

## leads\_statuses

This filter allows to pass stage and pipeline IDs to get only required lead stage change events.

This is what the request could look like:

```json
filter[value_after][leads_statuses][0][pipeline_id]=12345&filter[value_after][leads_statuses][0][status_id]=99999999
```

In the example we’ll get all lead stage change events where the lead was moved to the stage 99999999 of the pipeline 12345.

## responsible\_user\_id

This filter allows to pass user IDs separated with commas to get only the required responsible user change events.

This is what the request could look like:

```json
filter[value_after][responsible_user_id]=5555555
```

Here we’ll get all responsible user change events for the user ID 5555555.

## custom\_field\_values

Filter by the **enum** field value, available for the `custom_field_{FIELD_ID}_value_changed` event, no more than 1 event type should be passed.

This filter allows to pass **enum** field values to get only required field values change events.

This is what the request could look like:

```json
filter[value_after][custom_field_values]=145&filter[type]=custom_field_777777_value_changed
```

In the following example we’ll get all field value change events for the field ID 777777 with **enum** ID 145.

## value

This filter allows to pass before/after values. It is only available for the following event types: `nps_rate_added`,\
`sale_field_changed`, `name_field_changed`, `ltv_field_changed`, `custom_field_value_changed`.

This is what the request could look like:

```json
filter[value_after][value]=155&filter[type]=sale_field_changed&filter[entity]=lead
```

Here we’ll get all lead sale change events where lead sale became equal to 155.

***

# Data structure of value\_after/before

If you want to write your own scripts to filter [events list](https://developers.kommo.com/reference/events-list), keep in mind the data structure of `value_after` and `value_before` fields depends on the event type and can have different values.

* **Event types**: `lead_deleted`, `lead_restored`, `contact_deleted`, `contact_restored`, `company_deleted`, `company_restored`, `entity_merged`, `task_added`, `task_deleted`, `task_completed`

| Parameter                   | Description | Type  |
| :-------------------------- | :---------- | :---- |
| value\_after\|value\_before | Empty array | array |

```json
{
    "value_after": [],
    "value_before": []
}
```

* **Event type**: `task_text_changed`

| Parameter                                 | Type   | Description                                                                 |
| :---------------------------------------- | :----- | :-------------------------------------------------------------------------- |
| value\_after\|value\_before               | array  | Array of event changes (this event type always has one change in the array) |
| value\_after\|value\_before\[task]        | obj    | Сhanged task data object                                                    |
| value\_after\|value\_before\[task]\[text] | string | Task text                                                                   |

```json
{
    "value_after": [
          {
            "task": {
              "text": "new task text"
            }
          }
        ],
    "value_before": [
          {
            "task": {
              "text": "old task text"
            }
          }
        ]
}
```

* **Event types**: `robot_replied` and `intent_identified`

| Parameter                     | Type   | Description                                                                 |
| :---------------------------- | :----- | :-------------------------------------------------------------------------- |
| value\_after                  | array  | Array of event changes (this event type always has one change in the array) |
| value\_after\[helpbot]        | obj    | Triggered intent data object                                                |
| value\_after\[helpbot]\[text] | string | Task text                                                                   |

```json
{
    "value_after": [
          {
            "helpbot": {
              "id": 145
            }
          }
        ]
}
```

* **Event type**: `transaction_added`

| Parameter                       | Type  | Description                                                                 |
| :------------------------------ | :---- | :-------------------------------------------------------------------------- |
| value\_after                    | array | Array of event changes (this event type always has one change in the array) |
| value\_after\[transaction]      | obj   | Transaction data object                                                     |
| value\_after\[transaction]\[id] | int   | Transaction ID                                                              |

```json
{
    "value_after": [
          {
            "transaction": {
              "id": 33675
            }
          }
        ]
}
```

<br />

* **Event types**: `lead_added`, `contact_added`, `company_added`, `common_note_added`, `common_note_deleted`, `attachment_note_added`, `targeting_in_note_added`, `targeting_out_note_added`, `geo_note_added`, `service_note_added`, `site_visit_note_added`, `message_to_cashier_note_added`, `incoming_call`, `outgoing_call`, `incoming_sms`, `outgoing_sms`, `link_followed`, `task_result_added`

| Parameter                | Type  | Description                                                                 |
| :----------------------- | :---- | :-------------------------------------------------------------------------- |
| value\_after             | array | Array of event changes (this event type always has one change in the array) |
| value\_after\[note]      | obj   | Note data object                                                            |
| value\_after\[note]\[id] | int   | Note ID                                                                     |

```json
{
    "value_after": [
          {
            "note": {
              "id": 7422564
            }
          }
        ]
}
```

* **Event type**: `nps_rate_added`

| Parameter                 | Type  | Description                                                                 |
| :------------------------ | :---- | :-------------------------------------------------------------------------- |
| value\_after              | array | Array of event changes (this event type always has one change in the array) |
| value\_after\[nps]        | obj   | NPS rate data object                                                        |
| value\_after\[nps]\[rate] | int   | Rate from 1 to 10                                                           |

```json
{
    "value_after": [
          {
            "nps": {
              "rate": 7
            }
          }
        ]
}
```

* **Event types**: `incoming_chat_message` and `outgoing_chat_message`

| Parameter                   | Type   | Description                                                                 |
| :-------------------------- | :----- | :-------------------------------------------------------------------------- |
| value\_after                | array  | Array of event changes (this event type always has one change in the array) |
| value\_after\[message]      | obj    | Message data object                                                         |
| value\_after\[message]\[id] | string | Message ID                                                                  |

```json
{
    "value_after": [
          {
            "message": {
              "id": "1508b51c-aab0-428e-9322-611d847ae747"
            }
          }
        ]
}
```

* **Event types**: `entity_tag_added` and `entity_tag_deleted`

| Parameter                                | Type   | Description            |
| :--------------------------------------- | :----- | :--------------------- |
| value\_after\|value\_before              | array  | Array of event changes |
| value\_after\|value\_before\[tag]        | obj    | Tag data object        |
| value\_after\|value\_before\[tag]\[name] | string | Tag name               |

```json
{
    "value_after": [
          {
            "tag": {
              "name": "tag 1"
            }
          }
        ],
    "value_before": [
          {
            "tag": {
              "name": "tag2"
            }
          },
          {
            "tag": {
              "name": "tag2"
            }
          }
        ]
}
```

* **Event type**: `lead_status_changed`

| Parameter                                                 | Type  | Description            |
| :-------------------------------------------------------- | :---- | :--------------------- |
| value\_after\|value\_before                               | array | Array of event changes |
| value\_after\|value\_before\[lead\_status]                | obj   | Status data object     |
| value\_after\|value\_before\[lead\_status]\[id]           | int   | Status ID              |
| value\_after\|value\_before\[lead\_status]\[pipeline\_id] | int   | Pipeline ID            |

```json
{
    "value_after": [
          {
            "lead_status": {
              "id": 5233224,
              "pipeline_id": 437642,
            }
          }
        ],
    "value_before": [
          {
            "lead_status": {
              "id": 5233224,
              "pipeline_id": 437642,
            }
          }
        ]
}
```

* Event types: `company_linked`, `company_unlinked`, `contact_linked`, `contact_unlinked`, `lead_linked`, `lead_unlinked`, `entity_linked`, `entity_unlinked`

| Parameter                                   | Type   | Description                                                                 |
| :------------------------------------------ | :----- | :-------------------------------------------------------------------------- |
| value\_after\|value\_before                 | array  | Array of event changes (this event type always has one change in the array) |
| value\_after\|value\_before\[link]\[type]   | string | Entity type                                                                 |
| value\_after\|value\_before\[link]\[id]     | int    | Entity ID                                                                   |
| value\_after\|value\_before\[unlink]\[type] | string | Entity type                                                                 |
| value\_after\|value\_before\[unlink]\[id]   | int    | Entity ID                                                                   |

```json
{
    "value_after": [
          {
            "link": {
              "entity": {
                "type": "lead",
                "id": 6232965
              }
            }
          }
        ],
    "value_before": []
}
```

* **Event type**: `entity_responsible_changed`

| Parameter                                            | Type  | Description            |
| :--------------------------------------------------- | :---- | :--------------------- |
| value\_after\|value\_before                          | array | Array of event changes |
| value\_after\|value\_before\[responsible\_user]      | obj   | User data object       |
| value\_after\|value\_before\[responsible\_user]\[id] | int   | User ID                |

```json
{
    "value_after": [
          {
            "responsible_user": {
              "id": 504329
            }
          }
        ],
    "value_before": [
          {
            "responsible_user": {
              "id": 37268
            }
          }
        ]
}
```

* **Event type**: `task_deadline_changed`

| Parameter                                                | Type  | Description               |
| :------------------------------------------------------- | :---- | :------------------------ |
| value\_after\|value\_before                              | array | Array of event changes    |
| value\_after\|value\_before\[task\_deadline]             | obj   | Task deadline data object |
| value\_after\|value\_before\[task\_deadline]\[timestamp] | int   | Deadline timestamp        |

```json
{
    "value_after": [
          {
            "task_deadline": {
              "timestamp": 1573595900
            }
          }
        ],
    "value_before": [
          {
            "task_deadline": {
              "timestamp": 1573578700
            }
          }
        ]
}
```

* **Event type**: `task_type_changed`

| Parameter                                     | Type  | Description            |
| :-------------------------------------------- | :---- | :--------------------- |
| value\_after\|value\_before                   | array | Array of event changes |
| value\_after\|value\_before\[task\_type]      | obj   | Task type data object  |
| value\_after\|value\_before\[task\_type]\[id] | int   | Task type ID           |

```json
{
    "value_after": [
          {
            "task_type": {
              "id": 504329
            }
          }
        ],
    "value_before": [
          {
            "task_type": {
              "id": 37268
            }
          }
        ]
}
```

* **Event type**: `custom_field_value_changed`

| Parameter                                                        | Type      | Description                                                 |
| :--------------------------------------------------------------- | :-------- | :---------------------------------------------------------- |
| value\_after\|value\_before                                      | array     | Array of event changes                                      |
| value\_after\|value\_before\[custom\_field\_value]\[field\_id]   | int       | Field ID                                                    |
| value\_after\|value\_before\[custom\_field\_value]\[field\_type] | int       | Task type ID                                                |
| value\_after\|value\_before\[custom\_field\_value]\[enum\_id]    | int\|null | Enum value ID or null if the field doesn’t have enum values |
| value\_after\|value\_before\[custom\_field\_value]\[text]        | string    | Field value text                                            |

```json
{
  "value_after": [
    {
      "custom_field_value": {
        "field_id": 53728,
        "field_type": 8,
        "enum_id": 2352876,
        "text": "example1@test.com"
      }
    },
    {
      "custom_field_value": {
        "field_id": 53728,
        "field_type": 8,
        "enum_id": 2352876,
        "text": "example@test.com"
      }
    }
  ],
  "value_before": [
    {
      "custom_field_value": {
        "field_id": 53728,
        "field_type": 8,
        "enum_id": 193200,
        "text": "example@test.com"
      }
    }
  ]
}
```