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
Parameterid Inpath Typestring (UUID) Requiredyes DescriptionServer ID. List: GET /v1/infra/servers

Request fields (body)

Field Type Required Description
Fieldmode Typestring Requiredyes DescriptionTarget 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

Terminal
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

Terminal
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

javascript
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

javascript
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
Fieldsuccess Typeboolean DescriptionAlways true on success
Fielddata.mode Typestring DescriptionNew mode — BLACKHOLE
Fielddata.ip Typestring | null DescriptionServer IP, unchanged by the switch
Fielddata.sshPassword Typestring | null DescriptionAlways 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:

JSON
{
  "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:

JSON
{
  "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
HTTP400 CodeINVALID_MODE Descriptionmode is not OPEN or BLACKHOLE
HTTP400 CodeSAME_MODE DescriptionThe server is already in BLACKHOLE mode
HTTP400 CodeNO_SUBDOMAIN DescriptionThe switch runs as commands over the server's tunnel, and the server has no subdomain. The state is permanent — a retry does not help
HTTP400 CodeMODE_SWITCH_STANDALONE_ONLY DescriptionMode switching is supported for standalone virtual machines only. A Galaxy application's mode cannot be switched
HTTP401 CodeMISSING_API_KEY DescriptionThe X-Api-Key header was not provided
HTTP401 CodeINVALID_API_KEY DescriptionThe key is not recognized — no such key exists on the platform
HTTP402 CodeACCOUNT_FROZEN DescriptionThe 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
HTTP403 CodeOPEN_MODE_DISABLED DescriptionA 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
HTTP403 CodeDIRECT_NETWORK_CHANGE_REQUIRES_HUMAN DescriptionA 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
HTTP403 CodeAUDIENCE_APPROVAL_FORBIDDEN DescriptionThe current key, its owner or portal binding no longer permits the operation
HTTP403 CodeWRITE_BLOCKED_READONLY_KEY DescriptionThe key is in read-only mode and cannot switch the mode
HTTP403 CodeINFRA_FORBIDDEN_FOR_COWORK_KEY DescriptionThe 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
HTTP403 CodeSERVER_ROLE_FORBIDDEN DescriptionYou 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 available to you. Role breakdown — List servers
HTTP404 CodeNOT_FOUND DescriptionThe server does not exist, was deleted, or belongs to another API key while you are not on its development team
HTTP409 CodeSERVER_NOT_RUNNING DescriptionThe server is not in the RUNNING status. Start or wake it first — a plain retry does not change the state
HTTP409 CodeAGENT_NOT_CONNECTED DescriptionThe switch runs as commands over the Black Hole agent's tunnel, and the agent is not in the CONNECTED status yet. Wait for the connection and retry
HTTP409 CodeCONFLICT DescriptionThe 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
HTTP429 CodeRATE_LIMITED DescriptionThe platform's overall request limit was exceeded
HTTP502 CodeIPTABLES_FAILED DescriptionThe firewall rules could not be applied or the SSH password could not be set on the server itself. The mode does not change
HTTP502 CodePROVIDER_NOT_CONFIGURED DescriptionThe 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
HTTP502 CodeGATEWAY_UNREACHABLE DescriptionThe 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
HTTP502 CodeTUNNEL_NOT_FOUND DescriptionThe tunnel to the server was not found — the Black Hole agent is not connected. Retry once the agent reconnects
HTTP503 CodeGATEWAY_TIMEOUT DescriptionThe 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
HTTP503 CodeSECURITY_GROUP_ATTACH_FAILED DescriptionThe 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 allowOpenMode policy.
  • The "Switch to OPEN" link is not always shown. It sits in the SSH block of the "Deploy" tab while the server is in running status and the Black Hole agent is CONNECTED. 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.
  • accessPolicy is 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, the accessPolicy value is preserved in the database — and starts taking effect again after returning to BLACKHOLE.

See also