# Updating a deployment #

After you create an online or a batch deployment, you can still update your deployment details and update the assets that are associated with your deployment\.

For more information, see:

<!-- <ul> -->

 *  [Update deployment details](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/ml-deploy-update.html?context=cdpaas&locale=en#upd-general)
 *  [Update assets associated with a deployment](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/ml-deploy-update.html?context=cdpaas&locale=en#upd-assets)

<!-- </ul> -->

## Updating deployment details ##

You can update general deployment details, such as deployment name, description, metadata, and tags by using one of these methods:

<!-- <ul> -->

 *  [Update deployment details from the UI](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/ml-deploy-update.html?context=cdpaas&locale=en#update-details-ui)\.
 *  [Update deployment details by using the Patch API command](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/ml-deploy-update.html?context=cdpaas&locale=en#update-details-api)\.

<!-- </ul> -->

### Updating deployment details from the UI ###

<!-- <ol> -->

1.  From the **Deployments** tab of your deployment space, click the action menu for the deployment and choose **Edit settings**\.
2.  Update the details and then click **Save**\.
    
    Tip: You can also update a deployment from the information sheet for the deployment.

<!-- </ol> -->

### Updating deployment details by using the Patch API command ###

Use the [Watson Machine Learning API Patch](https://cloud.ibm.com/apidocs/machine-learning-cp#models-update) command to update deployment details\.

    curl -X PATCH '<deployment endpoint url>/ml/v4/deployments/<deployment id>?space_id=<space id>&version=<YYYY-MM-DD>' \n--data-raw '[
        {
            "op": "<operation type>",
            "path": "<path>",
            "value": "<new value>"
        },
        {
            "op": "<operation type>",
            "path": "<path>",
            "value": "<new value>"
        }
    ]'

For example, to update a description for deployment:

    curl -X PATCH '<deployment endpoint url>/ml/v4/deployments/<deployment_id>?space_id=<space_id>&version=<YYYY-MM-DD>' \n--data-raw '[
        {
            "op": "replace",
            "path": "/description",
            "value": "<new_description>"
        },
    ]'

**Notes**:

<!-- <ul> -->

 *  For `<operation type>`, use `"add"`, `"remove"`, or `"replace"`\.

<!-- </ul> -->

## Updating assets associated with a deployment ##

After you create an online or batch deployment, you can update the deployed asset from the same endpoint\. For example, if you have a better performing model, you can replace the deployed model with the improved version\. When the update is complete, the new model is available from the REST API endpoint\.

Before you update an asset, make sure that these conditions are true:

<!-- <ul> -->

 *  The framework of the new model is compatible with the existing deployed model\.
 *  The input schema exists and matches for the new and deployed model\.
    
    Caution: Failure to follow these conditions can result in a failed deployment.
 *  For more information, see [Updating an asset from the deployment space UI](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/ml-deploy-update.html?context=cdpaas&locale=en#update-asset-ui)\.
 *  For more information, see [Updating an asset by using the Patch API command](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/ml-deploy-update.html?context=cdpaas&locale=en#update-asset-api)\.

<!-- </ul> -->

### Updating an asset from the deployment space UI ###

<!-- <ol> -->

1.  From the **Deployments** tab of your deployment space, click the action menu for the deployment and choose **Edit**\.
2.  Click **Replace asset**\. From the *Select an asset* dialog box, select the asset that you want to replace the current asset with and click **Select asset**\.
3.  Click **Save**\.

<!-- </ol> -->

Important: Make sure that the new asset is compatible with the deployment\.

![Replacing a deployed asset](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/images/deploy-update.png)

### Updating an asset by using the Patch API command ###

Use the Watson Machine Learning [API](https://cloud.ibm.com/apidocs/machine-learning)`Patch` command to update any supported asset\.

Use this method to patch a model for an online deployment\.

    curl -X PATCH '<deployment endpoint url>/ml/v4/models/<model_id>?space_id=<space_id>&project_id=<project_id>&version=<YYYY-MM-DD>' \n--data-raw '[
        {
            "op": "<operation type>",
            "path": "<path>",
            "value": "<new value>"
        },
        {
            "op": "<operation type>",
            "path": "<path>",
            "value": "<new value>"
        }
    ]'

For example, patch a model with ID `6f01d512-fe0f-41cd-9a52-1e200c525c84` in space ID `f2ddb8ce-7b10-4846-9ab0-62454a449802`:

    curl -X PATCH '<deployment endpoint url>/ml/v4/models/6f01d512-fe0f-41cd-9a52-1e200c525c84?space_id=f2ddb8ce-7b10-4846-9ab0-62454a449802&project_id=<project_id>&version=<YYYY-MM-DD>' \n--data-raw '[
    
       {
          "op":"replace",
          "path":"/asset",
          "value":{
             "id":"6f01d512-fe0f-41cd-9a52-1e200c525c84",
             "rev":"1"
          }
       }
    ]'

A successful output response looks like this:

    {
      "entity": {
        "asset": {
          "href": "/v4/models/6f01d512-fe0f-41cd-9a52-1e200c525c84?space_id=f2ddb8ce-7b10-4846-9ab0-62454a449802",
          "id": "6f01d512-fe0f-41cd-9a52-1e200c525c84"
        },
        "custom": {
        },
        "description": "Test V4 deployments",
        "name": "test_v4_dep_online_space_hardware_spec",
        "online": {
        },
        "space": {
          "href": "/v4/spaces/f2ddb8ce-7b10-4846-9ab0-62454a449802",
          "id": "f2ddb8ce-7b10-4846-9ab0-62454a449802"
        },
        "space_id": "f2ddb8ce-7b10-4846-9ab0-62454a449802",
        "status": {
          "online_url": {
            "url": "https://example.com/v4/deployments/349dc1f7-9452-491b-8aa4-0777f784bd83/predictions"
          },
          "state": "updating"
        }
      },
      "metadata": {
        "created_at": "2020-06-08T16:51:08.315Z",
        "description": "Test V4 deployments",
        "guid": "349dc1f7-9452-491b-8aa4-0777f784bd83",
        "href": "/v4/deployments/349dc1f7-9452-491b-8aa4-0777f784bd83",
        "id": "349dc1f7-9452-491b-8aa4-0777f784bd83",
        "modified_at": "2020-06-08T16:55:28.348Z",
        "name": "test_v4_dep_online_space_hardware_spec",
        "parent": {
          "href": ""
        },
        "space_id": "f2ddb8ce-7b10-4846-9ab0-62454a449802"
      }
    }

**Notes:**

<!-- <ul> -->

 *  For `<operation type>`, use `"add"`, `"remove"`, or `"replace"`\.
 *  The initial state for the PATCH API output is "updating"\. Keep polling the status until it changes to "ready", then retrieve the deployment meta\.
 *  Only the `ASSET` attribute can be specified for the asset patch\. Changing any other attribute results in an error\.
 *  The schema of the current model and the model being patched is compared to the deployed asset\. A warning message is returned in the output of the Patch request API if the two don't match\. For example, if a mismatch is detected, you can find this information in the output response\.
    
        "status": {
              "message": {
                "text": "The input schema of the asset being patched does not match with the currently deployed asset. Please ensure that the score payloads are up to date as per the asset being patched."
              },
 *  For more information, see [Updating software specifications by using the API](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/ml-manage-outdated.html#update-soft-specs-api)\.

<!-- </ul> -->

**Parent topic:**[Managing predictive deployments](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/ml-deploy-general.html)

<!-- </article "role="article" "> -->