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. This endpoint rejects null while wake-schedule windows are enabled, unless the server is in the SCHEDULE run mode. Creating or updating a schedule is rejected whenever null is stored, even for a disabled window, except for an app in a galaxy and a server in the SCHEDULE run mode. 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, unless the server is in the SCHEDULE run mode. In the other direction, creating or updating any window while null is stored is rejected, even when that window is disabled, except for an app in a galaxy and a server in the SCHEDULE run mode. 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.
A server with idleSleepProtected: true must stay reachable, so a numeric threshold is refused with 400 AGENT_IDLE_SLEEP_FORBIDDEN. This is an agent or bot server, or an ordinary application with an enabled fetch bot. null and the scheduled run mode remain available.
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 |
|---|---|---|---|---|
Parameterid |
Inpath | Typestring (UUID) | Requiredyes | DescriptionID of a server in BLACKHOLE mode. List: GET /v1/infra/servers |
Request fields (body)
| Field | Type | Required | Description |
|---|---|---|---|
FieldsleepAfterMinutes |
Typenumber | null | Requiredyes | DescriptionStored idle timeout in minutes. Allowed values: 15, 30, 60, 240, or null (“Never”). Setting null is rejected while enabled wake windows exist, unless the server is in the SCHEDULE run mode. While null is stored, every schedule create or update is rejected, even for a disabled window, except for an app in a galaxy and a server in the SCHEDULE run mode. An older record that already combines null with an effective schedule uses the platform's post-window timeout. Other values are rejected with VALIDATION_ERROR |
Examples
curl — personal key
# 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
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
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
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 |
|---|---|---|
Fieldsuccess |
Typeboolean | DescriptionAlways true on success |
Fielddata.sleepAfterMinutes |
Typenumber | null | DescriptionThe current timeout value (echo of what was passed) |
Fielddata.workScheduleCleared |
Typeboolean | Descriptiontrue when this write removed a work schedule that was assigned to the server |
Response example
{
"success": true,
"data": {
"sleepAfterMinutes": 60,
"workScheduleCleared": false
}
}
Error response example
400 — attempting to enable guaranteed always-on mode (null) while wake-schedule windows are enabled, if the server is not in the SCHEDULE run mode:
{
"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 |
|---|---|---|
| HTTP400 | CodeVALIDATION_ERROR |
DescriptionsleepAfterMinutes is not in the list [15, 30, 60, 240, null] |
| HTTP400 | CodeGALAXY_APP_USE_GALAXY_ROUTE |
DescriptionThe 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 |
| HTTP400 | CodeBLACKHOLE_ONLY |
DescriptionThe server is in OPEN mode — auto-sleep is not available |
| HTTP400 | CodeALWAYS_ON_CONFLICT |
DescriptionAttempting 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, except for an app in a galaxy. A server in the SCHEDULE run mode does not get this code: its sleep is declared by the schedule |
| HTTP400 | CodeAGENT_IDLE_SLEEP_FORBIDDEN |
DescriptionThe server has idleSleepProtected: true, so numeric sleepAfterMinutes is forbidden. This is an agent or bot server, or an ordinary application with an enabled fetch bot. null is accepted and savings on a schedule remain available through the run mode |
| 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 |
| 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 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 |
| HTTP404 | CodeNOT_FOUND |
DescriptionThe server does not exist, was deleted, or belongs to another API key while you are not on its development team |
| HTTP429 | CodeRATE_LIMITED |
DescriptionThe 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
lastRequestAtbyGET /v1/infra/servers/:id/metrics. Outbound requests made by the application do not count as activity. The platform separately protects an application with an enabled fetch bot: it hasidleSleepProtected: true, a numeric threshold is unavailable, and outbound polling does not have to imitate inbound traffic. For other applications, outbound polling does not keep the machine online.nulldisables this sleep only without an effective wake schedule. - 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 servers, managed-bot servers, and applications with an enabled fetch bot do not idle-sleep without a schedule. Machines created by the platform for an AI agent or managed bot have
createdViaset toagentorbot. An ordinary server or Galaxy application has the same protection while an enabled fetch bot is associated with it. In every caseGET /v1/infra/servers/:idreturnsidleSleepProtected: true, and a numericsleepAfterMinutesrequest is rejected with400 AGENT_IDLE_SLEEP_FORBIDDEN. An ordinary application's previously stored threshold is kept and takes effect again after its last fetch bot is disabled. A schedule remains available and outranks protection. A webhook Bot alone does not enable protection. ALWAYS_ON_CONFLICTprotects guaranteed always-on mode. Current writes enforce the conflict in two directions: settingnullwhile wake-schedule windows are enabled is rejected, and creating or updating any window whilenullis stored is rejected even when that window is disabled. There are two exceptions: an app in a galaxy — it does not choose its plan but inherits it from the galaxy — and a server in theSCHEDULErun mode: its sleep is declared by the schedule. Neither is refused becausenullis stored. Deleting a window is allowed. 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.- Writing the timeout clears an assigned work schedule. A schedule outranks the timeout: while one is assigned the server runs during its windows, and the stored number would not affect its behavior at all. So the request means what it says — a number moves the server to "sleeps when idle",
nullto "around the clock", and either one drops the schedule together with the wake windows it generated.data.workScheduleClearedtells you it happened. Windows created by hand are untouched. The server's current mode is shown in therunModeandworkSchedulefields ofGET /v1/infra/servers/:id. - The endpoint does not change the status — it only updates the configuration. To put the server to sleep immediately, use
POST /sleep-now.