SSH Keys
Manage SSH keys that can be attached to workloads for secure shell access.
Authentication
All SSH key endpoints require authentication using a Bearer token. Include your API key in the Authorization header:
Authorization: Bearer <YOUR_API_KEY>
Create SSH Key
Create a new SSH key.
Endpoint
POST /tha/v2/ssh-keys
Request Body
| Field | Type | Description |
|---|---|---|
name | string | Required. Name for the SSH key. |
ssh_key | string | Required. The public SSH key content. |
Example Request
curl -X POST https://api.targon.com/tha/v2/ssh-keys \
-H "Authorization: Bearer <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"name": "my-laptop",
"ssh_key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA..."
}'
Response
Returns the created SSH key object.
| Field | Type | Description |
|---|---|---|
uid | string | Unique identifier for the SSH key. |
name | string | Name of the SSH key. |
public_key_raw | string | The public SSH key content. |
created_at | string | ISO 8601 creation timestamp. |
updated_at | string | ISO 8601 last update timestamp. |
Example Response
{
"uid": "shk-abc123def456",
"name": "my-laptop",
"public_key_raw": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA...",
"created_at": "2025-01-15T10:30:00Z",
"updated_at": "2025-01-15T10:30:00Z"
}
Errors
| Status Code | Description |
|---|---|
| 400 - Bad Request | Invalid request body. |
| 401 - Unauthorized | Invalid or missing API key. |
| 500 - Internal Server Error | Server error. |
List SSH Keys
List all SSH keys for the authenticated user.
Endpoint
GET /tha/v2/ssh-keys
Query Parameters
| Field | Type | Description |
|---|---|---|
limit | integer | Maximum number of items to return. |
cursor | string | Pagination cursor. |
Example Request
curl -X GET "https://api.targon.com/tha/v2/ssh-keys?limit=10" \
-H "Authorization: Bearer <YOUR_API_KEY>"
Response
| Field | Type | Description |
|---|---|---|
items | array | List of SSH key objects. |
next_cursor | string | Cursor for the next page of results. |
Example Response
{
"items": [
{
"uid": "shk-abc123def456",
"name": "my-laptop",
"public_key_raw": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA...",
"created_at": "2025-01-15T10:30:00Z",
"updated_at": "2025-01-15T10:30:00Z"
}
],
"next_cursor": ""
}
Errors
| Status Code | Description |
|---|---|
| 400 - Bad Request | Invalid query parameters. |
| 401 - Unauthorized | Invalid or missing API key. |
| 500 - Internal Server Error | Server error. |
Get SSH Key
Retrieve an SSH key by its UID.
Endpoint
GET /tha/v2/ssh-keys/{ssh_key_uid}
Path Parameters
| Field | Type | Description |
|---|---|---|
ssh_key_uid | string | Unique identifier of the SSH key. |
Example Request
curl -X GET https://api.targon.com/tha/v2/ssh-keys/shk-abc123def456 \
-H "Authorization: Bearer <YOUR_API_KEY>"
Response
Returns the SSH key object.
Example Response
{
"uid": "shk-abc123def456",
"name": "my-laptop",
"public_key_raw": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA...",
"created_at": "2025-01-15T10:30:00Z",
"updated_at": "2025-01-15T10:30:00Z"
}
Errors
| Status Code | Description |
|---|---|
| 401 - Unauthorized | Invalid or missing API key. |
| 403 - Forbidden | Not allowed. |
| 404 - Not Found | SSH key not found. |
| 500 - Internal Server Error | Server error. |
Update SSH Key
Update an SSH key's name.
Endpoint
PATCH /tha/v2/ssh-keys/{ssh_key_uid}
Path Parameters
| Field | Type | Description |
|---|---|---|
ssh_key_uid | string | Unique identifier of the SSH key. |
Request Body
| Field | Type | Description |
|---|---|---|
name | string | Required. New name for the SSH key. |
Example Request
curl -X PATCH https://api.targon.com/tha/v2/ssh-keys/shk-abc123def456 \
-H "Authorization: Bearer <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"name": "work-laptop"
}'
Response
Returns the updated SSH key object.
Example Response
{
"uid": "shk-abc123def456",
"name": "work-laptop",
"public_key_raw": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA...",
"created_at": "2025-01-15T10:30:00Z",
"updated_at": "2025-01-16T08:00:00Z"
}
Errors
| Status Code | Description |
|---|---|
| 400 - Bad Request | Invalid request body. |
| 401 - Unauthorized | Invalid or missing API key. |
| 403 - Forbidden | Not allowed. |
| 404 - Not Found | SSH key not found. |
| 500 - Internal Server Error | Server error. |
Delete SSH Key
Delete an SSH key.
Endpoint
DELETE /tha/v2/ssh-keys/{ssh_key_uid}
Path Parameters
| Field | Type | Description |
|---|---|---|
ssh_key_uid | string | Unique identifier of the SSH key. |
Example Request
curl -X DELETE https://api.targon.com/tha/v2/ssh-keys/shk-abc123def456 \
-H "Authorization: Bearer <YOUR_API_KEY>"
Response
Returns 204 No Content on success.
Errors
| Status Code | Description |
|---|---|
| 401 - Unauthorized | Invalid or missing API key. |
| 403 - Forbidden | Not allowed. |
| 404 - Not Found | SSH key not found. |
| 500 - Internal Server Error | Server error. |