---
title: "Create a public key for a user"
method: POST
path: "/admin/users/{username}/keys"
tags: ["Administration"]
---

# Create a public key for a user

`POST /admin/users/{username}/keys`

Requires the authenticated user to be a site administrator.

## Path parameters

- `username` string, required

## Request body

- object
  - `title` string, required
  - `key` string, required

## Response `201`

Created

- PublicKey
  - `id` integer
  - `key` string
  - `url` string
  - `title` string
  - `created_at` string, date-time

## Other responses

- `404` — Resource not found.
- `422` — Validation error.

---

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