---
type: api
title: Delete a script or search template
description: Deletes a stored script or search template.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-delete-script
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-delete-script
products:
  - Elasticsearch
---

# Delete a script or search template

Availability:

## Paths

- `DELETE` `/_scripts/{id}`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/authentication#basicauth)
- [Bearer auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/authentication#bearerauth)

#### Path Parameters

- `id` (string Id)
  The identifier for the stored script or search template.

## Description

Deletes a stored script or search template.

## Required authorization

* Cluster privileges: `manage`

## Query String Parameters

- `master_timeout` (string Duration · default: 30s)
  The period to wait for a connection to the master node.
If no response is received before the timeout expires, the request fails and returns an error.
It can also be set to `-1` to indicate that the request should never timeout.
- `timeout` (string Duration · default: 30s)
  The period to wait for a response.
If no response is received before the timeout expires, the request fails and returns an error.
It can also be set to `-1` to indicate that the request should never timeout.

## Response

`application/json`

- `acknowledged` (boolean)
  For a successful response, this value is always true. On failure, an exception is returned instead.
## Code Examples

#### Console

```console
DELETE _scripts/my-search-template
```

#### JavaScript

```javascript
const response = await client.deleteScript({
  id: "my-search-template",
});
```

#### Python

```python
resp = client.delete_script(
    id="my-search-template",
)
```

#### curl

```curl
curl -X DELETE "$ELASTICSEARCH_URL/_scripts/my-search-template" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.deleteScript(d -> d
    .id("my-search-template")
);
```

#### C#

```c#
var response = await client.DeleteScriptAsync(id: "my-search-template");
```

#### PHP

```php
$resp = $client->deleteScript([
    "id" => "my-search-template",
]);
```

#### Ruby

```ruby
response = client.delete_script(
  id: "my-search-template"
)
```

