---
title: "Get a repository public key"
method: GET
path: "/repos/{owner}/{repo}/codespaces/secrets/public-key"
tags: ["codespaces"]
---

# Get a repository public key

`GET /repos/{owner}/{repo}/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.

If the repository is private, OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.

## Path parameters

- `owner` string, required
- `repo` string, required

## Response `200`

Response

- CodespacesPublicKey — The public key used for setting Codespaces secrets.
  - `key_id` string, required — The identifier for the key.
  - `key` string, required — The Base64 encoded public key.
  - `id` integer
  - `url` string
  - `title` string
  - `created_at` string

---

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