---
title: "Get public key for the authenticated user"
method: GET
path: "/user/codespaces/secrets/public-key"
tags: ["codespaces"]
---

# Get public key for the authenticated user

`GET /user/codespaces/secrets/public-key`

Gets your public key, which you need to encrypt secrets. You need to encrypt a secret before you can create or update secrets.

The authenticated user must have Codespaces access to use this endpoint.

OAuth app tokens and personal access tokens (classic) need the `codespace` or `codespace:secrets` scope to use this endpoint.

## Response `200`

Response

- CodespacesUserPublicKey — The public key used for setting user Codespaces' Secrets.
  - `key_id` string, required — The identifier for the key.
  - `key` string, required — The Base64 encoded public key.

---

[API](https://skmtc.net/github/apis/rest-api.md) · [All operations](https://skmtc.net/github/apis/rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/github/rest-api/revisions/80850db290cd/schema)
