---
type: api
title: Run a script
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/v8/operation/operation-runscriptaction
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/v8/operation/operation-runscriptaction
products:
  - Kibana
---

# Run a script

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

## Paths

- `POST` `/api/endpoint/action/runscript`
- `POST` `/s/{space_id}/api/endpoint/action/runscript`

## Description

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

Run a shell command on an endpoint.

## Authentication

- Api key: `Authorization: <value>`
  These APIs use key-based authentication. You must create an API key and use the encoded value in the request header. For example: `Authorization: ApiKey base64AccessApiKey`
- Basic: `Authorization: Basic <credentials>`

## Request body

`application/json`

- `parameters` (union oneOf) — required
  Exactly one of 'Raw', 'HostPath', or 'CloudFile' must be provided. CommandLine and Timeout are optional for all.
  - **{ raw }**
    - `commandLine` (string · min length: 1) — optional
      Command line arguments.
    - `raw` (string · min length: 1) — required
      Raw script content.
    - `timeout` (integer · min: 1) — optional
      Timeout in seconds.
  - **{ hostPath }**
    - `commandLine` (string · min length: 1) — optional
      Command line arguments.
    - `hostPath` (string · min length: 1) — required
      Absolute or relative path of script on host machine.
    - `timeout` (integer · min: 1) — optional
      Timeout in seconds.
  - **{ cloudFile }**
    - `cloudFile` (string · min length: 1) — required
      Script name in cloud storage.
    - `commandLine` (string · min length: 1) — optional
      Command line arguments.
    - `timeout` (integer · min: 1) — optional
      Timeout in seconds.

## Response

OK

`application/json`

Type: `object`

## Code examples

#### Console

```console
POST kbn:/api/endpoint/action/runscript
{
  "parameters": {
    "raw": "string"
  }
}
```

#### curl

```curl
curl -X POST "${KIBANA_URL}/api/endpoint/action/runscript" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "parameters": {
      "raw": "string"
    }
  }'
```

