Skip to main content

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

FieldTypeDescription
namestringRequired. Name for the SSH key.
ssh_keystringRequired. 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.

FieldTypeDescription
uidstringUnique identifier for the SSH key.
namestringName of the SSH key.
public_key_rawstringThe public SSH key content.
created_atstringISO 8601 creation timestamp.
updated_atstringISO 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 CodeDescription
400 - Bad RequestInvalid request body.
401 - UnauthorizedInvalid or missing API key.
500 - Internal Server ErrorServer error.

List SSH Keys

List all SSH keys for the authenticated user.

Endpoint

GET /tha/v2/ssh-keys

Query Parameters

FieldTypeDescription
limitintegerMaximum number of items to return.
cursorstringPagination cursor.

Example Request

curl -X GET "https://api.targon.com/tha/v2/ssh-keys?limit=10" \
-H "Authorization: Bearer <YOUR_API_KEY>"

Response

FieldTypeDescription
itemsarrayList of SSH key objects.
next_cursorstringCursor 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 CodeDescription
400 - Bad RequestInvalid query parameters.
401 - UnauthorizedInvalid or missing API key.
500 - Internal Server ErrorServer error.

Get SSH Key

Retrieve an SSH key by its UID.

Endpoint

GET /tha/v2/ssh-keys/{ssh_key_uid}

Path Parameters

FieldTypeDescription
ssh_key_uidstringUnique 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 CodeDescription
401 - UnauthorizedInvalid or missing API key.
403 - ForbiddenNot allowed.
404 - Not FoundSSH key not found.
500 - Internal Server ErrorServer error.

Update SSH Key

Update an SSH key's name.

Endpoint

PATCH /tha/v2/ssh-keys/{ssh_key_uid}

Path Parameters

FieldTypeDescription
ssh_key_uidstringUnique identifier of the SSH key.

Request Body

FieldTypeDescription
namestringRequired. 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 CodeDescription
400 - Bad RequestInvalid request body.
401 - UnauthorizedInvalid or missing API key.
403 - ForbiddenNot allowed.
404 - Not FoundSSH key not found.
500 - Internal Server ErrorServer error.

Delete SSH Key

Delete an SSH key.

Endpoint

DELETE /tha/v2/ssh-keys/{ssh_key_uid}

Path Parameters

FieldTypeDescription
ssh_key_uidstringUnique 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 CodeDescription
401 - UnauthorizedInvalid or missing API key.
403 - ForbiddenNot allowed.
404 - Not FoundSSH key not found.
500 - Internal Server ErrorServer error.