---
title: SET_KEY
url: https://www.tines.com/docs/formulas/functions/set-key/
kind: formula-function
---

*[tines.com](https://www.tines.com/llms.txt) › [Docs](https://www.tines.com/docs/llms.txt) › [Formulas](https://www.tines.com/llm/docs/formulas.md) › [Functions](https://www.tines.com/llm/docs/formulas/functions.md)*

# SET_KEY

*[View on tines.com](https://www.tines.com/docs/formulas/functions/set-key/)*

Sets an object key to a value. If the key already exists, it will be overwritten. Nested keys can be specified using dot notation.

**Categories:** Objects

## Syntax

```
SET_KEY(object, path, value)
```

## Examples

### Example 1: Adds new keys

Formula:

```
SET_KEY({"name": "Marvin"}, "hair", "brown")
```

Output:

```json
{
  "hair": "brown",
  "name": "Marvin"
}
```

### Example 2: Overwrites keys

Formula:

```
SET_KEY({"name": "Marvin", "age": 30}, "age", 31)
```

Output:

```json
{
  "age": 31,
  "name": "Marvin"
}
```

### Example 3: Works on nested object paths

Formula:

```
SET_KEY({"name": "Marvin", "job": {"company": "Tines", "role": "Software Engineer"}}, "job.role", "Manager")
```

Output:

```json
{
  "job": {
    "company": "Tines",
    "role": "Manager"
  },
  "name": "Marvin"
}
```

### Example 4: Escape dots with backslash

Formula:

```
SET_KEY({".ie": "Ireland"}, "\.co\.uk", "United Kingdom")
```

Output:

```json
{
  ".co.uk": "United Kingdom",
  ".ie": "Ireland"
}
```
