Skip to main content

Overview

The Machines API allows you to create, read, and delete SSH machine configurations. All endpoints require JWT authentication.

Create Machine

cURL
curl -X POST "http://localhost:8080/api/v1/machine" \
  -H "Content-Type: application/json" \
  -b "jwt=your-jwt-token" \
  -d '{
    "name": "Production Server",
    "hostname": "192.168.1.100",
    "port": "22",
    "username": "ubuntu",
    "password": "optional-password",
    "private_key": "optional-private-key",
    "passphrase": "optional-passphrase",
    "organization": "my-org"
  }'
POST /api/v1/machine Create a new SSH machine configuration.

Request Body

name
string
required
Friendly name for the machine
hostname
string
required
IP address or hostname of the SSH server
port
string
required
SSH port (typically “22”)
username
string
required
SSH username for authentication
password
string
SSH password (required if not using private key). Encrypted before storage.
private_key
string
SSH private key (required if not using password). Encrypted before storage.
passphrase
string
Passphrase for encrypted private key (optional). Encrypted before storage.
organization
string
Organization identifier (optional)

Response

{
  "status": "OK",
  "message": "Machine created successfully",
  "data": null
}

Error Responses


List Machines

cURL
curl -X GET "http://localhost:8080/api/v1/machines" \
  -b "jwt=your-jwt-token"
GET /api/v1/machines Retrieve all machines for the authenticated user.

Response

{
  "status": "OK",
  "message": "Machines fetched successfully",
  "data": [
    {
      "id": 1,
      "name": "Production Server",
      "username": "ubuntu",
      "hostname": "192.168.1.100",
      "port": "22",
      "owner_id": "[email protected]",
      "owner_type": "user"
    },
    {
      "id": 2,
      "name": "Development Server",
      "username": "admin",
      "hostname": "dev.example.com",
      "port": "2222",
      "owner_id": "[email protected]",
      "owner_type": "user"
    }
  ]
}

Response Fields

data
array
Array of machine objects
data[].id
number
Unique machine identifier
data[].name
string
Machine name
data[].username
string
SSH username
data[].hostname
string
SSH hostname or IP address
data[].port
string
SSH port
data[].owner_id
string
User email who owns this machine
data[].owner_type
string
Owner type (always “user”)

Notes

  • Sensitive fields (password, private_key, passphrase) are NOT returned by this endpoint
  • Only machines owned by the authenticated user are returned
  • Results are filtered by username extracted from JWT token

Error Responses


Get Machine

cURL
curl -X GET "http://localhost:8080/api/v1/machine/1" \
  -b "jwt=your-jwt-token"
GET /api/v1/machine/{id} Retrieve details for a specific machine.

Path Parameters

id
string
required
Machine ID

Response

{
  "status": "OK",
  "message": "Machine fetched successfully",
  "data": {
    "id": 1,
    "name": "Production Server",
    "username": "ubuntu",
    "hostname": "192.168.1.100",
    "port": "22",
    "owner_id": "[email protected]",
    "owner_type": "user"
  }
}

Response Fields

data
object
Machine object
data.id
number
Unique machine identifier
data.name
string
Machine name
data.username
string
SSH username
data.hostname
string
SSH hostname or IP address
data.port
string
SSH port
data.owner_id
string
User email who owns this machine
data.owner_type
string
Owner type (always “user”)

Notes

  • Sensitive fields (password, private_key, passphrase) are NOT returned
  • Users can only access machines they own
  • Authorization is enforced via JWT username

Error Responses


Delete Machine

cURL
curl -X DELETE "http://localhost:8080/api/v1/machine/1" \
  -b "jwt=your-jwt-token"
DELETE /api/v1/machine/{id} Delete a machine configuration.

Path Parameters

id
string
required
Machine ID to delete

Response

{
  "status": "OK",
  "message": "Machine deleted successfully",
  "data": null
}

Notes

  • Users can only delete machines they own
  • Authorization is enforced via JWT username
  • Deletion is permanent and cannot be undone

Error Responses


Connect to Machine

cURL
curl -X POST "http://localhost:8080/api/v1/machine/1/connect" \
  -H "Content-Type: application/json" \
  -b "jwt=your-jwt-token" \
  -d '{
    "password": "your-master-password"
  }'
POST /api/v1/machine/{id}/connect Initiate an SSH connection and retrieve a UUID for WebSocket connection.

Path Parameters

id
string
required
Machine ID to connect to

Request Body

password
string
required
Master password to decrypt machine credentials (encrypted private key, passphrase, or SSH password)

Response

{
  "status": "OK",
  "message": "Connected to machine successfully",
  "data": "550e8400-e29b-41d4-a716-446655440000"
}
data
string
UUID for establishing WebSocket connection. Valid for the current time bucket (rounded to nearest minute).

Connection Flow

  1. User provides master password to decrypt credentials
  2. Machine credentials are retrieved from database and decrypted
  3. SSH connection is established to the remote machine
  4. UUID is generated and SSH client is stored in memory
  5. UUID is associated with a time bucket (rounded to nearest minute)
  6. Client uses UUID to establish WebSocket connection at /ssh?uuid={uuid}

Notes

  • The UUID is temporary and stored in memory with a time bucket
  • Time buckets are used for automatic cleanup of stale connections
  • The SSH connection remains open until WebSocket is established
  • Users can only connect to machines they own

Error Responses

Build docs developers (and LLMs) love