---
title: "Keep the project always on (paid plans), let it sleep when idle, or follow the plan; always_on wakes a sleeping project"
method: PUT
path: "/projects/{projectId}/sleep"
tags: ["Projects"]
---

# Keep the project always on (paid plans), let it sleep when idle, or follow the plan; always_on wakes a sleeping project

`PUT /projects/{projectId}/sleep`

## Request

- Base URL: `https://hostingsurge.com/api/v1`
- URL: `https://hostingsurge.com/api/v1/projects/{projectId}/sleep`
- Auth: one of:
  - HTTP bearer
  - API key in cookie `__Host-hs_session`

## Path parameters

- `projectId` string, uuid, required

## Request body

- object
  - `preference` 'plan' | 'always_on' | 'when_idle', required: plan: follow the plan; always_on: never sleep (paid plans); when_idle: sleep when idle

## Response `200`

Updated

- object
  - `projectId` string, uuid, required
  - `available` boolean, required
  - `state` 'awake' | 'sleeping' | 'waking', required
  - `preference` 'plan' | 'always_on' | 'when_idle', required
  - `sleepsAfterHours` integer, nullable, required
  - `canKeepAlwaysOn` boolean, required
  - `supported` boolean, required
  - `reason` 'recent_activity' | 'always_on' | 'plan_never' | 'static' | 'cron_jobs' | 'webhooks' | 'busy' | 'service' | 'backup_pending' | 'deploying' | 'not_ready' | 'unsupported' | 'sleep_off' | 'idle' | 'stop_failed' | 'no_visits' | 'no_metrics' | 'wildcard_domain' | 'null', nullable, required
  - `sleptAt` string, nullable, required: ISO-8601 timestamp
  - `wokenAt` string, nullable, required: ISO-8601 timestamp
  - `lastWakeMs` integer, nullable, required

## Other responses

- `400`: Invalid request (code invalid_request)
- `401`: Missing or invalid session/token (code unauthorized)
- `402`: Keep always on is part of the paid plans (code upgrade_required)
- `403`: Authenticated but not permitted (code forbidden)
- `404`: Not found or not visible to the caller (code not_found)

---

[API](https://skmtc.dev/hostingsurge/apis/hostingsurge-platform-api.md) · [All operations](https://skmtc.dev/hostingsurge/apis/hostingsurge-platform-api/llms.txt) · [OpenAPI document](https://skmtc.dev/hostingsurge/apis/hostingsurge-platform-api/revisions/4d08337cdff1?raw)
