---
title: "Add an SSH public key"
method: POST
path: "/v2/ssh-keys"
tags: ["ssh-keys"]
---

# Add an SSH public key

`POST /v2/ssh-keys`

Adds an SSH public key. Reports SSH_PUBLIC_KEY_ALREADY_EXISTS on duplicate SSH public key values.

## Request body

- object
  - `publicKey` string, required
  - `name` string

## Response `200`

Successful response

- object
  - `id` integer, required
  - `publicKey` string, required
  - `name` string, nullable, required
  - `createdAt` string, required

## Other responses

- `400` — Invalid input data
- `401` — Authorization not provided
- `403` — Insufficient access
- `500` — Internal server error

## Changes

- **2026-09-26** `6b22302ea98a` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/hyperbolic/apis/castle-api/changes/v2/ssh-keys/post.md)

---

[API](https://skmtc.dev/hyperbolic/apis/castle-api.md) · [All operations](https://skmtc.dev/hyperbolic/apis/castle-api/llms.txt) · [OpenAPI document](https://skmtc.dev/hyperbolic/apis/castle-api/revisions/6b22302ea98a?raw)
