# Port Tunneling

This page has requests to support port tunneling, such as opening and closing port tunneling sessions, and has requests to get information about the open port tunnels.

### Prerequisites

The following are required to use the port tunneling API requests:

* You must have the following Project Permission defined:
  * Remote Terminal & Port Tunnel.
* For using a remote SSH session, you need ssh-client installed on the device.

No ports need to be open on the device or the firewall for port tunneling to work.

## Open Port Tunnel

> Opens a port tunneling session with the device that you specify.\
> \
> Once you obtain the server address and port, you are ready to interact with the device. For more information, see Terminal, Port Tunnel, and Command Runner in the user documentation.

```json
{"openapi":"3.0.0","info":{"title":"Port Tunneling API","version":"1.0.0"},"servers":[{"url":"https://api.connect.jfrog.io"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"You will need to get an access token from the Connect web UI to use the Connect API v2. The v1 token will not work for v2.\n\n    Important: For security reasons, the new token generated by Connect will not be stored. Ensure that you copy the token and save it in a safe place.\n"}},"schemas":{"portTunnelRequest":{"type":"object","properties":{"device_uuid":{"type":"string","description":"The UUID of the device you want to connect to."},"port":{"type":"integer","description":"The port you want to forward. This can be any port number. For example, use 22 for a secure SSH connection to your device."},"allowed_ip":{"type":"string","description":"The port will be accessible only from this IP address. If you do not use this parameter, the allowed IP will be your current IP address."}}},"portTunnelResponse":{"type":"object","properties":{"port_tunnel_id":{"type":"string","description":"The UUID of the port tunnel. This parameter is used in the Close Port Tunnel request to close the port tunneling session."},"server_address":{"type":"string","description":"The address of the server. This is also visible in the web UI."},"server_port":{"type":"integer","description":"The port of the server.  This is also visible in the web UI."}}}}},"paths":{"/api/v2/{project_key}/port_tunnel":{"post":{"summary":"Open Port Tunnel","description":"Opens a port tunneling session with the device that you specify.\n\nOnce you obtain the server address and port, you are ready to interact with the device. For more information, see Terminal, Port Tunnel, and Command Runner in the user documentation.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/portTunnelRequest"}}}},"parameters":[{"name":"project_key","in":"path","schema":{"type":"string"},"required":true,"description":"The fleet key of the relevant fleet in the account. An account can have multiple fleets (formerly called projects). If you don't know the fleet key, you can find it in the Fleet Settings of the web UI."}],"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/portTunnelResponse"}}}}}}}}}
```

{% openapi src="/files/UeWoz3ss1wbQBvxCGAz9" path="/api/v2/{project\_key}/port\_tunnel" method="get" %}
[port-tunnel-openapi-jm01.yaml](https://content.gitbook.com/content/RPSTjDOh8m1HIptqGtC4/blobs/xaAP4CnikPMamRjivto4/port-tunnel-openapi-jm01.yaml)
{% endopenapi %}

{% openapi src="/files/UeWoz3ss1wbQBvxCGAz9" path="/api/v2/{project\_key}/port\_tunnel/{port\_tunnel\_id}" method="get" %}
[port-tunnel-openapi-jm01.yaml](https://content.gitbook.com/content/RPSTjDOh8m1HIptqGtC4/blobs/xaAP4CnikPMamRjivto4/port-tunnel-openapi-jm01.yaml)
{% endopenapi %}

{% openapi src="/files/UeWoz3ss1wbQBvxCGAz9" path="/api/v2/{project\_key}/port\_tunnel/{port\_tunnel\_id}" method="delete" %}
[port-tunnel-openapi-jm01.yaml](https://content.gitbook.com/content/RPSTjDOh8m1HIptqGtC4/blobs/xaAP4CnikPMamRjivto4/port-tunnel-openapi-jm01.yaml)
{% endopenapi %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.connect.jfrog.io/developers/api-reference/connect-api-reference/port-tunneling.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
