---
type: api
title: Delete a synonym set
description: You can only delete a synonyms set that is not in use by any index analyzer.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/operation/operation-synonyms-delete-synonym
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/operation/operation-synonyms-delete-synonym
products:
  - Elasticsearch Serverless
---

# Delete a synonym set

Availability:

## Paths

- `DELETE` `/_synonyms/{id}`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/authentication#apikeyauth)

#### Path Parameters

- `id` (string Id)
  The synonyms set identifier to delete.

## Description

You can only delete a synonyms set that is not in use by any index analyzer.

Synonyms sets can be used in synonym graph token filters and synonym token filters.
These synonym filters can be used as part of search analyzers.

Analyzers need to be loaded when an index is restored (such as when a node starts, or the index becomes open).
Even if the analyzer is not used on any field mapping, it still needs to be loaded on the index recovery phase.

If any analyzers cannot be loaded, the index becomes unavailable and the cluster status becomes red or yellow as index shards are not available.
To prevent that, synonyms sets that are used in analyzers can't be deleted.
A delete request in this case will return a 400 response code.

To remove a synonyms set, you must first remove all indices that contain analyzers using it.
You can migrate an index by creating a new index that does not contain the token filter with the synonyms set, and use the reindex API in order to copy over the index data.
Once finished, you can delete the index.
When the synonyms set is not used in analyzers, you will be able to delete it.

## Required authorization

* Cluster privileges: `manage_search_synonyms`

## 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 _synonyms/my-synonyms-set
```

#### JavaScript

```javascript
const response = await client.synonyms.deleteSynonym({
  id: "my-synonyms-set",
});
```

#### Python

```python
resp = client.synonyms.delete_synonym(
    id="my-synonyms-set",
)
```

#### curl

```curl
curl -X DELETE "$ELASTICSEARCH_URL/_synonyms/my-synonyms-set" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.synonyms().deleteSynonym(d -> d
    .id("my-synonyms-set")
);
```

#### C#

```c#
var response = await client.Synonyms.DeleteSynonymAsync(id: "my-synonyms-set");
```

#### PHP

```php
$resp = $client->synonyms()->deleteSynonym([
    "id" => "my-synonyms-set",
]);
```

#### Ruby

```ruby
response = client.synonyms.delete_synonym(
  id: "my-synonyms-set"
)
```

