---
type: api
title: Update a runtime field
description: Update an existing runtime field in a data view. Only the fields provided in the request body are updated.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v0/operation/operation-updateruntimefielddefault
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v0/operation/operation-updateruntimefielddefault
products:
  - Kibana
---

# Update a runtime field

- Server: `https://{kibana_url}`

## Paths

- `POST` `/api/data_views/data_view/{viewId}/runtime_field/{fieldName}`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/kibana/v0/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/kibana/v0/authentication#basicauth)

#### Path Parameters

- `fieldName` (string)
  The name of the runtime field.
- `viewId` (string)
  An identifier for the data view.

## Description

Update an existing runtime field in a data view. Only the fields provided in the request body are updated.

## Request Body

`application/json`

- `runtimeField` (object) — required
  The runtime field definition object.

You can update following fields:

- `type`
- `script`

## Responses

#### `200`

Indicates a successful call.

#### `400`

Bad request

`application/json`

- `error` (string)
- `message` (string)
- `statusCode` (number)
## Code Examples

#### Console

```console
POST kbn://api/data_views/data_view/{viewId}/runtime_field/{fieldName}
{"runtimeField":{"type":"long","script":{"source":"emit(doc['timestamp'].value.getHour())"}}}
```

#### curl

```curl
curl \
  -X POST "${KIBANA_URL}/api/data_views/data_view/${DATA_VIEW_ID}/runtime_field/${FIELD_NAME}" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "kbn-xsrf: true" \
  -H "Content-Type: application/json" \
  -d '{"runtimeField":{"type":"long","script":{"source":"emit(doc['"'"'timestamp'"'"'].value.getHour())"}}}'
```

## Response Examples

#### A bad request response.

The request was rejected because the payload or query parameters are missing required fields or contain invalid values.

```json
{
  "error": "Bad Request",
  "message": "[request body.data_view.title]: expected value of type [string] but got [undefined]",
  "statusCode": 400
}
```

