Create a Tunnel
"Tunnel" in this API refers to a live connection a running agent has open to the platform — it's read-only state surfaced by GET /v1/tunnels. You don't create tunnels directly via REST.
To get a live tunnel, do one of the following:
- Provision a configured endpoint via POST /v1/endpoints and connect the agent with the resulting credentials. The endpoint persists; tunnels open and close as the agent reconnects.
- Open an ad-hoc tunnel from a process using the Python SDK or agent CLI. The platform mints a one-shot endpoint behind the scenes.
Request — provision an endpoint (REST)
curl -X POST "https://api.ngris.com/v1/endpoints" \
-H "X-API-KEY: <your_api_key>" \
-H "Content-Type: application/json" \
-d '{
"subdomain": "myapp",
"protocol": "http",
"region": "eu-north-1"
}'
Python
from ngris import Ngris
client = Ngris(api_key="<your_api_key>")
ep = client.endpoints.create({
"subdomain": "myapp",
"protocol": "http",
"region": "eu-north-1",
})
print(ep.uuid)
Python — ad-hoc live tunnel
import ngris
# Spawns the agent in-process; revoked on context exit.
with ngris.connect(8080, api_key="<your_api_key>") as t:
print(t.public_url)