Deleting a Model

Function

This API is used to delete a model based on the model ID. When cascade is set to true, the model specified by the model ID and models of different versions with the same name as the specified model are deleted. By default, only the model with the specified model ID is deleted.

Debugging

You can debug this API through automatic authentication in or use the SDK sample code generated by API Explorer.

URI

DELETE /v1/{project_id}/models/{model_id}

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

model_id

Yes

String

ID of the model to be deleted

project_id

Yes

String

Project ID. For details, see Obtaining a Project ID and Name.

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

cascade

No

Boolean

The default value is false, indicating that only the model with the specified model ID is deleted. If this parameter is set to true, both the model specified by the model ID and models of different versions with the same name as the specified model are deleted. A maximum of 20 models can be deleted at a time.

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token. It can be obtained by calling the IAM API that is used to obtain a user token. The value of X-Subject-Token in the response header is the user token.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

delete_success_list

Array of strings

ID list of models successfully deleted

delete_failed_list

Array of DeleteModelResponseFailedList objects

ID of the model that fails to be deleted and the failure cause list

Table 5 DeleteModelResponseFailedList

Parameter

Type

Description

error_msg

String

Error message of the model deletion failure

error_code

String

Error code of the model deletion failure

model_id

String

ID of a model that fails to be deleted

Example Requests

DELETE https://{endpoint}/v1/{project_id}/models/{model_id}

Example Responses

Status code: 200

Message indicating a successful deletion or a deletion failure

{
  "delete_success_list" : [ "10eb0091-887f-4839-9929-cbc884f1e20e" ],
  "delete_failed_list" : [ {
    "error_msg" : "Failed to delete model because the model (759645d9-3672-4db1-bb6d-49ed58b84e10) has been used to deploy a service.",
    "error_code" : "ModelArts.3009",
    "model_id" : "e527d311-a947-46da-a6e0-66c49945dfaa"
  } ]
}

Status Codes

Status Code

Description

200

Message indicating a successful deletion or a deletion failure

Error Codes

See Error Codes.