All Products
Search
Document Center

Key Management Service:Decrypt

Last Updated:Jul 29, 2025

Decrypts ciphertext.

Operation description

Precautions

  • For information about the access policy required for a RAM user or RAM role to call this operation, see Resource Access Management.

  • You can call this operation using a shared gateway or a dedicated gateway. For more information, see Alibaba Cloud SDK.

    • Shared gateway: You can access KMS over the Internet or using a VPC domain name. To use a shared gateway, you must enable Internet access. For more information, see Access keys in a KMS instance over the Internet.

    • Dedicated gateway: You can access KMS using the private endpoint of KMS (<YOUR_KMS_INSTANCE_ID>.cryptoservice.kms.aliyuncs.com).

QPS limits

  • Shared gateway: The queries per second (QPS) limit for a single user for this operation is 1,000. If this limit is exceeded, API calls are throttled, which may affect your business. We recommend that you plan your calls accordingly.

  • Dedicated gateway: The QPS limit for a single user for this operation is subject to the performance specifications of your KMS instance. For more information, see Performance metrics.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request parameters

Parameter

Type

Required

Description

Example

CiphertextBlob

string

Yes

The ciphertext that you want to decrypt.
The ciphertext is generated by calling the following API operations:

DZhOWVmZDktM2QxNi00ODk0LWJkNGYtMWZjNDNmM2YyYWJmaaSl+TztSIMe43nbTH/Z1Wr4XfLftKhAciUmDQXuMRl4WTvKhxjMThjK****

EncryptionContext

object

No

A JSON string that consists of key-value pairs.

Note

If you specify EncryptionContext when you call the GenerateDataKey, Encrypt, or GenerateDataKeyWithoutPlaintext operation to encrypt data, you must specify the same parameter for decryption. For more information, see EncryptionContext.

{"Example":"Example"}

DryRun

string

No

Specifies whether to enable the dry run feature.

  • true: enables the dry run feature.

  • false (default): disables the dry run feature.

The dry run feature lets you test API calls, check whether you have the required permissions on resources, and check whether the request parameters are valid. If you enable the dry run feature, KMS always returns a failure response that indicates the cause of the failure. The following causes are possible:

  • DryRunOperationError: The request would have succeeded if the DryRun parameter was not specified.

  • ValidationError: The parameters specified in the request are invalid.

  • AccessDeniedError: You are not authorized to perform this operation on the KMS resource.

false

Response parameters

Parameter

Type

Description

Example

object

KeyVersionId

string

The ID of the key version that is used to decrypt the ciphertext. This key version is a version of the master key.

2ab1a983-7072-4bbc-a582-584b5bd8****

KeyId

string

The ID of the master key that is used to decrypt the ciphertext.
The globally unique identifier of the master key.

202b9877-5a25-46e3-a763-e20791b5****

RequestId

string

The ID of the request. This ID is a globally unique identifier that is generated by Alibaba Cloud for the request. You can use the ID to troubleshoot issues.

207596a2-36d3-4840-b1bd-f87044699bd7

Plaintext

string

The decrypted plaintext.

tRYXuCwgja12xxO1N/gZERDDCLw9doZEQiPDk/Bv****

Examples

Success response

JSON format

{
  "KeyVersionId": "2ab1a983-7072-4bbc-a582-584b5bd8****",
  "KeyId": "202b9877-5a25-46e3-a763-e20791b5****",
  "RequestId": "207596a2-36d3-4840-b1bd-f87044699bd7",
  "Plaintext": "tRYXuCwgja12xxO1N/gZERDDCLw9doZEQiPDk/Bv****"
}

Error response

JSON format

//xml response

        202b9877-5a25-46e3-a763-e20791b5****
        2ab1a983-7072-4bbc-a582-584b5bd8****
        Plaintext&lt;/Plaintext&gt;
        &lt;RequestId&gt;4bd560a1-729e-45f1-a3d9-b2a33d61046b&lt;/RequestId&gt;
