---
type: api
title: Update a runtime field
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/kibana/v8/operation/operation-updateruntimefielddefault
resource: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/kibana/v8/operation/operation-updateruntimefielddefault
products:
  - Kibana
---

# Update a runtime field

Authentication: required

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

## Paths

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

#### Path parameters

- `space_id` (string) — optional
  An identifier for the space. If `space_id` is not provided in the URL, the default space is used. Refer to [Spaces](https://www.elastic.co/docs/deploy-manage/manage-spaces) for more information.
- `fieldName` (string) — required
  The name of the runtime field.
  Example: `hour_of_day`
- `viewId` (string) — required
  An identifier for the data view.
  Example: `ff959d40-b880-11e8-a6d9-e546fe2bba5f`

## 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/ff959d40-b880-11e8-a6d9-e546fe2bba5f/runtime_field/hour_of_day
{
  "runtimeField": {
    "script": {
      "source": "emit(doc[\u0022bar\u0022].value)"
    }
  }
}
```

#### curl

```curl
curl -X POST "${KIBANA_URL}/api/data_views/data_view/ff959d40-b880-11e8-a6d9-e546fe2bba5f/runtime_field/hour_of_day" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "runtimeField": {
      "script": {
        "source": "emit(doc[\u0022bar\u0022].value)"
      }
    }
  }'
```

## Response examples

#### 400

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{
  "error": "Bad Request",
  "message": "string",
  "statusCode": 400
}
```

