---
title: Deploy a serving endpoint with the CLI and bundles
description: Create, check, update, and delete a Model Serving endpoint with the Databricks CLI, and deploy one endpoint from a bundle.
canonical_url: https://docs.databricks.com/aws/en/machine-learning/model-serving/model-serving-cli-bundles
---

# Deploy a serving endpoint with the CLI and bundles

Use the Databricks CLI to create, check, update, and delete a Model Serving endpoint, or to deploy one endpoint from a bundle.

The CLI steps use `databricks serving-endpoints` commands. The bundle steps define an endpoint in a `databricks.yml` file, and `databricks bundle deploy` creates or updates it. The examples create two endpoints, `cli-endpoint` and `bundle-endpoint`, and both can exist at the same time. To create an endpoint in the Serving UI or with the REST API, see [Create an endpoint for custom models in Model Serving](https://docs.databricks.com/aws/en/machine-learning/model-serving/create-manage-serving-endpoints.md).

## Requirements

* Databricks CLI, v0.218.0 or above for the bundle steps. To install it, see [Install or update the Databricks CLI](https://docs.databricks.com/aws/en/dev-tools/cli/install.md).
* A custom model registered in Unity Catalog. Unity Catalog requires a [signature](https://docs.databricks.com/aws/en/machine-learning/model-serving/custom-models.md#signature-and-input-examples) on each new model version. The examples serve version 1 of `<catalog>.<schema>.cli_model`. Replace `<catalog>` and `<schema>` with your catalog and schema.
* Signed in to the workspace from the CLI with [`databricks auth login`](https://docs.databricks.com/aws/en/dev-tools/cli/authentication.md). Add `--profile <name>` to use another profile.
* `jq`, which the `get` commands pipe through.

## Create an endpoint with the CLI

### <a id="check-the-cli-version" />Check the CLI version

Run the following command:

```bash
databricks version
```

The command prints the installed version, such as `Databricks CLI v1.17.0`.

### <a id="save-the-endpoint-settings" />Save the endpoint settings

Save the endpoint settings in `create.json`:

```json
{
  "name": "cli-endpoint",
  "config": {
    "served_entities": [
      {
        "name": "cli-example",
        "entity_name": "<catalog>.<schema>.cli_model",
        "entity_version": "1",
        "workload_size": "Small",
        "scale_to_zero_enabled": true
      }
    ],
    "traffic_config": {
      "routes": [
        {
          "served_entity_name": "cli-example",
          "traffic_percentage": 100
        }
      ]
    }
  }
}
```

With `--json`, the body holds `name` at the top level, and `config` holds `served_entities` and `traffic_config`. The `entity_name` is the full name of a Unity Catalog model, and `entity_version` is given as a string. The endpoint name can use alphanumeric characters, dashes, and underscores, must start and end with a letter or digit, and can't be longer than 63 characters on create.

### <a id="create-the-endpoint" />Create the endpoint

Run the following command:

```bash
databricks serving-endpoints create --json @create.json
```

The command prints the endpoint as JSON. When it returns, `ready` is READY and `config_update` is NOT\_UPDATING. Without `--no-wait`, the command returns when `config_update` reaches NOT\_UPDATING, and the default timeout is 20 minutes. To return before the endpoint is ready, add `--no-wait`, and the command returns while `config_update` is IN\_PROGRESS and `ready` is NOT\_READY.

## <a id="check-the-endpoint-with-the-cli" />Check the endpoint with the CLI

Read the endpoint state by running:

```bash
databricks serving-endpoints get cli-endpoint -o json | jq "{ready: .state.ready, config_update: .state.config_update, config_version: .config.config_version}"
```

The command prints the following.

```text
{
  "ready": "READY",
  "config_update": "NOT_UPDATING",
  "config_version": 1
}
```

The `config_update` field takes NOT\_UPDATING, IN\_PROGRESS, UPDATE\_FAILED, or UPDATE\_CANCELED. For a new endpoint, `ready` is NOT\_READY until its deployment finishes, and READY after that. During an update to a running endpoint, `ready` stays READY. When an update finishes successfully, `config_update` returns to NOT\_UPDATING at the same time that `ready` is READY. The `config_version` field is the number of the active configuration.

A READY endpoint can still return a 404 to a query for a short time. The error reads `The given endpoint is not ready to serve traffic yet, please retry later.` No field that `get` returns shows the state behind that 404, so READY doesn't show whether the next query is accepted.

## <a id="update-the-endpoint-with-the-cli" />Update the endpoint with the CLI

### <a id="save-the-new-settings" />Save the new settings

Save the new settings in `update.json`:

```json
{
  "served_entities": [
    {
      "name": "cli-example",
      "entity_name": "<catalog>.<schema>.cli_model",
      "entity_version": "1",
      "workload_size": "Small",
      "scale_to_zero_enabled": false
    }
  ],
  "traffic_config": {
    "routes": [
      {
        "served_entity_name": "cli-example",
        "traffic_percentage": 100
      }
    ]
  }
}
```

This body has `served_entities` and `traffic_config` at the top level, and it has no `name` and no `config` object. If you send `name` or a `config` object, the CLI warns that it doesn't know those fields, and the update exits with an error, so leave them out.

### <a id="update-the-endpoint" />Update the endpoint

Run the following command:

```bash
databricks serving-endpoints update-config cli-endpoint --json @update.json
```

The command returns when `config_update` reaches NOT\_UPDATING.

### <a id="read-the-endpoint-after-the-update" />Read the endpoint after the update

Run the following command:

```bash
databricks serving-endpoints get cli-endpoint -o json | jq "{ready: .state.ready, config_update: .state.config_update, config_version: .config.config_version, scale_to_zero: [.config.served_entities[].scale_to_zero_enabled]}"
```

The command prints the following.

```text
{
  "ready": "READY",
  "config_update": "NOT_UPDATING",
  "config_version": 2,
  "scale_to_zero": [
    false
  ]
}
```

The `config_version` is 2, and `scale_to_zero` shows false, the value in `update.json`. While the update runs, `config_update` shows IN\_PROGRESS, and `config_version` keeps the old number. The old configuration keeps serving until the new one is ready.

## Delete the endpoint with the CLI

### <a id="delete-the-endpoint" />Delete the endpoint

Run the following command:

```bash
databricks serving-endpoints delete cli-endpoint
```

A successful delete returns no output and exit code 0.

### <a id="check-that-the-endpoint-is-gone" />Check that the endpoint is gone

Run the following command:

```bash
databricks serving-endpoints get cli-endpoint
```

The command prints the following.

```text
Error: Endpoint with name 'cli-endpoint' does not exist.
```

The command exits with code 1 and this error, which means the endpoint is gone. Deleting an endpoint can't be undone.

## Deploy an endpoint from a bundle

Declarative Automation Bundles (formerly known as Databricks Asset Bundles) are a feature of the Databricks CLI. The bundle commands start with `databricks bundle`.

### <a id="write-the-bundle-file" />Write the bundle file

Write the bundle file as `databricks.yml`:

```yaml
bundle:
  name: cli-bundles-example

targets:
  dev:
    default: true
    workspace:
      host: <workspace-url>

resources:
  model_serving_endpoints:
    cli_example:
      name: bundle-endpoint
      config:
        served_entities:
          - name: cli-example
            entity_name: <catalog>.<schema>.cli_model
            entity_version: '1'
            workload_size: Small
            scale_to_zero_enabled: true
        traffic_config:
          routes:
            - served_entity_name: cli-example
              traffic_percentage: 100
```

Replace `<workspace-url>` with your workspace URL. The `targets` block holds named targets. The examples use one target, `dev`, and set it as the default with `default: true`. The endpoint goes under `model_serving_endpoints`, and the key, `cli_example` here, names the resource in the deploy output. The `name` is the endpoint name, and it must be unique across the workspace.

Each served entity has fields such as `entity_name`, `entity_version`, `workload_size`, and `scale_to_zero_enabled`. The `workload_size` field takes `Small`, `Medium`, or `Large`. Don't set it together with min or max provisioned concurrency. For those settings, see [Create an endpoint for custom models in Model Serving](https://docs.databricks.com/aws/en/machine-learning/model-serving/create-manage-serving-endpoints.md). In this file, each route names its served entity with `served_entity_name`, and the `traffic_percentage` values must total 100.

### <a id="validate-the-bundle" />Validate the bundle

Run the following command:

```bash
databricks bundle validate --target dev
```

The command prints the following.

```text
Name: cli-bundles-example
Target: dev
Workspace:
  Host: <workspace-url>
  User: <user>
  Path: /Workspace/Users/<user>/.bundle/cli-bundles-example/dev

Validation OK!
```

The command checks the bundle, and the output ends with `Validation OK!`. To treat warnings as errors, add `--strict`, which needs CLI v0.286.0 or above.

### <a id="deploy-the-bundle" />Deploy the bundle

Run the following command:

```bash
databricks bundle deploy --target dev
```

The command prints the following.

```text
Uploading bundle files to /Workspace/Users/<user>/.bundle/cli-bundles-example/dev/files...
Created model_serving_endpoints.cli_example
Files: 1 uploaded, 0 deleted
Resources: 1 created, 0 changed, 0 deleted, 0 unchanged
```

The deploy returns after `ready` is READY and `config_update` is NOT\_UPDATING, and its output doesn't show that it is waiting.

After the deploy, read the state with the `get` command in [Check the endpoint with the CLI](https://docs.databricks.com/aws/en/machine-learning/model-serving/model-serving-cli-bundles.md#check-the-endpoint-with-the-cli), using `bundle-endpoint`. The first deploy leaves `ready` `READY`, `config_update` `NOT_UPDATING`, and `config_version` `1`. With `mode: development` set on the target, the resolved name is `dev_<user>_bundle-endpoint`.

## Update or destroy a bundle endpoint

### <a id="change-the-bundle-and-deploy-again" />Change the bundle and deploy again

Change `scale_to_zero_enabled` from `true` to `false` in `databricks.yml`, and deploy again:

```bash
databricks bundle deploy --target dev
```

The command prints the following.

```text
Uploading bundle files to /Workspace/Users/<user>/.bundle/cli-bundles-example/dev/files...
Updated model_serving_endpoints.cli_example
Files: 1 uploaded, 0 deleted
Resources: 0 created, 1 changed, 0 deleted, 0 unchanged
```

The deploy returns when `config_update` reaches NOT\_UPDATING. An update can fail. See [An update fails during a bundle deploy](https://docs.databricks.com/aws/en/machine-learning/model-serving/model-serving-cli-bundles.md#an-update-fails-during-a-bundle-deploy). A failed update still uses a config version number, so the next successful update can skip one.

### <a id="destroy-the-bundle" />Destroy the bundle

Run the following command:

```bash
databricks bundle destroy --target dev --auto-approve
```

The command removes the resources that the bundle created. The `--auto-approve` flag skips the interactive approval for deleting the bundle's resources and files. To approve the deletion yourself, run the command without the flag in a terminal.

The last lines of its output are the following.

```text
The following resources will be deleted:
  delete resources.model_serving_endpoints.cli_example

All files and directories at the following location will be deleted: /Workspace/Users/<user>/.bundle/cli-bundles-example/dev

Destroy: 1 deleted
```

### <a id="check-that-the-bundle-endpoint-is-gone" />Check that the bundle endpoint is gone

Run the following command:

```bash
databricks serving-endpoints get bundle-endpoint
```

The command prints the following, which says the endpoint does not exist.

```text
Error: Endpoint with name 'bundle-endpoint' does not exist.
```

## Troubleshooting

### The name is passed as an argument with --json

The command exits with code 1 and prints this error.

```text
Error: when --json flag is specified, no positional arguments are allowed. Provide 'name' in your JSON input
```

**Cause:** The CLI rejects a name argument when `--json` is set, and no endpoint is created.

**Solution:** Remove the name argument, and put the name in the JSON body, as the create body above does. The create command then returns the endpoint named `cli-endpoint`.

### <a id="an-update-fails-during-a-bundle-deploy" />An update fails during a bundle deploy

The deploy exits with an error after it waits. The error says the endpoint failed to reach NOT\_UPDATING, and that the current status is UPDATE\_FAILED.

**Cause:** The update didn't finish, so `config_update` shows UPDATE\_FAILED, and the active configuration keeps serving.

**Solution:** Run the same deploy again. To read the message that the failed update left, look at `pending_config` in the output of `databricks serving-endpoints get bundle-endpoint -o json`. `pending_config` holds the version that the failed update was applying. The message says to try updating the endpoint, and to contact Databricks support if the problem persists. When the deploy succeeds, it prints `Updated model_serving_endpoints.cli_example`, and `config_update` returns to NOT\_UPDATING.

## Additional resources

* For the options of each serving command, see [Serving endpoints commands in the CLI reference](https://docs.databricks.com/aws/en/dev-tools/cli/reference/serving-endpoints-commands.md).
* For the other bundle endpoint keys, see [Bundle resources reference](https://docs.databricks.com/aws/en/dev-tools/bundles/resources.md).
