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. How it interacts with wake-schedule windows is described below.
null disables idle auto-sleep. The .com plans are non-preemptible, so a dedicated machine with null outside the SCHEDULE run mode does not idle-sleep, even with previously stored windows. In the SCHEDULE run mode, the assigned work schedule determines sleep. Creating or updating wake windows normally requires an explicit numeric value (15, 30, 60, or 240).
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: the .com plans are non-preemptible, and writing null also removes an assigned work 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. null means “Never”. Setting null while enabled wake windows exist is rejected as a settings conflict, unless the server is in the SCHEDULE run mode. 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 “Runs around the clock” 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 set null while wake-schedule windows are enabled — delete or disable the windows first. 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 schedule-based savings 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 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 is bound to another API key and 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. - 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 only the “Runs around the clock” mode. The rules are asymmetric: settingsleepAfterMinutes: nullwhile wake-schedule windows are enabled is rejected, and creating or updating any window whilenullis stored is rejected even withenabled: false. The window-write gate excludes an app in a galaxy, which inherits the galaxy's plan, and a server in theSCHEDULErun mode. When writingnull, the exception applies to theSCHEDULErun mode. Deleting a window is allowed. Previously stored windows do not enable idle auto-sleep for a dedicated machine withnulloutside theSCHEDULErun mode. Before switching to “Never”, delete or disable the enabled windows, 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 there are no requests",
nullto "Runs 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.