---
type: api
title: Stop a trained model deployment
description: ## Required authorization
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v9/operation/operation-ml-stop-trained-model-deployment
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v9/operation/operation-ml-stop-trained-model-deployment
products:
  - Elasticsearch
---

# Stop a trained model deployment

Availability: Generally available since 8.0

## Paths

- `POST` `/_ml/trained_models/{model_id}/deployment/_stop`

#### Path parameters

- `model_id` (string) — required
  The unique identifier of the trained model.

## Required authorization

- Cluster privileges: `manage_ml`

## Authentication

- Api key: `Authorization: <value>`
  Elasticsearch APIs support key-based authentication.
  You must create an API key and use the encoded value in the request header.
  For example:
  
  
  ```
  curl -X GET "${ES_URL}/_cat/indices?v=true" \
    -H "Authorization: ApiKey ${API_KEY}"
  ```
  
  To get API keys, use the `/_security/api_key` APIs.
- Basic: `Authorization: Basic <credentials>`
- Bearer: `Authorization: Bearer <token>`
  Elasticsearch APIs support the use of bearer tokens in the `Authorization` HTTP header to authenticate with the API.
  For examples, refer to [Token-based authentication services](https://www.elastic.co/docs/deploy-manage/users-roles/cluster-or-deployment-auth/token-based-authentication-services)

## Query string parameters

- `allow_no_match` (boolean · default: true) — optional
  Specifies what to do when the request: contains wildcard expressions and there are no deployments that match;
contains the  `_all` string or no identifiers and there are no matches; or contains wildcard expressions and
there are only partial matches. By default, it returns an empty array when there are no matches and the subset of results when there are partial matches.
If `false`, the request returns a 404 status code when there are no matches or only partial matches.
- `force` (boolean · default: false) — optional
  Forcefully stops the deployment, even if it is used by ingest pipelines. You can't use these pipelines until you
restart the model deployment.

## Request body

`application/json`

- `id` (string) — optional
  If provided, must be the same identifier as in the path.
- `allow_no_match` (boolean · default: true) — optional
  Specifies what to do when the request: contains wildcard expressions and there are no deployments that match;
contains the  `_all` string or no identifiers and there are no matches; or contains wildcard expressions and
there are only partial matches. By default, it returns an empty array when there are no matches and the subset of results when there are partial matches.
If `false`, the request returns a 404 status code when there are no matches or only partial matches.
- `force` (boolean · default: false) — optional
  Forcefully stops the deployment, even if it is used by ingest pipelines. You can't use these pipelines until you
restart the model deployment.

## Response

`application/json`

- `stopped` (boolean)
## Code examples

#### Console

```console
POST _ml/trained_models/my_model_for_search/deployment/_stop
```

#### JavaScript

```javascript
const response = await client.ml.stopTrainedModelDeployment({
  model_id: "my_model_for_search",
});
```

#### Python

```python
resp = client.ml.stop_trained_model_deployment(
    model_id="my_model_for_search",
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_ml/trained_models/my_model_for_search/deployment/_stop" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.ml().stopTrainedModelDeployment(s -> s
    .modelId("my_model_for_search")
);
```

#### C#

```c#
var response = await client.MachineLearning.StopTrainedModelDeploymentAsync(modelId: "my_model_for_search");
```

#### PHP

```php
$resp = $client->ml()->stopTrainedModelDeployment([
    "model_id" => "my_model_for_search",
]);
```

#### Ruby

```ruby
response = client.ml.stop_trained_model_deployment(
  model_id: "my_model_for_search"
)
```

