For AI agents: markdown of this page — /docs-content-en/infra/lifecycle/sleep.md documentation index — /llms.txt

Configure auto-sleep

PATCH /v1/infra/servers/:id/sleep

Configures the stored automatic sleep timer of a BLACKHOLE server. If no inbound HTTP requests reach the application for the effective timeout, the server stops automatically. It can be brought back up by a /wake call, though a request to the HTTPS subdomain does not always wake the server — see that page for the conditions. Passing null stores the “Never” setting and enables guaranteed always-on mode. The sleep endpoint rejects null while wake-schedule windows are enabled; schedule creation and update are rejected whenever null is stored, even for a disabled window. If an older record already contains null plus an effective schedule, the effective timeout changes between windows — see below.

Without an effective schedule, null disables idle auto-sleep. Setting null while enabled windows exist is rejected as an always-on conflict. In the other direction, creating or updating any window while null is stored is rejected, even when that window is disabled. If an older record already contains null plus an enabled and entitled schedule with a next wake, the platform applies its post-window timeout — 15 minutes of inactivity by default. An explicit numeric value (15, 30, 60, or 240) remains compatible with a schedule and always takes priority over that fallback.

For a continuous 24/7 workload, store null and leave no effective wake schedule. See Provider plans for the available plans and their characteristics.

Parameters

Parameter In Type Required Description
id path string (UUID) yes ID of a server in BLACKHOLE mode

Request fields (body)

Field Type Required Description
sleepAfterMinutes number | null yes Stored idle timeout in minutes. Allowed values: 15, 30, 60, 240, or null (“Never”; setting it is rejected with enabled wake windows, and storing it blocks every schedule create/update, including a disabled window; an older effective conflicting record uses the platform's post-window timeout). Other values are rejected with VALIDATION_ERROR

Examples

curl — personal key

Terminal
# Enable auto-sleep after 60 minutes of inactivity
curl -X PATCH https://vibecode.bitrix24.com/v1/infra/servers/SERVER_ID/sleep \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"sleepAfterMinutes": 60}'

# Disable auto-sleep
curl -X PATCH https://vibecode.bitrix24.com/v1/infra/servers/SERVER_ID/sleep \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"sleepAfterMinutes": null}'

curl — OAuth application

Terminal
curl -X PATCH https://vibecode.bitrix24.com/v1/infra/servers/SERVER_ID/sleep \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"sleepAfterMinutes": 60}'

JavaScript — personal key

javascript
const res = await fetch(
  `https://vibecode.bitrix24.com/v1/infra/servers/${serverId}/sleep`,
  {
    method: 'PATCH',
    headers: {
      'X-Api-Key': 'YOUR_API_KEY',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ sleepAfterMinutes: 60 }),
  }
)
const { data } = await res.json()
console.log(`Auto-sleep after ${data.sleepAfterMinutes} min`)

JavaScript — OAuth application

javascript
await fetch(
  `https://vibecode.bitrix24.com/v1/infra/servers/${serverId}/sleep`,
  {
    method: 'PATCH',
    headers: {
      'X-Api-Key': 'YOUR_APP_KEY',
      'Authorization': 'Bearer USER_SESSION_TOKEN',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ sleepAfterMinutes: null }),
  }
)

Response fields

Field Type Description
success boolean Always true on success
data.sleepAfterMinutes number | null The current timeout value (echo of what was passed)

Response example

JSON
{
  "success": true,
  "data": {
    "sleepAfterMinutes": 60
  }
}

Error response example

400 — invalid sleepAfterMinutes value:

JSON
{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "sleepAfterMinutes must be 15, 30, 60, 240, or null"
  }
}

400 — the server is not in BLACKHOLE mode:

JSON
{
  "success": false,
  "error": {
    "code": "BLACKHOLE_ONLY",
    "message": "Sleep settings are only available for BLACKHOLE servers"
  }
}

400 — attempting to enable guaranteed always-on mode while wake-schedule windows are enabled:

JSON
{
  "success": false,
  "error": {
    "code": "ALWAYS_ON_CONFLICT",
    "message": "The server has enabled wake-schedule windows, which conflict with always-on (24/7) mode. Delete or disable the wake windows first, or keep a sleep timeout."
  }
}

Errors

HTTP Code Description
400 VALIDATION_ERROR sleepAfterMinutes is not in the list [15, 30, 60, 240, null]
400 GALAXY_APP_USE_GALAXY_ROUTE The server is a Galaxy app. It sleeps together with its host, and its idle timer is not set through the Vibecode API. For what applies to an app, see the Galaxy app page
400 BLACKHOLE_ONLY The server is in OPEN mode — auto-sleep is not available
400 ALWAYS_ON_CONFLICT Attempting to use null as always-on mode while wake-schedule windows are enabled — delete or disable the windows first. Creating or updating any window while null is stored is rejected as well, even when the submitted window is disabled
400 AGENT_IDLE_SLEEP_FORBIDDEN The server was created for an agent or bot (createdVia agent/bot) — a numeric sleepAfterMinutes is forbidden; only null is accepted. Schedule creation and update are rejected while that value is stored, even for a disabled window
401 MISSING_API_KEY The X-Api-Key header was not provided
401 INVALID_API_KEY Invalid or expired API key
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
429 RATE_LIMITED The platform's overall request limit was exceeded

The full list of common API errors — Errors.

Known specifics

  • What counts as activity and resets the timer. Inbound HTTP requests that reach the application through the tunnel reset the timer. Actual activity is checked every few minutes through Gateway metrics, and the moment of the last request is exposed as lastRequestAt by GET /v1/infra/servers/:id/metrics. Outbound requests that the application itself makes do not count as activity, so an application built around continuously polling an external API does not keep its own machine online — after the effective timeout the machine stops, and the application with it. Delete or disable enabled wake windows before setting null to prevent that idle sleep. If an older record already contains null plus an effective schedule, the platform's post-window timeout still applies.
  • Auto-wake is preserved. A server put to sleep by the timer wakes on a call to /deploy//wake//start, and a request to the HTTPS subdomain wakes it under the automatic wake conditions.
  • The default value for new servers is 60 minutes. The current value is returned by GET /v1/infra/servers/:id.
  • Agent and managed-bot servers do not normally idle-sleep. This covers machines the platform creates itself for an AI agent or a managed bot — in the GET /v1/infra/servers/:id response their createdVia field is agent or bot. They are created with sleepAfterMinutes: null because a sleeping bot stops polling Bitrix24, will not wake on a new message, and interrupts any task in progress. A numeric sleepAfterMinutes request for such a server is rejected with 400 AGENT_IDLE_SLEEP_FORBIDDEN; null is the only stored value, and schedule creation or update is rejected while it is stored, even for a disabled window. If an older record already contains null plus an effective schedule, the platform's post-window timeout applies and null no longer means around-the-clock operation. A machine created through POST /v1/infra/servers has createdVia: api and is not covered by the numeric-timeout restriction.
  • ALWAYS_ON_CONFLICT protects guaranteed always-on mode. Current writes enforce the conflict in two directions: setting null while wake-schedule windows are enabled is rejected, and creating or updating any window while null is stored is rejected even when that window is disabled. Existing older records are not rewritten: if one already contains both settings, an effective schedule activates the platform's post-window timeout. Delete or disable the windows first, or keep a numeric timeout.
  • The endpoint does not change the status — it only updates the configuration. To put the server to sleep immediately, use POST /sleep-now.

See also