---
title: "Create a runtime field"
method: POST
path: "/api/data_views/data_view/{viewId}/runtime_field"
tags: ["data views"]
---

# Create a runtime field

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

**Spaces method and path for this operation:**

<div><span class="operation-verb post">post</span>&nbsp;<span class="operation-path">/s/{space_id}/api/data_views/data_view/{viewId}/runtime_field</span></div>

Refer to [Spaces](https://www.elastic.co/docs/deploy-manage/manage-spaces) for more information.

Create a runtime field for a data view. Runtime fields are computed at query time using a [Painless script](https://www.elastic.co/docs/explore-analyze/scripting/modules-scripting-painless) and do not require reindexing. If no `script` is provided, the runtime field returns the corresponding value from the document `_source`.

## Path parameters

- `viewId` string, required

## Headers

- `kbn-xsrf` string, required

## Request body

- object
  - `name` string, required — The name for a runtime field.
  - `runtimeField` object, required — The runtime field definition object.

## Response `200`

Indicates a successful call.

- object

---

[API](https://skmtc.net/elastic/apis/kibana-apis.md) · [All operations](https://skmtc.net/elastic/apis/kibana-apis/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/elastic/kibana-apis/versions/531c9e2a7d23/schema)
