For AI agents: markdown of this page — /docs-content-en/infra/access/mode.md documentation index — /llms.txt
Switch mode
PATCH /v1/infra/servers/:id/mode
Switches the server between BLACKHOLE mode (everything closed behind the firewall, access only via the HTTPS subdomain) and OPEN mode (direct access by IP, SSH on port 22 open). When switching to OPEN, the firewall is fully removed and an SSH password is generated. When switching back, the firewall is restored and the password is deleted. Switching to OPEN is forbidden if the platform (the openModeEnabled flag) or the Bitrix24 account (the allowOpenMode policy) does not permit it, or if the server's role requires a sealed network policy.
OPEN disables Black Hole protection. The server becomes reachable from the internet by IP. All Deploy API endpoints (
/exec,/upload,/logs,/deploy) work only in BLACKHOLE mode — in OPEN they return an error.
Parameters
| Parameter | In | Type | Req. | Description |
|---|---|---|---|---|
id |
path | string (UUID) | yes | Server ID |
Request fields (body)
| Field | Type | Req. | Description |
|---|---|---|---|
mode |
string | yes | Target mode: OPEN or BLACKHOLE |
Examples
curl — personal key
# BLACKHOLE → OPEN
curl -X PATCH https://vibecode.bitrix24.com/v1/infra/servers/SERVER_ID/mode \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"mode": "OPEN"}'
# OPEN → BLACKHOLE (restore protection)
curl -X PATCH https://vibecode.bitrix24.com/v1/infra/servers/SERVER_ID/mode \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"mode": "BLACKHOLE"}'
curl — OAuth application
curl -X PATCH https://vibecode.bitrix24.com/v1/infra/servers/SERVER_ID/mode \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{"mode": "OPEN"}'
JavaScript — personal key
const res = await fetch(
`https://vibecode.bitrix24.com/v1/infra/servers/${serverId}/mode`,
{
method: 'PATCH',
headers: {
'X-Api-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({ mode: 'OPEN' }),
}
)
const { data } = await res.json()
if (data.sshPassword) console.log(`New SSH password: ${data.sshPassword}`)
JavaScript — OAuth application
await fetch(
`https://vibecode.bitrix24.com/v1/infra/servers/${serverId}/mode`,
{
method: 'PATCH',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({ mode: 'BLACKHOLE' }),
}
)
Response fields
| Field | Type | Description |
|---|---|---|
success |
boolean | Always true on success |
data.mode |
string | New mode (OPEN or BLACKHOLE) |
data.ip |
string | null | Server IP (does not change when the mode is switched) |
data.sshPassword |
string | null | Generated SSH password. Returned only when switching to OPEN. When switching to BLACKHOLE — null |
Response example
BLACKHOLE → OPEN switch:
{
"success": true,
"data": {
"mode": "OPEN",
"ip": "178.154.230.106",
"sshPassword": "rT9xQ2mKaPzFHyB3"
}
}
OPEN → BLACKHOLE switch:
{
"success": true,
"data": {
"mode": "BLACKHOLE",
"ip": "178.154.230.106",
"sshPassword": null
}
}
Error response example
403 — switching to OPEN is forbidden by the Bitrix24 account policy:
{
"success": false,
"error": {
"code": "OPEN_MODE_NOT_ALLOWED",
"message": "OPEN mode is not allowed by portal policy",
"userMessage": "OPEN mode is not allowed by Bitrix24 account policy. An admin enables it in Settings → Creation. Meanwhile, use the Deploy API (exec/upload/logs)."
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| 400 | INVALID_MODE |
mode is not OPEN or BLACKHOLE |
| 400 | SAME_MODE |
The server is already in the requested mode |
| 400 | NO_SUBDOMAIN |
The server has no subdomain, while the switch runs as commands over its tunnel. The state is permanent — a retry does not help |
| 400 | MODE_SWITCH_STANDALONE_ONLY |
Mode switching is supported for standalone virtual machines only. A Galaxy application's mode cannot be switched |
| 401 | MISSING_API_KEY |
The X-Api-Key header was not provided |
| 401 | INVALID_API_KEY |
Invalid or expired API key |
| 402 | OPEN_MODE_REQUIRES_COMMERCIAL |
OPEN mode requires a commercial Bitrix24 plan. The response carries error.userMessage, the upgrade link in error.details.upgradeUrl and error.hint. After the upgrade the gate clears on its own; to force it, call GET /v1/me?refresh=tariff |
| 402 | ACCOUNT_FROZEN |
The account balance is exhausted. The refusal arrives before the mode value is validated and before the server is looked up, so on a frozen account the endpoint answers neither 400 nor 404 |
| 403 | OPEN_MODE_DISABLED |
OPEN mode is disabled on the platform (the openModeEnabled flag). Contact the platform administrator. The response carries error.userMessage — ready-made text in the user's language |
| 403 | OPEN_MODE_NOT_ALLOWED |
OPEN mode is forbidden by the portal policy (the allowOpenMode flag). Contact the portal administrator. The response carries error.userMessage. The exception is the second branch of the same code, with the message Portal context required — it arrives without userMessage |
| 403 | INFRA_FORBIDDEN_FOR_COWORK_KEY |
The call was made with a Cowork/Code key — such a key works with data only and cannot perform write operations. To issue a key that can, see Project key for deploy |
| 403 | SERVER_ROLE_FORBIDDEN |
You are on this server's development team with the Developer role, and this operation is open to the Administrator role. error.hint carries your role, the required threshold and the list of calls that are open to you. Role breakdown — List servers |
| 404 | NOT_FOUND |
The server does not exist, was deleted, or belongs to another API key while you are not on its development team |
| 409 | SERVER_NOT_RUNNING |
The server is not in the RUNNING status. Start or wake it first — a plain retry does not change the state |
| 409 | AGENT_NOT_CONNECTED |
The Black Hole agent is not in the CONNECTED status yet, while the switch runs as commands over its tunnel. Wait for the connection and retry |
| 409 | MODE_SWITCH_SEALED_ROLE |
The server's role — a pool member, a service machine — requires a sealed network policy, so OPEN mode is unavailable to it. The mode does not change, no password is issued, and a retry returns the same refusal |
| 409 | CONFLICT |
Two branches of one code: another operation is already running on the server and holds its lock, or a parallel request changed the mode while this one was running. In both cases, retry after the neighbouring operation finishes |
| 429 | RATE_LIMITED |
The platform's overall request limit was exceeded |
| 502 | IPTABLES_FAILED |
The firewall rules could not be applied or the SSH password could not be set on the server itself. The mode does not change |
| 502 | PROVIDER_NOT_CONFIGURED |
The cloud access that switches the outer network-policy layer was not found for this server. The mode does not change, and the state is permanent — a retry does not help |
| 502 | GATEWAY_UNREACHABLE |
The tunnel to the server does not answer: the platform could not reach it. The code carries the underlying cause after the colon. The mode does not change, and a retry makes sense |
| 502 | TUNNEL_NOT_FOUND |
The tunnel to the server was not found — the Black Hole agent is not connected. Retry once the agent reconnects |
| 503 | GATEWAY_TIMEOUT |
The agent did not answer within the allotted time. The code starts with GATEWAY_TIMEOUT and carries the timeout. The switch may have applied partially — check the server state before retrying |
| 503 | SECURITY_GROUP_ATTACH_FAILED |
The network policy could not be switched on the outer layer. The mode does not change, and retrying the request makes sense |
The full list of common API errors — Errors.
Known specifics
- OPEN resolution order (both levels must allow it): first the platform flag
openModeEnabled— not even the platform admin bypasses this check. Then the Bitrix24 account policyallowOpenMode— the platform admin bypasses it. Switching to OPEN is possible only if both allow it. - The IP does not change when the mode is switched. The cloud virtual machine stays the same — only the network policy and the SSH configuration change.
- The network policy is held by two layers. The inner one is the iptables rules on the machine itself; the outer one sits outside it and cannot be lifted from within. A mode switch changes both, the outer layer first. Where the outer layer is not supported for a server, only the inner one applies and the endpoint behaves as before.
- A connection loss mid-switch closes the firewall again. If the connection to the server is lost after the outer layer was switched, the platform closes the machine's firewall and restores the outer layer to its previous role, and only then returns the error. That closing travels over the same connection that was lost, so on a fully unreachable server it does not arrive either.
- A failed mode write after the server was closed does not reopen the firewall. The machine stays closed on both layers while the server record still reads
OPEN. A retry withmode: "OPEN"returns400 SAME_MODE. Access comes back by switching toBLACKHOLEand then toOPENagain. - The tunnel (
blackholeStatus) is preserved in OPEN mode. The Black Hole agent keeps running, the HTTPS subdomain stays operational — the firewall simply no longer blocks external traffic. However, the Deploy API still refuses the call: it requires BLACKHOLE specifically. accessPolicyis not applied in OPEN. In OPEN, protection is built on SSH keys and iptables (which is removed); the HTTPS subdomain policy effectively does not work. When the mode is switched, theaccessPolicyvalue is preserved in the database — and starts taking effect again after returning to BLACKHOLE.