# keys

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

Returns the top-level keys of an object.

## Syntax

```scopeql
keys(<object>)
```

## Arguments

| Argument   | Type     | Description        |
| ---------- | -------- | ------------------ |
| `<object>` | `object` | Object to inspect. |

## Returns

Returns `array` of strings. An empty object returns `[]`. Returns NULL if the input is NULL.

## Examples

Inspect top-level keys before selecting fields from events with different payload shapes.

```scopeql
VALUES
    ('evt-17', {'channel': 'web', 'campaign': 'spring'}),
    ('evt-42', {'channel': 'mobile', 'coupon': 'WELCOME'})
SELECT $0 AS event_id, $1 AS payload
SELECT event_id, keys(payload) AS attributes
```

```text
+----------+------------------------+
| event_id | attributes             |
+----------+------------------------+
| evt-17   | ["campaign","channel"] |
| evt-42   | ["channel","coupon"]   |
+----------+------------------------+
```

The key order may vary. Use `schema` to summarize observed keys and types across multiple events.
