All Products
Search
Document Center

Key Management Service:GetParametersForImport

Last Updated:Jul 29, 2025

Queries the parameters that are used to import key material for a customer master key (CMK).

Operation description

The returned parameters can be used to call the ImportKeyMaterial operation.

  • You can import key material only for CMKs whose Origin parameter is set to EXTERNAL.
  • The public key and token that are returned by the GetParametersForImport operation must be used together. The public key and token can be used to import key material only for the CMK that is specified when you call the operation.
  • The public key and token that are returned vary each time you call the GetParametersForImport operation.
  • You must specify the type of the public key and the encryption algorithm that are used to encrypt key material. The following table lists the types of public keys and the encryption algorithms allowed for each type.
Public key typeEncryption algorithmDescription
RSA_2048RSAES_PKCS1_V1_5

RSAES_OAEP_SHA_1

RSAES_OAEP_SHA_256 | CMKs of all regions and all protection levels are supported.

Dedicated Key Management Service (KMS) does not support RSAES_OAEP_SHA_1. | | EC_SM2 | SM2PKE | CMKs whose ProtectionLevel is set to HSM are supported. The SM2 algorithm is developed and approved by the State Cryptography Administration of China. The SM2 algorithm can be used only to import key material for a CMK whose ProtectionLevel is set to HSM. You can use the SM2 algorithm only when you enable the Managed HSM feature for KMS in the Chinese mainland. For more information, see Overview of Managed HSM. | For more information, see Import key material. This topic provides an example on how to query the parameters that are used to import key material for a CMK. The ID of the CMK is 1234abcd-12ab-34cd-56ef-12345678****, the encryption algorithm is RSAES_PKCS1_V1_5, and the public key is of the RSA_2048 type. The parameters that are returned include the ID of the CMK, the public key that is used to encrypt the key material, the token that is used to import the key material, and the time when the token expires.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

There is currently no authorization information disclosed in the API.

Request parameters

ParameterTypeRequiredDescriptionExample
KeyIdstringYes

The globally unique ID of the CMK.

Note You can import key material only for CMKs whose Origin parameter is set to EXTERNAL.
202b9877-5a25-46e3-a763-e20791b5****
WrappingAlgorithmstringYes

The algorithm that is used to encrypt key material.

RSAES_PKCS1_V1_5
WrappingKeySpecstringYes

The type of the public key that is used to encrypt key material.

RSA_2048

For more information about common request parameters, see Common parameters.

Response parameters

ParameterTypeDescriptionExample
object
KeyIdstring

The globally unique ID of the CMK.

The value of this parameter is required when you call the ImportKeyMaterial operation.

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

The token that is used to import key material.

The token is valid for 24 hours. The value of this parameter is required when you call the ImportKeyMaterial operation.

Base64String
RequestIdstring

The ID of the request, which is used to locate and troubleshoot issues.

8cdf51fd-bcd6-d79a-0ef4-e52c9b5466dc
TokenExpireTimestring

The time when the token expires.

2018-01-25T00:01:02Z
PublicKeystring

The public key that is used to encrypt key material.

The public key is Base64-encoded.

MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlls4uIBxD0GG84C+lGBO6Dhpf1J3XimC6cPmPNaKKJMOzoX4tD+C+r7aZv8lZ3vnPfxuxvy/YwG+whUxTEEFUdqJTOIzhPfYucupqKM92crVHIuG+xtMVeHKjyTr+UrtKCsQikqHT+19yDRN/RMoo2HUx0gmEnRyXd8t3JyUXun9FdoxKA08GrsV7nodb9ZsoBLhnev7tTLcXvLyKW6XG1ZQCQm6dPnbnwLeDXR7uK0Lqn9PM28mBIdaiQUQxj2XbM1CoJA+JiyVX3Ptdb+4rqukb4Rb05B80Bs9xV/cf7FIku08l7xGhrGiQFq+DFXwQWtwihXHZxz3LhldU+4ZPwID****

Examples

Sample success responses

JSONformat

{
  "KeyId": "202b9877-5a25-46e3-a763-e20791b5****",
  "ImportToken": "Base64String",
  "RequestId": "8cdf51fd-bcd6-d79a-0ef4-e52c9b5466dc",
  "TokenExpireTime": "2018-01-25T00:01:02Z",
  "PublicKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlls4uIBxD0GG84C+lGBO6Dhpf1J3XimC6cPmPNaKKJMOzoX4tD+C+r7aZv8lZ3vnPfxuxvy/YwG+whUxTEEFUdqJTOIzhPfYucupqKM92crVHIuG+xtMVeHKjyTr+UrtKCsQikqHT+19yDRN/RMoo2HUx0gmEnRyXd8t3JyUXun9FdoxKA08GrsV7nodb9ZsoBLhnev7tTLcXvLyKW6XG1ZQCQm6dPnbnwLeDXR7uK0Lqn9PM28mBIdaiQUQxj2XbM1CoJA+JiyVX3Ptdb+4rqukb4Rb05B80Bs9xV/cf7FIku08l7xGhrGiQFq+DFXwQWtwihXHZxz3LhldU+4ZPwID****"
}

Error codes

HTTP status codeError codeError messageDescription
400Unsupported.OriginThis key origin is not valid for this apiThe key origin is not supported for this API operation.
400InvalidParameterThe specified parameter is not valid.An invalid value is specified for the parameter.
404InvalidAccessKeyId.NotFoundThe Access Key ID provided does not exist in our records.-

For a list of error codes, visit the Service error codes.