Docs
Live demo
POST/api/v2/ssh-tunnels

Create a new SSH tunnel. The tunnel is created but not started. Requires a valid test_token from a successful test-connection call. A target_id links the tunnel to that PostgreSQL target and takes the forwarded endpoint from its connection string, as PATCH does. A target that cannot be linked is rejected before the tunnel is saved. remote_host and remote_port set the forwarded endpoint and win over the endpoint of the linked target.

Requires name, ssh_host, ssh_user, ssh_key_id and test_token. Attach targets via ssh_tunnel_id on the target (or target_id here for PostgreSQL).

Request body application/json · CreateSSHTunnelRequest

SSH tunnel creation request

Required5 of 10 fields
namestringrequired
min length 1 · max length 100
ssh_hoststringrequired
ssh_key_idstringrequired
ssh_userstringrequired
min length 1 · max length 255
test_tokenstringrequired

Token from successful test-connection

Optional5 fields
remote_hoststring

Host the tunnel forwards to, as seen from the bastion. Set together with remote_port. A value wins over the endpoint of the linked target.

remote_portinteger

Port the tunnel forwards to. Set together with remote_host.

min 1 · max 65535
ssh_portinteger
min 1 · max 65535
sudo_passwordstring

Password for sudo operations on remote server

min length 1 · max length 255
target_idstring

PostgreSQL target to link the tunnel to. The forwarded endpoint is taken from its connection string.

Responses

201

Created

SSHTunnelResponse · 18 fields
created_atstring
error_messagestring

Reason of the last failure of the tunnel in Principal's words. Never a driver or dial error

health_checked_atstring
health_error_messagestring

Reason of the last failed health check, or of the failed reconnects of a tunnel that stopped because nobody used it

health_statusstring
idstring
last_connected_atstring
local_portinteger

Always 0. Principal no longer opens a local port for a tunnel. Kept for wire compatibility.

deprecated
namestring
remote_hoststring
remote_portinteger
ssh_hoststring
ssh_key_idstring

SSH key the tunnel signs in with. Omitted when the tunnel has no key.

ssh_portinteger
ssh_userstring
statusstring
disconnectedconnectingconnectedfailed
target_idstring
updated_atstring
404

The target to link was not found

409

Mutations of the target to link are paused

Common errors: 400 401 403 413 429 503 504. They mean the same for every operation, see Errors.

↑ ↓ to moveEnter to openEsc to close