---
title: "Attach public key"
method: POST
path: "/api/vps/v1/public-keys/attach/{virtualMachineId}"
tags: ["VPS: Public Keys"]
---

# Attach public key

`POST /api/vps/v1/public-keys/attach/{virtualMachineId}`

Attach existing public keys from your account to a specified virtual machine.

Multiple keys can be attached to a single virtual machine.

Use this endpoint to enable SSH key authentication for VPS instances.

## Path parameters

- `virtualMachineId` integer, required

## Request body

- VPSV1PublicKeyAttachRequest
  - `ids` integer[], required — Public Key IDs to attach

## Response `200`

Success response

- VPSV1ActionActionResource
  - `id` integer — Action ID
  - `name` string — Action name
  - `state` 'success' | 'error' | 'delayed' | 'sent' | 'created' — Action state
  - `created_at` string, date-time
  - `updated_at` string, date-time

## Other responses

- `401` — Unauthenticated response
- `422` — Validation error response
- `500` — Error response

---

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