---
title: "Create a GPG key for the authenticated user"
method: POST
path: "/user/gpg_keys"
tags: ["users"]
---

# Create a GPG key for the authenticated user

`POST /user/gpg_keys`

Adds a GPG key to the authenticated user's GitHub account.

OAuth app tokens and personal access tokens (classic) need the `write:gpg_key` scope to use this endpoint.

## Request body

- object
  - `name` string — A descriptive name for the new key.
  - `armored_public_key` string, required — A GPG key in ASCII-armored format.

## Response `201`

Response

- GpgKey — A unique encryption key
  - `id` integer, required
  - `name` string, nullable
  - `primary_key_id` integer, nullable, required
  - `key_id` string, required
  - `public_key` string, required
  - `emails` object[], required
    - `email` string
    - `verified` boolean
  - `subkeys` object[], required
    - `id` integer
    - `primary_key_id` integer
    - `key_id` string
    - `public_key` string
    - `emails` object[]
      - `email` string
      - `verified` boolean
    - `subkeys` unknown[]
      - unknown
    - `can_sign` boolean
    - `can_encrypt_comms` boolean
    - `can_encrypt_storage` boolean
    - `can_certify` boolean
    - `created_at` string
    - `expires_at` string, nullable
    - `raw_key` string, nullable
    - `revoked` boolean
  - `can_sign` boolean, required
  - `can_encrypt_comms` boolean, required
  - `can_encrypt_storage` boolean, required
  - `can_certify` boolean, required
  - `created_at` string, date-time, required
  - `expires_at` string, date-time, nullable, required
  - `revoked` boolean, required
  - `raw_key` string, nullable, required

## Other responses

- `304` — Not modified
- `401` — Requires authentication
- `403` — Forbidden
- `404` — Resource not found
- `422` — Validation failed, or the endpoint has been spammed.

---

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