- [HTTP request](https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/import#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/import#body.PATH_PARAMETERS)
- [Request body](https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/import#body.request_body)
  - [JSON representation](https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/import#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/import#body.response_body)
- [Authorization scopes](https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/import#body.aspect)
- [Try it!](https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/import#try-it)

**Full name**: projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.import

Import wrapped key material into a `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions#CryptoKeyVersion`.

All requests must specify a `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys#CryptoKey`. If a `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions#CryptoKeyVersion` is additionally specified in the request, key material will be reimported into that version. Otherwise, a new version will be created, and will be assigned the next sequential id within the `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys#CryptoKey`.

### HTTP request

Choose an endpoint:
global europe-west6 us-east7 europe-west3 us-west8 europe-west9 me-central2 us-east1 us-west1 us-west3 us-central2 us-east4 us-west2 europe-west8 us-central1 us-west4 us-east5 us-south1 northamerica-northeast1 northamerica-northeast2 us in ca   
`POST https://cloudkms.googleapis.com/v1/{parent=projects/*/locations/*/keyRings/*/cryptoKeys/*}/cryptoKeyVersions:import`

<br />

The URLs use [gRPC Transcoding](https://google.aip.dev/127) syntax.

### Path parameters

| Parameters ||
|---|---|
| `parent` | `string` Required. The `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys#CryptoKey.FIELDS.name` of the `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys#CryptoKey` to be imported into. The create permission is only required on this key when creating a new `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions#CryptoKeyVersion`. Authorization requires the following [IAM](https://cloud.google.com/iam/docs/) permission on the specified resource `parent`: - `cloudkms.cryptoKeyVersions.create` |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "cryptoKeyVersion": string, "algorithm": enum (`https://docs.cloud.google.com/kms/docs/reference/rest/v1/CryptoKeyVersionAlgorithm`), "importJob": string, "wrappedKey": string, // The following is a list of mutually exclusive fields. At most one of the // fields will be set in a response: "rsaAesWrappedKey": string // End of mutually exclusive fields. } ``` |

| Fields ||
|---|---|
| `cryptoKeyVersion` | `string` Optional. The optional `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions#CryptoKeyVersion.FIELDS.name` of an existing `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions#CryptoKeyVersion` to target for an import operation. If this field is not present, a new `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions#CryptoKeyVersion` containing the supplied key material is created. If this field is present, the supplied key material is imported into the existing `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions#CryptoKeyVersion`. To import into an existing `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions#CryptoKeyVersion`, the `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions#CryptoKeyVersion` must be a child of `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/import#body.PATH_PARAMETERS.parent`, have been previously created via `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/import#google.cloud.kms.v1.KeyManagementService.ImportCryptoKeyVersion`, and be in `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions#CryptoKeyVersion.CryptoKeyVersionState.ENUM_VALUES.DESTROYED` or `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions#CryptoKeyVersion.CryptoKeyVersionState.ENUM_VALUES.IMPORT_FAILED` state. The key material and algorithm must match the previous `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions#CryptoKeyVersion` exactly if the `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions#CryptoKeyVersion` has ever contained key material. Authorization requires the following [IAM](https://cloud.google.com/iam/docs/) permission on the specified resource `cryptoKeyVersion`: - `cloudkms.cryptoKeyVersions.update` |
| `algorithm` | ``enum (`https://docs.cloud.google.com/kms/docs/reference/rest/v1/CryptoKeyVersionAlgorithm`)`` Required. The `https://docs.cloud.google.com/kms/docs/reference/rest/v1/CryptoKeyVersionAlgorithm` of the key being imported. This does not need to match the `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys#CryptoKey.FIELDS.version_template` of the `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys#CryptoKey` this version imports into. |
| `importJob` | `string` Required. The `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.importJobs#ImportJob.FIELDS.name` of the `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.importJobs#ImportJob` that was used to wrap this key material. Authorization requires the following [IAM](https://cloud.google.com/iam/docs/) permission on the specified resource `importJob`: - `cloudkms.importjobs.useToImport` |
| `wrappedKey` | `string (https://developers.google.com/discovery/v1/type-format format)` Optional. The wrapped key material to import. Before wrapping, key material must be formatted. If importing symmetric key material, the expected key material format is plain bytes. If importing asymmetric key material, the expected key material format is PKCS#8-encoded DER (the PrivateKeyInfo structure from RFC 5208). When wrapping with import methods (`https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.importJobs#ImportMethod.ENUM_VALUES.RSA_OAEP_3072_SHA1_AES_256` or `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.importJobs#ImportMethod.ENUM_VALUES.RSA_OAEP_4096_SHA1_AES_256` or `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.importJobs#ImportMethod.ENUM_VALUES.RSA_OAEP_3072_SHA256_AES_256` or `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.importJobs#ImportMethod.ENUM_VALUES.RSA_OAEP_4096_SHA256_AES_256`), this field must contain the concatenation of: 1. An ephemeral AES-256 wrapping key wrapped with the `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.importJobs#ImportJob.FIELDS.public_key` using RSAES-OAEP with SHA-1/SHA-256, MGF1 with SHA-1/SHA-256, and an empty label. 2. The formatted key to be imported, wrapped with the ephemeral AES-256 key using AES-KWP (RFC 5649). <br /> This format is the same as the format produced by PKCS#11 mechanism CKM_RSA_AES_KEY_WRAP. When wrapping with import methods (`https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.importJobs#ImportMethod.ENUM_VALUES.RSA_OAEP_3072_SHA256` or `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.importJobs#ImportMethod.ENUM_VALUES.RSA_OAEP_4096_SHA256`), this field must contain the formatted key to be imported, wrapped with the `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.importJobs#ImportJob.FIELDS.public_key` using RSAES-OAEP with SHA-256, MGF1 with SHA-256, and an empty label. A base64-encoded string. |
| This field is legacy. Use the field `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/import#body.request_body.FIELDS.wrapped_key` instead. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: ||
| `rsaAesWrappedKey` | `string (https://developers.google.com/discovery/v1/type-format format)` Optional. This field has the same meaning as `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/import#body.request_body.FIELDS.wrapped_key`. Prefer to use that field in new work. Either that field or this field (but not both) must be specified. A base64-encoded string. |
| End of mutually exclusive fields. ||

### Response body

If successful, the response body contains an instance of `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions#CryptoKeyVersion`.

### Authorization scopes

Requires one of the following OAuth scopes:

- `https://www.googleapis.com/auth/cloudkms`
- `https://www.googleapis.com/auth/cloud-platform`

For more information, see the [Authentication Overview](https://docs.cloud.google.com/docs/authentication#authorization-gcp).