Tunnels API
Manage your tunnels programmatically with the Tunnels API.
List All Tunnels
Get all tunnels for the authenticated user.
bash
curl https://intunnel.cloud/api/tunnels \
-H "Authorization: Bearer YOUR_TOKEN"Response
json
{
"success": true,
"tunnels": [
{
"id": 1,
"subdomain": "myapp",
"domain": "intunnel.cloud",
"token": "tun_abc123...",
"description": "Development server",
"created_at": "2024-01-15T10:30:00Z",
"last_connected": "2024-01-20T14:22:00Z",
"is_active": true
}
]
}Get Single Tunnel
Get details for a specific tunnel.
bash
curl https://intunnel.cloud/api/tunnels/1 \
-H "Authorization: Bearer YOUR_TOKEN"Response
json
{
"success": true,
"tunnel": {
"id": 1,
"subdomain": "myapp",
"domain": "intunnel.cloud",
"token": "tun_abc123...",
"description": "Development server",
"device_binding": false,
"ip_whitelist": null,
"created_at": "2024-01-15T10:30:00Z",
"last_connected": "2024-01-20T14:22:00Z"
}
}Create Tunnel
Create a new tunnel.
bash
curl -X POST https://intunnel.cloud/api/tunnels \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"subdomain": "newapp",
"domain": "intunnel.cloud",
"description": "My new project"
}'Request Body
| Field | Type | Required | Description |
|---|---|---|---|
subdomain | string | Yes | Unique subdomain |
domain | string | No | Domain (default: intunnel.cloud) |
description | string | No | Description for your reference |
Response
json
{
"success": true,
"tunnel": {
"id": 2,
"subdomain": "newapp",
"domain": "intunnel.cloud",
"token": "tun_xyz789...",
"description": "My new project",
"created_at": "2024-01-21T09:00:00Z"
}
}Update Tunnel
Update an existing tunnel.
bash
curl -X PUT https://intunnel.cloud/api/tunnels/1 \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"description": "Updated description",
"device_binding": true,
"ip_whitelist": "192.168.1.1,10.0.0.0/24"
}'Request Body
| Field | Type | Description |
|---|---|---|
description | string | New description |
device_binding | boolean | Enable/disable device binding |
ip_whitelist | string | Comma-separated IPs or CIDRs |
Response
json
{
"success": true,
"tunnel": {
"id": 1,
"subdomain": "myapp",
"description": "Updated description",
"device_binding": true,
"ip_whitelist": "192.168.1.1,10.0.0.0/24"
}
}Delete Tunnel
Delete a tunnel permanently.
bash
curl -X DELETE https://intunnel.cloud/api/tunnels/1 \
-H "Authorization: Bearer YOUR_TOKEN"Response
json
{
"success": true,
"message": "Tunnel deleted successfully"
}WARNING
Deletion is permanent. The subdomain will become available for others to use.
Regenerate Token
Generate a new token for a tunnel (invalidates the old one).
bash
curl -X POST https://intunnel.cloud/api/tunnels/1/regenerate-token \
-H "Authorization: Bearer YOUR_TOKEN"Response
json
{
"success": true,
"token": "tun_newtoken123..."
}Reset Device Binding
Reset the device binding for a tunnel.
bash
curl -X POST https://intunnel.cloud/api/tunnels/1/reset-device \
-H "Authorization: Bearer YOUR_TOKEN"Response
json
{
"success": true,
"message": "Device binding reset successfully"
}Error Responses
Tunnel Not Found
json
{
"success": false,
"error": "Tunnel not found"
}Status: 404 Not Found
Subdomain Taken
json
{
"success": false,
"error": "Subdomain already in use"
}Status: 400 Bad Request
Invalid Subdomain
json
{
"success": false,
"error": "Invalid subdomain format"
}Status: 400 Bad Request
Subdomain Rules
Valid subdomains must:
- Be 3-30 characters long
- Contain only letters, numbers, and hyphens
- Start and end with a letter or number
- Not contain consecutive hyphens
Valid: myapp, my-app, app123Invalid: -myapp, my--app, ab
Code Examples
Python
python
import requests
API_URL = "https://intunnel.cloud/api"
TOKEN = "your-session-token"
headers = {"Authorization": f"Bearer {TOKEN}"}
# List tunnels
response = requests.get(f"{API_URL}/tunnels", headers=headers)
tunnels = response.json()["tunnels"]
# Create tunnel
new_tunnel = requests.post(
f"{API_URL}/tunnels",
headers=headers,
json={"subdomain": "myapp", "description": "Test"}
).json()JavaScript
javascript
const API_URL = 'https://intunnel.cloud/api';
const TOKEN = 'your-session-token';
const headers = {
'Authorization': `Bearer ${TOKEN}`,
'Content-Type': 'application/json'
};
// List tunnels
const tunnels = await fetch(`${API_URL}/tunnels`, { headers })
.then(r => r.json());
// Create tunnel
const newTunnel = await fetch(`${API_URL}/tunnels`, {
method: 'POST',
headers,
body: JSON.stringify({ subdomain: 'myapp', description: 'Test' })
}).then(r => r.json());