> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bringits.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Key Mapping

> Map existing object keys to new keys

The Key Mapping command (Command Type: 1005) maps existing object keys to new keys using a list of mapping rules. Each rule extracts a value via a JSONPath query and assigns it to a new key name.

## Overview

The Key Mapping command provides functionality for:

* Renaming object fields to match a target schema
* Extracting nested values and promoting them to top-level keys
* Applying consistent field naming across all objects in a collection

## Command Type

**Command Type ID:** 1005

## Parameters

| Parameter   | Type                | Description                                                      | Required |
| ----------- | ------------------- | ---------------------------------------------------------------- | -------- |
| **mapping** | Array of KeyMapping | Defines the rules for extracting data and mapping it to new keys | Yes      |

### KeyMapping

| Field    | Type   | Description                                               | Required |
| -------- | ------ | --------------------------------------------------------- | -------- |
| **to**   | string | The new key to which the extracted value will be assigned | Yes      |
| **from** | string | A JSONPath query string to extract the value              | No       |

## Usage Examples

### Rename Fields

```json theme={null}
{
  "command": "key-mapping",
  "params": {
    "mapping": [
      { "from": "$.eventId", "to": "id" },
      { "from": "$.eventName", "to": "name" },
      { "from": "$.startTime", "to": "startsAt" }
    ]
  }
}
```

### Promote Nested Fields

```json theme={null}
{
  "command": "key-mapping",
  "params": {
    "mapping": [
      { "from": "$.event.id", "to": "eventId" },
      { "from": "$.event.sport.id", "to": "sportId" },
      { "from": "$.event.league.id", "to": "leagueId" }
    ]
  }
}
```

### Map Without Source Path

```json theme={null}
{
  "command": "key-mapping",
  "params": {
    "mapping": [
      { "to": "payload" }
    ]
  }
}
```

## Common Use Cases

* **Schema Normalization**: Rename incoming fields to match your internal schema
* **Field Promotion**: Lift nested values to the top level for easier access
* **Data Standardization**: Apply consistent field naming across multiple data sources

## Related Commands

* [Key Mapping With JSONPath](/stream/commands/parse/key-mapping-jsonpath) - Extract and map using complex JSONPath
* [Object Mapper](/stream/commands/parse/object-mapper) - Full object transformation with mapping config
* [Transform By JDM](/stream/commands/parse/transform) - Transform using JDM mapping rules
