# exclude

[Read this page in HTML](https://www.scopedb.io/docs/reference/functions/semi-structured-data/exclude)

Removes specified array elements or object keys.

## Syntax

```scopeql
exclude(<source>, <excluded>)
```

## Arguments

| Argument     | Type                | Description                                                                         |
| ------------ | ------------------- | ----------------------------------------------------------------------------------- |
| `<source>`   | `array` or `object` | Array or object to filter.                                                          |
| `<excluded>` | `array`             | Array values or object keys to remove. For objects, non-string entries are ignored. |

## Returns

Returns the same type as `<source>`.

* For arrays, removes every matching element, including NULL. Retained elements keep their order and duplicates.
* For objects, removes the listed top-level keys. Nested keys are unchanged.
* If nothing remains, returns `[]` or `{}`.
* If either input is NULL, returns NULL.

## Examples

### Remove routine labels from an alert

Keep the labels that are relevant to triage by excluding routine markers.

```scopeql
SELECT exclude(
    ['checkout', 'heartbeat', 'timeout', 'debug'],
    ['heartbeat', 'debug']
) AS alert_labels
```

```text
+------------------------+
| alert_labels           |
+------------------------+
| ["checkout","timeout"] |
+------------------------+
```

### Remove fields from an exported summary

Exclude selected top-level keys when preparing a smaller event object for a report.

```scopeql
SELECT exclude(
    {'order_id': 'o-17', 'status': 'paid', 'debug': 'cache-hit'},
    ['debug']
) AS summary
```

```text
+-------------------------------------+
| summary                             |
+-------------------------------------+
| {"order_id":"o-17","status":"paid"} |
+-------------------------------------+
```
