## Delete a wake window

`DELETE /v1/infra/servers/:id/wake-schedules/:scheduleId`

Deletes one wake window of a server. A deleted window can't be restored through the API — create a new one if you need it back.

## Parameters

| Parameter | In | Type | Required | Description |
|-----------|----|------|:--------:|--------------|
| `id` | path | string (UUID) | yes | ID of the BLACKHOLE server |
| `scheduleId` | path | string | yes | Window ID, taken from `data[].id` in the [window list](./list.md) |

## Examples

### curl — personal key

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/infra/servers/SERVER_ID/wake-schedules/SCHEDULE_ID" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth app

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/infra/servers/SERVER_ID/wake-schedules/SCHEDULE_ID" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const res = await fetch(
  `https://vibecode.bitrix24.com/v1/infra/servers/${serverId}/wake-schedules/${scheduleId}`,
  { method: 'DELETE', headers: { 'X-Api-Key': 'YOUR_API_KEY' } }
)
const body = await res.json()
if (body.success) console.log('Window deleted')
```

### JavaScript — OAuth app

```javascript
const res = await fetch(
  `https://vibecode.bitrix24.com/v1/infra/servers/${serverId}/wake-schedules/${scheduleId}`,
  {
    method: 'DELETE',
    headers: {
      'X-Api-Key': 'YOUR_APP_KEY',
      'Authorization': 'Bearer USER_SESSION_TOKEN',
    },
  }
)
```

## Response fields

| Field | Type | Description |
|-------|------|--------------|
| `success` | boolean | `true` on a successful delete |

Unlike deleting CRM entity records, this endpoint responds `200` with the body `{ "success": true }`, not `204 No Content`.

## Response example

```json
{
  "success": true
}
```

## Error response example

404 — window not found:

```json
{
  "success": false,
  "error": {
    "code": "NOT_FOUND",
    "message": "Wake window not found"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|------|--------------|
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |
| 401 | `INVALID_API_KEY` | The API key is invalid or expired |
| 403 | `INFRA_SCOPE_REQUIRED` | The key lacks the `vibe:infra` scope |
| 404 | `NOT_FOUND` | The server was not found/deleted/belongs to a different API key, or no window with that `scheduleId` exists on this server |
| 429 | `RATE_LIMITED` | The 10-requests-per-minute limit for this endpoint was exceeded |

Full list of shared error codes — [Errors](/docs/errors).

## Known behavior

- **Works regardless of the feature's per-account status.** Unlike creating and updating, deleting an existing window is not gated by `WAKE_SCHEDULE_DISABLED` — so the server owner can remove a window even if scheduled wake was disabled for their Bitrix24 account after the window was created.
- **Doesn't check server mode or status.** Unlike creating and updating, deleting doesn't run the `BLACKHOLE_ONLY`/`GALAXY_NOT_SUPPORTED`/`ALWAYS_ON_CONFLICT` checks — a window can be deleted from a server in any mode, as long as the server has one.

## See also

- [List windows](./list.md)
- [Create a window](./create.md)
- [Update a window](./update.md)
