> For AI agents: the complete documentation index is available at https://proxykite.com/docs/llms.txt, the full documentation bundle is available at https://proxykite.com/docs/llms-full.txt.

# Ports

Each proxy has a public **host:port** on our cloud router. Two layouts:

| Mode               | What it means                                                                                              |
| ------------------ | ---------------------------------------------------------------------------------------------------------- |
| `shared` (default) | One port speaks HTTP, HTTPS (`CONNECT`) **and** SOCKS5. `http_port` and `socks5_port` are the same number. |
| `split`            | Two ports: `http_port` speaks HTTP/HTTPS only, `socks5_port` speaks SOCKS5 only.                           |

The ready-made strings in [`GET /proxies/{id}`](https://proxykite.com/docs/api/proxies.md) (`users[].http`, `users[].socks5`) always use the right port.
You can pick the port numbers yourself from the cloud router's free range (`range`, 30000–30999 today). A port another proxy
uses (yours or another customer's) cannot be taken.

:::warning
Changing a port or the mode **changes the proxy's address**. Every client still using the old address stops working
within about 10 seconds. Each change is written to the activity log.
:::

In `split` mode each port refuses the other protocol once the box runs agent **1.3.0** or newer (a SOCKS5 client on the
HTTP port is refused; an HTTP client on the SOCKS5 port gets `400`). With an older agent both ports accept both.

## Get the ports


`GET /proxies/{id}/ports`

**Ability:** `read`



**curl**

```bash
curl 'https://proxykite.com/api/v1/proxies/7/ports' \
  -H "Authorization: Bearer $HYP_TOKEN" \
  -H 'Accept: application/json'
```


**Python**

```python
import os
import requests

r = requests.get(
    "https://proxykite.com/api/v1/proxies/7/ports",
    headers={"Authorization": f"Bearer {os.environ['HYP_TOKEN']}", "Accept": "application/json"},
    timeout=30,
)
print(r.status_code, r.json())
```


**Node.js**

```js
const res = await fetch('https://proxykite.com/api/v1/proxies/7/ports', {
  headers: {
    Authorization: `Bearer ${process.env.HYP_TOKEN}`,
    Accept: 'application/json',
  },
  signal: AbortSignal.timeout(30000),
});
console.log(res.status, await res.json());
```


**PHP**

```php
<?php
$ch = curl_init('https://proxykite.com/api/v1/proxies/7/ports');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('HYP_TOKEN'),
        'Accept: application/json',
    ],
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
var_dump($status, json_decode($body, true));
```



**Response `200`**

```json
{"data": {"mode": "split", "http_port": 30007, "socks5_port": 30544, "host": "ind1.proxykite.com",
  "range": {"min": 30000, "max": 30999}}}
```

## Change the ports


`PUT /proxies/{id}/ports`

**Ability:** `manage` · **Who:** the account owner or a team admin. At most 20 changes per minute.

| Body field    | Type    |                                                                                                                                       |
| ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| `mode`        | string  | **required**: `shared` or `split`                                                                                                     |
| `http_port`   | integer | optional, new HTTP port (in `shared` mode: the one port). Leave it out to keep the current one                                        |
| `socks5_port` | integer | optional, `split` only, new SOCKS5 port. Leave it out to keep the current one, or to get a random free port when switching to `split` |



**curl**

```bash
curl -X PUT 'https://proxykite.com/api/v1/proxies/7/ports' \
  -H "Authorization: Bearer $HYP_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{"mode":"split","socks5_port":30544}'
```


**Python**

```python
import os
import requests

r = requests.put(
    "https://proxykite.com/api/v1/proxies/7/ports",
    headers={"Authorization": f"Bearer {os.environ['HYP_TOKEN']}", "Accept": "application/json"},
    json={"mode": "split", "socks5_port": 30544},
    timeout=30,
)
print(r.status_code, r.json())
```


**Node.js**

```js
const res = await fetch('https://proxykite.com/api/v1/proxies/7/ports', {
  method: 'PUT',
  headers: {
    Authorization: `Bearer ${process.env.HYP_TOKEN}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"mode":"split","socks5_port":30544}),
  signal: AbortSignal.timeout(30000),
});
console.log(res.status, await res.json());
```


**PHP**

```php
<?php
$ch = curl_init('https://proxykite.com/api/v1/proxies/7/ports');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'PUT',
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('HYP_TOKEN'),
        'Accept: application/json',
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => '{"mode":"split","socks5_port":30544}',
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
var_dump($status, json_decode($body, true));
```



**Response `200`**: the ports object as in [Get the ports](#get-the-ports).

`422 validation_failed` with `fields.http_port` / `fields.socks5_port` when a port is outside `range`, already used, or
both ports are the same; `fields.socks5_port` "No free port left on this cloud router" when the range is full.

## Pick a free port


`GET /proxies/{id}/ports/free`

**Ability:** `manage` · Returns one random free port of this proxy's cloud router (`null` when the range is full). It is not
reserved; use it in `PUT /proxies/{id}/ports` right away.



**curl**

```bash
curl 'https://proxykite.com/api/v1/proxies/7/ports/free' \
  -H "Authorization: Bearer $HYP_TOKEN" \
  -H 'Accept: application/json'
```


**Python**

```python
import os
import requests

r = requests.get(
    "https://proxykite.com/api/v1/proxies/7/ports/free",
    headers={"Authorization": f"Bearer {os.environ['HYP_TOKEN']}", "Accept": "application/json"},
    timeout=30,
)
print(r.status_code, r.json())
```


**Node.js**

```js
const res = await fetch('https://proxykite.com/api/v1/proxies/7/ports/free', {
  headers: {
    Authorization: `Bearer ${process.env.HYP_TOKEN}`,
    Accept: 'application/json',
  },
  signal: AbortSignal.timeout(30000),
});
console.log(res.status, await res.json());
```


**PHP**

```php
<?php
$ch = curl_init('https://proxykite.com/api/v1/proxies/7/ports/free');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('HYP_TOKEN'),
        'Accept: application/json',
    ],
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
var_dump($status, json_decode($body, true));
```



**Response `200`**

```json
{"data": {"port": 30544}}
```
