---
search:
  tags:
    - Keypairs
    - GET
seo:
  description: >-
    Returns the public half of the environment keypair, used to encrypt values…
    Reference for the GET /environments/{envId}/keypair endpoint in the varsafe
    API.
sidebar:
  label: Get an environment public key
  badge: GET
title: Get an environment public key
type: openapi-operation
---
Returns the public half of the environment keypair, used to encrypt values into a committable encrypted .env file. The private half is never returned by this route.

`GET /environments/{envId}/keypair`

**Responses**

- `200` — Success.
- `400` — The request failed validation. \`field\` names the offending input.
- `401` — No credential was presented, or it is invalid or revoked.
- `403` — The credential is valid but lacks the required scope, role or team access.
- `404` — The resource does not exist, or is not visible to this credential.
- `429` — Rate limited. Retry after the interval named in the response.
- `500` — Unexpected server error. The body never carries internal detail.

Response example, 200:

```json
{
  "keyId": "string",
  "publicKey": "string",
  "version": 0,
  "isActive": true,
  "createdAt": "2019-08-24T14:15:22Z",
  "rotatedAt": "2019-08-24T14:15:22Z"
}
```
