---
title: "Save and Test Warm Hook"
method: POST
path: "/v1/environments/{environmentId}/warm-hooks/save-test"
tags: ["Environments"]
---

# Save and Test Warm Hook

`POST /v1/environments/{environmentId}/warm-hooks/save-test`

Saves the supplied script as the active warm hook for the environment and runs it in an isolated sandbox. Always persists the new version; the response includes the test result so callers can decide whether to roll back. The endpoint takes 30–90 seconds to return because it spins up a real sandbox.

## Path parameters

- `environmentId` string, required

## Request body

- SaveAndTestWarmHookRequest
  - `content` string, required — Shell script to save and execute

## Response `201`

Warm hook saved (test result included in body)

- SaveAndTestWarmHookResponse
  - `warm_hook` WarmHookRecord, required — A warm hook — the shell script that runs while pre-warming workspaces for an environment.
    - `id` string, uuid, required
    - `organization_id` string, uuid, required
    - `environment_id` string, uuid, required
    - `version` integer, required — Monotonic version (newer scripts have higher versions)
    - `content` string, required — Shell script content
    - `is_active` boolean, required — Whether this version is the active one for the environment
    - `created_at` string, date-time, required
  - `test` WarmHookTestResult, required — Result of running a warm hook script in an isolated sandbox.
    - `exit_code` integer, required — Process exit code (0 = success)
    - `output` string, required — Captured stdout + stderr
    - `timed_out` boolean, required — Whether execution was killed for taking too long

## Other responses

- `400` — Bad request - Missing or invalid parameters
- `401` — Unauthorized - Invalid or missing API key
- `500` — Internal server error

---

[API](https://skmtc.net/tryreplicas/apis/replica-api.md) · [All operations](https://skmtc.net/tryreplicas/apis/replica-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/tryreplicas/replica-api/versions/aa3b4c932f7a/schema)
