# REST Resource: projects.locations.keyRings.cryptoKeys

- [Resource: CryptoKey](https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.locations.keyRings.cryptoKeys#CryptoKey)
  - [JSON representation](https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.locations.keyRings.cryptoKeys#CryptoKey.SCHEMA_REPRESENTATION)
- [Methods](https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.locations.keyRings.cryptoKeys#METHODS_SUMMARY)

## Resource: CryptoKey

A `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey` represents a logical key that can be used for cryptographic operations.

A `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey` is made up of zero or more `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.CryptoKeyVersion`, which represent the actual key material used in cryptographic operations.

| JSON representation |
|---|
| ``` { "name": string, "primary": { object (`https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.CryptoKeyVersion`) }, "purpose": enum (`https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.CryptoKeyPurpose`), "createTime": string, "nextRotationTime": string, "versionTemplate": { object (`https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.CryptoKeyVersionTemplate`) }, "labels": { string: string, ... }, "importOnly": boolean, "destroyScheduledDuration": string, "cryptoKeyBackend": string, // Union field `rotation_schedule` can be only one of the following: "rotationPeriod": string // End of list of possible types for union field `rotation_schedule`. } ``` |

| Fields ||
|---|---|
| `name` | `string` Output only. The resource name for this `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey` in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*`. |
| `primary` | ``object (`https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.CryptoKeyVersion`)`` Output only. A copy of the "primary" `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.CryptoKeyVersion` that will be used by \[Encrypt\]\[KeyManagementService.Encrypt\] when this `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey` is given in \[EncryptRequest.name\]\[\]. The `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey`'s primary version can be updated via \[UpdateCryptoKeyPrimaryVersion\]\[KeyManagementService.UpdateCryptoKeyPrimaryVersion\]. Keys with `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.FIELDS.purpose` `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.CryptoKeyPurpose.ENUM_VALUES.ENCRYPT_DECRYPT` may have a primary. For other keys, this field will be omitted. |
| `purpose` | ``enum (`https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.CryptoKeyPurpose`)`` Immutable. The immutable purpose of this `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey`. |
| `createTime` | ``string (`https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestamp` format)`` Output only. The time at which this `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey` was created. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: `"2014-10-02T15:01:23Z"` and `"2014-10-02T15:01:23.045123456Z"`. |
| `nextRotationTime` | ``string (`https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestamp` format)`` At `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.FIELDS.next_rotation_time`, the Key Management Service will automatically: 1. Create a new version of this `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey`. 2. Mark the new version as primary. Key rotations performed manually via \[CreateCryptoKeyVersion\]\[KeyManagementService.CreateCryptoKeyVersion\] and \[UpdateCryptoKeyPrimaryVersion\]\[KeyManagementService.UpdateCryptoKeyPrimaryVersion\] do not affect `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.FIELDS.next_rotation_time`. Keys with `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.FIELDS.purpose` `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.CryptoKeyPurpose.ENUM_VALUES.ENCRYPT_DECRYPT` support automatic rotation. For other keys, this field must be omitted. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: `"2014-10-02T15:01:23Z"` and `"2014-10-02T15:01:23.045123456Z"`. |
| `versionTemplate` | ``object (`https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.CryptoKeyVersionTemplate`)`` A template describing settings for new `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.CryptoKeyVersion` instances. The properties of new `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.CryptoKeyVersion` instances created by either \[CreateCryptoKeyVersion\]\[KeyManagementService.CreateCryptoKeyVersion\] or auto-rotation are controlled by this template. |
| `labels` | `map (key: string, value: string)` Labels with user-defined metadata. For more information, see [Labeling Keys](https://cloud.google.com/kms/docs/labeling-keys). |
| `importOnly` | `boolean` Immutable. Whether this key may contain imported versions only. |
| `destroyScheduledDuration` | ``string (`https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Duration` format)`` Immutable. The period of time that versions of this key spend in the `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.CryptoKeyVersionState.ENUM_VALUES.DESTROY_SCHEDULED` state before transitioning to `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.CryptoKeyVersionState.ENUM_VALUES.DESTROYED`. If not specified at creation time, the default duration is 24 hours. A duration in seconds with up to nine fractional digits, ending with '`s`'. Example: `"3.5s"`. |
| `cryptoKeyBackend` | `string` Immutable. The resource name of the backend environment where the key material for all `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.CryptoKeyVersion` associated with this `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey` reside and where all related cryptographic operations are performed. Only applicable if `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.CryptoKeyVersion` have a `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.ProtectionLevel` of \[EXTERNAL_VPC\]\[CryptoKeyVersion.ProtectionLevel.EXTERNAL_VPC\], with the resource name in the format `projects/*/locations/*/ekmConnections/*`. Note, this list is non-exhaustive and may apply to additional `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.ProtectionLevel` in the future. |
| Union field `rotation_schedule`. Controls the rate of automatic rotation. `rotation_schedule` can be only one of the following: ||
| `rotationPeriod` | ``string (`https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Duration` format)`` `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.FIELDS.next_rotation_time` will be advanced by this period when the service automatically rotates a key. Must be at least 24 hours and at most 876,000 hours. If `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.FIELDS.rotation_period` is set, `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.FIELDS.next_rotation_time` must also be set. Keys with `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.FIELDS.purpose` `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey.CryptoKeyPurpose.ENUM_VALUES.ENCRYPT_DECRYPT` support automatic rotation. For other keys, this field must be omitted. A duration in seconds with up to nine fractional digits, ending with '`s`'. Example: `"3.5s"`. |

| ## Methods ||
|---|---|
| ### `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.locations.keyRings.cryptoKeys/getProtectedResourcesSummary` | Returns aggregate information about the resources protected by the given Cloud KMS `https://docs.cloud.google.com/kms/docs/reference/inventory/rest/v1/projects.cryptoKeys#CryptoKey`. |