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 a server from OPEN mode back to the protected BLACKHOLE mode: the firewall is restored and the SSH password is deleted. A server cannot be switched to OPEN through the API; a person does that in the Vibecode dashboard.
A request with mode: "OPEN" is refused before any action on the server or its network. While OPEN mode is disabled platform-wide, the response is 403 OPEN_MODE_DISABLED, and nobody can switch a server to OPEN at that time, including from the dashboard. When the mode is enabled platform-wide, the response is 403 DIRECT_NETWORK_CHANGE_REQUIRES_HUMAN with a link to the server card in the dashboard.
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 | Required | Description |
|---|---|---|---|---|
id |
path | string (UUID) | yes | Server ID |
Request fields (body)
| Field | Type | Required | Description |
|---|---|---|---|
mode |
string | yes | Target mode. Through the API, a server can be switched only to BLACKHOLE. The value OPEN passes format validation, but the request is refused with code 403 — see the errors table below |
Examples
curl — personal key
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": "BLACKHOLE"}'
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: 'BLACKHOLE' }),
}
)
const { data } = await res.json()
console.log(`Server mode: ${data.mode}`)
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 — BLACKHOLE |
data.ip |
string | null | Server IP, unchanged by the switch |
data.sshPassword |
string | null | Always null from this endpoint: an SSH password is issued only when switching to OPEN, and that switch is not available through the API |
Response example
OPEN → BLACKHOLE switch:
{
"success": true,
"data": {
"mode": "BLACKHOLE",
"ip": "178.154.230.106",
"sshPassword": null
}
}
Error response example
403 — a request to switch to OPEN while the mode is enabled platform-wide:
{
"success": false,
"error": {
"code": "DIRECT_NETWORK_CHANGE_REQUIRES_HUMAN",
"message": "Opening direct network access requires a current human cabinet session",
"details": {
"settingsUrl": "https://vibecode.bitrix24.com/servers/3f2b9c1e-7a4d-4e8b-9c5f-1d2e3a4b5c6d"
}
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| 400 | INVALID_MODE |
mode is not OPEN or BLACKHOLE |
| 400 | SAME_MODE |
The server is already in BLACKHOLE 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 |
The key is not recognized — no such key exists on the platform |
| 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 |
A request with mode: "OPEN" while OPEN mode is disabled platform-wide. Nobody can switch a server to OPEN at that time, including from the dashboard. The response carries error.userMessage — ready-made text in the key owner's language |
| 403 | DIRECT_NETWORK_CHANGE_REQUIRES_HUMAN |
A request with mode: "OPEN" while the mode is enabled platform-wide. The API does not switch a server to OPEN: a person performs the switch in the dashboard — the "Black Hole Servers" section, the "Deploy" link on the server card, then the "Switch to OPEN" link in the SSH block. The address in error.details.settingsUrl opens the server card straight on the "Deploy" tab. A retry returns the same refusal |
| 403 | AUDIENCE_APPROVAL_FORBIDDEN |
The current key, its owner or portal binding no longer permits the operation |
| 403 | WRITE_BLOCKED_READONLY_KEY |
The key is in read-only mode and cannot switch the mode |
| 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, but this operation requires 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 | CONFLICT |
The code covers two cases: 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 other 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
- In the dashboard, switching to OPEN goes through three checks. OPEN mode is enabled platform-wide, the Bitrix24 account is on a commercial plan, and the account allows OPEN through the
allowOpenModepolicy. - The "Switch to OPEN" link is not always shown. It sits in the SSH block of the "Deploy" tab while the server is in
runningstatus and the Black Hole agent isCONNECTED. While OPEN mode is disabled platform-wide, the link is absent and the block shows an explanation instead. - 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. The close command travels over the same connection that was lost, so it does not reach a fully unreachable server 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. - The tunnel (
blackholeStatus) is preserved in OPEN mode. The Black Hole agent keeps running, the HTTPS subdomain stays operational, and the firewall 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.