&lt;/KMS&gt;&lt;/code&gt;
            &lt;/section&gt;

            &lt;section class="section" cond-otherprops="errorcode" id="api-detail-45"&gt;
                &lt;h2 class="title sectiontitle" id="h2-url-6" baseUrl="t2858474_v1_0_0.xdita" docId="5523455" docType="TOPIC" data-node="5523455" data-latest="1" conref="t2858199.xdita#api-doc-error-code"&gt;&lt;/h2&gt;
            	&lt;table class="table" id="api-detail-46" style="margin-bottom:12px"&gt;
            		&lt;colgroup id="doc-api-Ecs-DescribeRegions-entry-1"&gt;
            		&lt;col id="doc-api-Ecs-DescribeRegions-entry-col-0" style="width:13.04%"&gt;
            		&lt;col id="doc-api-Ecs-DescribeRegions-entry-col-1" style="width:21.73%"&gt;
            		&lt;col id="doc-api-Ecs-DescribeRegions-entry-col-2" style="width:32.6%"&gt;
            		&lt;col id="doc-api-Ecs-DescribeRegions-entry-col-3" style="width:32.6%"&gt;
            		&lt;/colgroup&gt;
            		&lt;thead class="thead"&gt;
            			&lt;tr id="doc-api-Kms-Decrypt-errorCode-entry"&gt;
            				&lt;th id="doc-api-Kms-Decrypt-errorCode-entry-th-1" colspan="1" rowspan="1" style="background-color:#e5e5e5;vertical-align:middle"&gt;
                                &lt;p id="216169fbd14eu" conref="t2858199.xdita#api-doc-error-code-table-header-field-status-code" data-node="5523455" data-latest="1" baseUrl="t2858474_v1_0_0.xdita" docId="4958267" docType="DITA"&gt;&lt;/p&gt;
                            &lt;/th&gt;
            				&lt;th id="doc-api-Kms-Decrypt-errorCode-entry-th-2" colspan="1" rowspan="1" style="background-color:#e5e5e5;vertical-align:middle"&gt;
                                &lt;p id="e673e7a9490xb" conref="t2858199.xdita#api-doc-error-code-table-header-field-error-code" data-node="5523455" data-latest="1" baseUrl="t2858474_v1_0_0.xdita" docId="4958267" docType="DITA"&gt;&lt;/p&gt;
                            &lt;/th&gt;
            				&lt;th id="doc-api-Kms-Decrypt-errorCode-entry-th-3" colspan="1" rowspan="1" style="background-color:#e5e5e5;vertical-align:middle"&gt;
                                &lt;p id="b6c649b78fjmf" conref="t2858199.xdita#api-doc-error-code-table-header-field-error-message" data-node="5523455" data-latest="1" baseUrl="t2858474_v1_0_0.xdita" docId="4958267" docType="DITA"&gt;&lt;/p&gt;
                            &lt;/th&gt;
            				&lt;th id="doc-api-Kms-Decrypt-errorCode-entry-th-4" colspan="1" rowspan="1" style="background-color:#e5e5e5;vertical-align:middle"&gt;
                                &lt;p id="1ec898966evaw" conref="t2858199.xdita#api-doc-error-code-table-header-field-error-description" data-node="5523455" data-latest="1" baseUrl="t2858474_v1_0_0.xdita" docId="4958267" docType="DITA"&gt;&lt;/p&gt;
                            &lt;/th&gt;
            			&lt;/tr&gt;
            		&lt;/thead&gt;
            		&lt;tbody class="tbody"&gt;
            		    &lt;tr id="doc-api-Kms-Decrypt-errorCode-UnsupportedOperation" class="entry colsep-1 rowsep-1 new-version row-level-1"&gt;
                            &lt;td id="doc-api-Kms-Decrypt-errorCode-UnsupportedOperation-httpStatus"&gt;
                                &lt;span&gt;400&lt;/span&gt;
                            &lt;/td&gt;
                            &lt;td id="doc-api-Kms-Decrypt-errorCode-UnsupportedOperation-errorCode" data-spm-anchor-id=""&gt;
                                &lt;span&gt;UnsupportedOperation&lt;/span&gt;
                            &lt;/td&gt;
                            &lt;td id="doc-api-Kms-Decrypt-errorCode-UnsupportedOperation-errorMessage"&gt;
                                &lt;span&gt;This action is not supported.&lt;/span&gt;
                            &lt;/td&gt;
                            &lt;td id="doc-api-Kms-Decrypt-errorCode-UnsupportedOperation-description" data-spm-anchor-id=""&gt;
                                &lt;span&gt;The operation is not supported.&lt;/span&gt;
                            &lt;/td&gt;
                        &lt;/tr&gt;
            		    &lt;tr id="doc-api-Kms-Decrypt-errorCode-Forbidden.AliasNotFound" class="entry colsep-1 rowsep-1 new-version row-level-1"&gt;
                            &lt;td id="doc-api-Kms-Decrypt-errorCode-Forbidden.AliasNotFound-httpStatus"&gt;
                                &lt;span&gt;404&lt;/span&gt;
                            &lt;/td&gt;
                            &lt;td id="doc-api-Kms-Decrypt-errorCode-Forbidden.AliasNotFound-errorCode" data-spm-anchor-id=""&gt;
                                &lt;span&gt;Forbidden.AliasNotFound&lt;/span&gt;
                            &lt;/td&gt;
                            &lt;td id="doc-api-Kms-Decrypt-errorCode-Forbidden.AliasNotFound-errorMessage"&gt;
                                &lt;span&gt;The specified Alias is not found.&lt;/span&gt;
                            &lt;/td&gt;
                            &lt;td id="doc-api-Kms-Decrypt-errorCode-Forbidden.AliasNotFound-description" data-spm-anchor-id=""&gt;
                                &lt;span&gt;The error message returned because the specified alias does not exist.&lt;/span&gt;
                            &lt;/td&gt;
                        &lt;/tr&gt;
            		    &lt;tr id="doc-api-Kms-Decrypt-errorCode-Forbidden.KeyNotFound" class="entry colsep-1 rowsep-1 new-version row-level-1"&gt;
                            &lt;td id="doc-api-Kms-Decrypt-errorCode-Forbidden.KeyNotFound-httpStatus"&gt;
                                &lt;span&gt;404&lt;/span&gt;
                            &lt;/td&gt;
                            &lt;td id="doc-api-Kms-Decrypt-errorCode-Forbidden.KeyNotFound-errorCode" data-spm-anchor-id=""&gt;
                                &lt;span&gt;Forbidden.KeyNotFound&lt;/span&gt;
                            &lt;/td&gt;
                            &lt;td id="doc-api-Kms-Decrypt-errorCode-Forbidden.KeyNotFound-errorMessage"&gt;
                                &lt;span&gt;The specified Key is not found.&lt;/span&gt;
                            &lt;/td&gt;
                            &lt;td id="doc-api-Kms-Decrypt-errorCode-Forbidden.KeyNotFound-description" data-spm-anchor-id=""&gt;
                                &lt;span&gt;The error message returned because the specified CMK does not exist.&lt;/span&gt;
                            &lt;/td&gt;
                        &lt;/tr&gt;
            		    &lt;tr id="doc-api-Kms-Decrypt-errorCode-Rejected.Disabled" class="entry colsep-1 rowsep-1 new-version row-level-1"&gt;
                            &lt;td id="doc-api-Kms-Decrypt-errorCode-Rejected.Disabled-httpStatus"&gt;
                                &lt;span&gt;409&lt;/span&gt;
                            &lt;/td&gt;
                            &lt;td id="doc-api-Kms-Decrypt-errorCode-Rejected.Disabled-errorCode" data-spm-anchor-id=""&gt;
                                &lt;span&gt;Rejected.Disabled&lt;/span&gt;
                            &lt;/td&gt;
                            &lt;td id="doc-api-Kms-Decrypt-errorCode-Rejected.Disabled-errorMessage"&gt;
                                &lt;span&gt;The request was rejected because the key state is Disabled.&lt;/span&gt;
                            &lt;/td&gt;
                            &lt;td id="doc-api-Kms-Decrypt-errorCode-Rejected.Disabled-description" data-spm-anchor-id=""&gt;
                                &lt;span&gt;The request was rejected because the key state is Disabled.&lt;/span&gt;
                            &lt;/td&gt;
                        &lt;/tr&gt;
            		    &lt;tr id="doc-api-Kms-Decrypt-errorCode-Rejected.PendingDeletion" class="entry colsep-1 rowsep-1 new-version row-level-1"&gt;
                            &lt;td id="doc-api-Kms-Decrypt-errorCode-Rejected.PendingDeletion-httpStatus"&gt;
                                &lt;span&gt;409&lt;/span&gt;
                            &lt;/td&gt;
                            &lt;td id="doc-api-Kms-Decrypt-errorCode-Rejected.PendingDeletion-errorCode" data-spm-anchor-id=""&gt;
                                &lt;span&gt;Rejected.PendingDeletion&lt;/span&gt;
                            &lt;/td&gt;
                            &lt;td id="doc-api-Kms-Decrypt-errorCode-Rejected.PendingDeletion-errorMessage"&gt;
                                &lt;span&gt;The request was rejected because the key state is PendingDeletion.&lt;/span&gt;
                            &lt;/td&gt;
                            &lt;td id="doc-api-Kms-Decrypt-errorCode-Rejected.PendingDeletion-description" data-spm-anchor-id=""&gt;
                                &lt;span&gt;The request was rejected because the key state is PendingDeletion.&lt;/span&gt;
                            &lt;/td&gt;
                        &lt;/tr&gt;
            		    &lt;tr id="doc-api-Kms-Decrypt-errorCode-Rejected.Unavailable" class="entry colsep-1 rowsep-1 new-version row-level-1"&gt;
                            &lt;td id="doc-api-Kms-Decrypt-errorCode-Rejected.Unavailable-httpStatus"&gt;
                                &lt;span&gt;409&lt;/span&gt;
                            &lt;/td&gt;
                            &lt;td id="doc-api-Kms-Decrypt-errorCode-Rejected.Unavailable-errorCode" data-spm-anchor-id=""&gt;
                                &lt;span&gt;Rejected.Unavailable&lt;/span&gt;
                            &lt;/td&gt;
                            &lt;td id="doc-api-Kms-Decrypt-errorCode-Rejected.Unavailable-errorMessage"&gt;
                                &lt;span&gt;The request was rejected because the key state is Unavailable.&lt;/span&gt;
                            &lt;/td&gt;
                            &lt;td id="doc-api-Kms-Decrypt-errorCode-Rejected.Unavailable-description" data-spm-anchor-id=""&gt;
                                &lt;span&gt;The request was denied because the key status is unavailable.&lt;/span&gt;
                            &lt;/td&gt;
                        &lt;/tr&gt;
            		&lt;/tbody&gt;
            	&lt;/table&gt;
                &lt;section id="api-detail-47" baseUrl="t2858199_v1_0_2.xdita" docId="5028902" docType="TOPIC" data-node="5523455" data-latest="1" conref="t2858199.xdita#api-detail-47"&gt;
                    &lt;div data-tag="conref-replace" data-replace-type="attr" data-replace-id="api-doc-error-code-link-cn" data-replace-attr-key="href" data-replace-attr-value="https://api.aliyun.com/document/Kms/2016-01-20/errorCode"&gt;&lt;/div&gt;
                    &lt;div data-tag="conref-replace" data-replace-type="attr" data-replace-id="api-doc-error-code-link-intl" data-replace-attr-key="href" data-replace-attr-value="https://api.alibabacloud.com/document/Kms/2016-01-20/errorCode"&gt;&lt;/div&gt;
                &lt;/section&gt;
            &lt;/section&gt;

            &lt;section class="section" id="changeList"&gt;
                &lt;h2 class="title sectiontitle" id="workbench-doc-change-demo" conref="t2858199.xdita#api-doc-change-history" data-node="5523455" data-latest="1" baseUrl="t2858474_v1_0_0.xdita" docId="5523455" docType="TOPIC"&gt;&lt;/h2&gt;
                &lt;section id="api-doc-change-history-more-info" baseUrl="t2858199_v1_0_3.xdita" docId="5213447" docType="TOPIC" data-node="5523455" data-latest="1" conref="t2858199.xdita#api-doc-change-history-more-info"&gt;
                    &lt;div data-tag="conref-replace" data-replace-id="api-doc-change-history-more-info-operation-link-cn" data-replace-type="attr" data-replace-attr-key="href" data-replace-attr-value="https://api.aliyun.com/document/Kms/2016-01-20/Decrypt#workbench-doc-change-demo"&gt;&lt;/div&gt;
                    &lt;div data-tag="conref-replace" data-replace-id="api-doc-change-history-more-info-operation-link-intl" data-replace-type="attr" data-replace-attr-key="href" data-replace-attr-value="https://api.alibabacloud.com/document/Kms/2016-01-20/Decrypt#workbench-doc-change-demo"&gt;&lt;/div&gt;
                &lt;/section&gt;
            &lt;/section&gt;

        &lt;/div&gt;
    &lt;/main&gt;
&lt;/body&gt;
&lt;/html&gt;
</plaintext></kms></code></section></div></main></body></html>