---
type: api
title: Create script
description: Create a new script entry by uploading a script file
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v0/operation/operation-endpointscriptlibrarycreatescript
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v0/operation/operation-endpointscriptlibrarycreatescript
products:
  - Kibana
---

# Create script

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

## Paths

- `POST` `/api/endpoint/scripts_library`

- [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)

## Description

Create a new script entry by uploading a script file

## Request Body

`multipart/form-data`

- `description` (string · max: 10000) — optional
  Description of the script and its purpose/functionality
- `example` (string · max: 10000) — optional
  Example usage of the script
- `file` (object) — required
  The script file upload
- `fileType` (enum) — required
  The type of the uploaded file, which determines the expected value of `pathToExecutable`. If `fileType` is "script", then `pathToExecutable` should not be included. If `fileType` is "archive", then `pathToExecutable` is required and should specify the path to the executable file within the archive.
  Values: `script`, `archive`
- `instructions` (string · max: 10000) — optional
  Instructions for using the script, including details around its supported input arguments
- `name` (string · min: 1 · max: 256) — required
  Name of the script
- `pathToExecutable` (string · max: 4096) — optional
  Used only for when the uploaded script is an archive (.zip file for example). This property defines the relative path to the file included in the archive that should be executed once its contents are extracted. The path should be relative to the root of the archive.
- `platform` ([] enum) — required
  Platforms supported by the the script
  Values: `linux`, `macos`, `windows`
- `requiresInput` (boolean) — optional
  Whether the script requires input arguments
- `tags` ([] enum) — optional
  Tags to categorize the script
  Values: `remediationAction`, `dataCollection`, `networkDiagnostics`, `networkAction`, `systemInventory`, `forensicCollection`, `threatHunting`, `discovery`, `systemManagement`, `userManagement`, `troubleshooting`

## Response

Action request was successfully created

`application/json`

- `data` ({})
  - `createdAt` (string)
  - `createdBy` (string)
  - `description` (string)
    Description of the script and its purpose/functionality
  - `downloadUri` (string)
    URI to download the script file. Note that this is the relative path and does not include the space (if applicable)
  - `example` (string)
  - `fileHash` (string)
    SHA256 hash of the script file that was uploaded
  - `fileName` (string)
    Name of the script file that was uploaded
  - `fileSize` (integer)
    Size of the script file that was uploaded in bytes
  - `id` (string)
  - `instructions` (string)
    Instructions for using the script, including details around its supported input arguments
  - `name` (string)
  - `pathToExecutable` (string)
    The relative path to the file included in the archive that should be executed once its contents are extracted. Applicable only for scripts uploaded as an archive (.zip file for example).
  - `platform` ([] enum)
    Values: `linux`, `macos`, `windows`
  - `requiresInput` (boolean)
  - `tags` ([] enum)
    Tags that categorize the script
    Values: `remediationAction`, `dataCollection`, `networkDiagnostics`, `networkAction`, `systemInventory`, `forensicCollection`, `threatHunting`, `discovery`, `systemManagement`, `userManagement`, `troubleshooting`
  - `updatedAt` (string)
  - `updatedBy` (string)
  - `version` (string)
## Code Examples

#### Console

```console
POST /api/endpoint/scripts_library
{
  "description": "Collects host data for investigation",
  "example": "./collect_host_data.sh --help",
  "file": "./collect_host_data.zip",
  "fileType": "archive",
  "instructions": "Collects host data for investigation",
  "name": "Collect host data",
  "pathToExecutable": "./bin/collect_host_data.sh",
  "platform": [
    "linux",
    "macos"
  ],
  "requiresInput": false
}
```

#### curl

```curl
curl -X POST "https://{kibana_url}/api/endpoint/scripts_library" \
  -H "Content-Type: multipart/form-data" \
  -d '{
  "description": "Collects host data for investigation",
  "example": "./collect_host_data.sh --help",
  "file": "./collect_host_data.zip",
  "fileType": "archive",
  "instructions": "Collects host data for investigation",
  "name": "Collect host data",
  "pathToExecutable": "./bin/collect_host_data.sh",
  "platform": [
    "linux",
    "macos"
  ],
  "requiresInput": false
}'
```

## Response Examples

#### Create a script entry

```json
{
  "data": {
    "description": "Collects host data for investigation",
    "file": "./collect_host_data.sh",
    "fileType": "script",
    "id": 1234567890,
    "instructions": "No arguments required",
    "name": "Collect host data",
    "platform": [
      "linux",
      "macos"
    ]
  }
}
```

