---
search:
  tags:
    - Keypairs
    - POST
seo:
  description: >-
    Returns the key id and public key that varsafe export encrypts a .env…
    Reference for the POST /environments/{envId}/sealing-key endpoint in the
    varsafe API.
sidebar:
  label: Get or create an environment sealing key
  badge: POST
title: Get or create an environment sealing key
type: openapi-operation
---
Returns the key id and public key that `varsafe export` encrypts a .env file with, creating the environment keypair on first use. Allowed to anyone who may read the environment’s secret values. The private key never leaves the server.

`POST /environments/{envId}/sealing-key`

**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"
}
```
