

# SetImageStatus

Sets the status of an image in a premium repository to `ACTIVE` or `DEPRECATED`. When you deprecate an image, Amazon ECR deletes it after the deprecation period ends. You can't use this operation while the repository is in the `DRAFT` state.

## Request Syntax
<a name="API_SetImageStatus_RequestSyntax"></a>

```
{
   "deprecationPeriodDays": {{number}},
   "imageId": { 
      "imageDigest": "{{string}}",
      "imageTag": "{{string}}"
   },
   "registryId": "{{string}}",
   "repositoryName": "{{string}}",
   "repositoryType": "{{string}}",
   "status": "{{string}}"
}
```

## Request Parameters
<a name="API_SetImageStatus_RequestParameters"></a>

For information about the parameters that are common to all actions, see [Common Parameters](CommonParameters.md).

The request accepts the following data in JSON format.

 ** [deprecationPeriodDays](#API_SetImageStatus_RequestSyntax) **   <a name="ecrpublic-SetImageStatus-request-deprecationPeriodDays"></a>
The number of days that Amazon ECR waits before it deletes the deprecated image. You can specify a value between 90 and 365. This parameter is required when you set `status` to `DEPRECATED`. Don't specify it when you set `status` to `ACTIVE`.  
Type: Integer  
Valid Range: Minimum value of 90. Maximum value of 365.  
Required: No

 ** [imageId](#API_SetImageStatus_RequestSyntax) **   <a name="ecrpublic-SetImageStatus-request-imageId"></a>
The image ID of the image to set the status for. If you specify a tag, the tag is resolved to the digest of the image that it currently points to, and the status is set on that image.  
Type: [ImageIdentifier](API_ImageIdentifier.md) object  
Required: Yes

 ** [registryId](#API_SetImageStatus_RequestSyntax) **   <a name="ecrpublic-SetImageStatus-request-registryId"></a>
The AWS account ID that's associated with the public registry that contains the image. If you do not specify a registry, the default public registry is assumed. You can specify only your own account ID. Cross-account access through a repository policy isn't supported for this operation.  
Type: String  
Pattern: `[0-9]{12}`   
Required: No

 ** [repositoryName](#API_SetImageStatus_RequestSyntax) **   <a name="ecrpublic-SetImageStatus-request-repositoryName"></a>
The name of the repository that contains the image.  
Type: String  
Length Constraints: Minimum length of 2. Maximum length of 205.  
Pattern: `[a-z0-9]+((\.|_|__|-+)[a-z0-9]+)*(\/[a-z0-9]+((\.|_|__|-+)[a-z0-9]+)*)*`   
Required: Yes

 ** [repositoryType](#API_SetImageStatus_RequestSyntax) **   <a name="ecrpublic-SetImageStatus-request-repositoryType"></a>
The type of the repository. You can set the image status only in a `PREMIUM` repository.  
Type: String  
Valid Values: `FREE | PREMIUM`   
Required: Yes

 ** [status](#API_SetImageStatus_RequestSyntax) **   <a name="ecrpublic-SetImageStatus-request-status"></a>
The status to set on the image. Valid values:  
+  `ACTIVE`: Cancels a pending deletion. You can do this only before the scheduled deletion time.
+  `DEPRECATED`: Schedules the image for deletion after the deprecation period.
After the scheduled deletion time, you can't change the status of the image.  
If the image is part of a manifest list, Amazon ECR requires that a manifest list is deleted before the images that it references. To deprecate an image that a manifest list references, deprecate the manifest list first, with a scheduled deletion time before the image's. You can't set a manifest list to `ACTIVE` while it references deprecated images. Requests that break these rules fail with `ValidationException`.  
Type: String  
Valid Values: `ACTIVE | DEPRECATED`   
Required: Yes

## Response Syntax
<a name="API_SetImageStatus_ResponseSyntax"></a>

```
{
   "imageId": { 
      "imageDigest": "string",
      "imageTag": "string"
   },
   "repositoryName": "string",
   "repositoryType": "string",
   "scheduledDeletionAt": number,
   "status": "string"
}
```

## Response Elements
<a name="API_SetImageStatus_ResponseElements"></a>

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

 ** [imageId](#API_SetImageStatus_ResponseSyntax) **   <a name="ecrpublic-SetImageStatus-response-imageId"></a>
The image ID of the image that the status was set on.  
Type: [ImageIdentifier](API_ImageIdentifier.md) object

 ** [repositoryName](#API_SetImageStatus_ResponseSyntax) **   <a name="ecrpublic-SetImageStatus-response-repositoryName"></a>
The repository name that's associated with the request.  
Type: String  
Length Constraints: Minimum length of 2. Maximum length of 205.  
Pattern: `[a-z0-9]+((\.|_|__|-+)[a-z0-9]+)*(\/[a-z0-9]+((\.|_|__|-+)[a-z0-9]+)*)*` 

 ** [repositoryType](#API_SetImageStatus_ResponseSyntax) **   <a name="ecrpublic-SetImageStatus-response-repositoryType"></a>
The type of the repository.  
Type: String  
Valid Values: `FREE | PREMIUM` 

 ** [scheduledDeletionAt](#API_SetImageStatus_ResponseSyntax) **   <a name="ecrpublic-SetImageStatus-response-scheduledDeletionAt"></a>
The date and time that the deprecated image is scheduled for deletion. This is the time of the `SetImageStatus` request plus the deprecation period. Amazon ECR deletes the image within 24 hours after this time. Amazon ECR returns this value only when the image status is `DEPRECATED`.  
Type: Timestamp

 ** [status](#API_SetImageStatus_ResponseSyntax) **   <a name="ecrpublic-SetImageStatus-response-status"></a>
The status of the image. Valid values:  
+  `ACTIVE`: The image isn't scheduled for deletion.
+  `DEPRECATED`: The image is scheduled for deletion. Entitled buyers can still pull it until it's deleted.
Type: String  
Valid Values: `ACTIVE | DEPRECATED` 

## Errors
<a name="API_SetImageStatus_Errors"></a>

For information about the errors that are common to all actions, see [Common Error Types](CommonErrors.md).

 ** ConflictException **   
Another operation is in progress on the same resource. Wait and then retry the request.    
 ** message **   
The error message associated with the exception.
HTTP Status Code: 400

 ** ImageNotFoundException **   
The image requested doesn't exist in the specified repository. Check the image tag or digest. To list the images in a repository, use `DescribeImages` or `DescribeImageTags`, or for a premium repository that you're entitled to, `DescribeEntitledImages` or `DescribeEntitledImageTags`.    
 ** message **   
The error message associated with the exception.
HTTP Status Code: 400

 ** InvalidParameterException **   
The specified parameter is invalid. Review the available parameters for the API request.    
 ** message **   
The error message associated with the exception.
HTTP Status Code: 400

 ** RepositoryNotFoundException **   
The specified repository can't be found. Check the spelling of the specified repository and ensure that you're performing operations on the correct registry.    
 ** message **   
The error message associated with the exception.
HTTP Status Code: 400

 ** ServerException **   
These errors are usually caused by a server-side issue. Retry the request. If it continues to fail, contact AWS Support.    
 ** message **   
The error message associated with the exception.
HTTP Status Code: 500

 ** UnsupportedCommandException **   
The action isn't supported in this Region. Check that the action is available in the AWS Region that you're using, and try again in a supported Region.    
 ** message **   
The error message associated with the exception.
HTTP Status Code: 400

 ** ValidationException **   
There was an error validating the request. Check the request parameters and try again.    
 ** message **   
The error message associated with the exception.
HTTP Status Code: 400

## See Also
<a name="API_SetImageStatus_SeeAlso"></a>

For more information about using this API in one of the language-specific AWS SDKs, see the following:
+  [AWS Command Line Interface V2](https://docs.aws.amazon.com/goto/cli2/ecr-public-2020-10-30/SetImageStatus) 
+  [AWS SDK for .NET V4](https://docs.aws.amazon.com/goto/DotNetSDKV4/ecr-public-2020-10-30/SetImageStatus) 
+  [AWS SDK for C\+\+](https://docs.aws.amazon.com/goto/SdkForCpp/ecr-public-2020-10-30/SetImageStatus) 
+  [AWS SDK for Go v2](https://docs.aws.amazon.com/goto/SdkForGoV2/ecr-public-2020-10-30/SetImageStatus) 
+  [AWS SDK for Java V2](https://docs.aws.amazon.com/goto/SdkForJavaV2/ecr-public-2020-10-30/SetImageStatus) 
+  [AWS SDK for JavaScript V3](https://docs.aws.amazon.com/goto/SdkForJavaScriptV3/ecr-public-2020-10-30/SetImageStatus) 
+  [AWS SDK for Kotlin](https://docs.aws.amazon.com/goto/SdkForKotlin/ecr-public-2020-10-30/SetImageStatus) 
+  [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/ecr-public-2020-10-30/SetImageStatus) 
+  [AWS SDK for Python (Boto3)](https://docs.aws.amazon.com/goto/boto3/ecr-public-2020-10-30/SetImageStatus) 
+  [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/ecr-public-2020-10-30/SetImageStatus) 