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

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

Returns the public key for the given `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#CryptoKey.FIELDS.purpose` must be `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys#CryptoKeyPurpose.ENUM_VALUES.ASYMMETRIC_SIGN` or `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys#CryptoKeyPurpose.ENUM_VALUES.ASYMMETRIC_DECRYPT`.

### 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   
`GET https://cloudkms.googleapis.com/v1/{name=projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*}/publicKey`

<br />

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

### Path parameters

| Parameters ||
|---|---|
| `name` | `string` Required. The `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions#CryptoKeyVersion.FIELDS.name` of the `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions#CryptoKeyVersion` public key to get. Authorization requires the following [IAM](https://cloud.google.com/iam/docs/) permission on the specified resource `name`: - `cloudkms.cryptoKeyVersions.viewPublicKey` |

### Query parameters

| Parameters ||
|---|---|
| `publicKeyFormat` | ``enum (`https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.importJobs#PublicKeyFormat`)`` Optional. The `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/getPublicKey#body.PublicKey` format specified by the user. This field is required for PQC algorithms. If specified, the public key will be exported through the `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/getPublicKey#body.PublicKey.FIELDS.public_key` field in the requested format. Otherwise, the `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/getPublicKey#body.PublicKey.FIELDS.pem` field will be populated for non-PQC algorithms, and an error will be returned for PQC algorithms. |

### Request body

The request body must be empty.

### Response body

The public keys for a given `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions#CryptoKeyVersion`. Obtained via `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/getPublicKey#google.cloud.kms.v1.KeyManagementService.GetPublicKey`.

If successful, the response body contains data with the following structure:

| JSON representation |
|---|
| ``` { "pem": string, "algorithm": enum (`https://docs.cloud.google.com/kms/docs/reference/rest/v1/CryptoKeyVersionAlgorithm`), "pemCrc32c": string, "name": string, "protectionLevel": enum (`https://docs.cloud.google.com/kms/docs/reference/rest/v1/ProtectionLevel`), "publicKeyFormat": enum (`https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.importJobs#PublicKeyFormat`), "publicKey": { object (`https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/getPublicKey#ChecksummedData`) } } ``` |

| Fields ||
|---|---|
| `pem` | `string` The public key, encoded in PEM format. For more information, see the [RFC 7468](https://tools.ietf.org/html/rfc7468) sections for [General Considerations](https://tools.ietf.org/html/rfc7468#section-2) and [Textual Encoding of Subject Public Key Info](https://tools.ietf.org/html/rfc7468#section-13). |
| `algorithm` | ``enum (`https://docs.cloud.google.com/kms/docs/reference/rest/v1/CryptoKeyVersionAlgorithm`)`` The `https://docs.cloud.google.com/kms/docs/reference/rest/v1/CryptoKeyVersionAlgorithm` associated with this key. |
| `pemCrc32c` | `string (https://developers.google.com/discovery/v1/type-format format)` Integrity verification field. A CRC32C checksum of the returned `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/getPublicKey#body.PublicKey.FIELDS.pem`. An integrity check of `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/getPublicKey#body.PublicKey.FIELDS.pem` can be performed by computing the CRC32C checksum of `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/getPublicKey#body.PublicKey.FIELDS.pem` and comparing your results to this field. Discard the response in case of non-matching checksum values, and perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed `2^32-1`, and can be safely downconverted to uint32 in languages that support this type. NOTE: This field is in Beta. |
| `name` | `string` The `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions#CryptoKeyVersion.FIELDS.name` of the `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions#CryptoKeyVersion` public key. Provided here for verification. NOTE: This field is in Beta. |
| `protectionLevel` | ``enum (`https://docs.cloud.google.com/kms/docs/reference/rest/v1/ProtectionLevel`)`` The `https://docs.cloud.google.com/kms/docs/reference/rest/v1/ProtectionLevel` of the `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions#CryptoKeyVersion` public key. |
| `publicKeyFormat` | ``enum (`https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.importJobs#PublicKeyFormat`)`` The `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/getPublicKey#body.PublicKey` format specified by the customer through the `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/getPublicKey#body.QUERY_PARAMETERS.public_key_format` field. |
| `publicKey` | ``object (`https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/getPublicKey#ChecksummedData`)`` This field contains the public key (with integrity verification), formatted according to the `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/getPublicKey#body.PublicKey.FIELDS.public_key_format` field. |

### 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).

## ChecksummedData

Data with integrity verification field.

| JSON representation |
|---|
| ``` { "data": string, "crc32cChecksum": string } ``` |

| Fields ||
|---|---|
| `data` | `string (https://developers.google.com/discovery/v1/type-format format)` Raw Data. A base64-encoded string. |
| `crc32cChecksum` | `string (https://developers.google.com/discovery/v1/type-format format)` Integrity verification field. A CRC32C checksum of the returned `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/getPublicKey#ChecksummedData.FIELDS.data`. An integrity check of `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/getPublicKey#ChecksummedData.FIELDS.data` can be performed by computing the CRC32C checksum of `https://docs.cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/getPublicKey#ChecksummedData.FIELDS.data` and comparing your results to this field. Discard the response in case of non-matching checksum values, and perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed `2^32-1`, and can be safely downconverted to uint32 in languages that support this type. |