---
title: "Save and test warm hook"
method: POST
path: "/v1/environments/{environment_id}/warm-hooks/save-test"
tags: ["Hooks"]
---

# Save and test warm hook

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

## Request

- Base URL: `https://api.replicas.dev`
- URL: `https://api.replicas.dev/v1/environments/{environment_id}/warm-hooks/save-test`
- Auth: HTTP bearer

Runs the script in a new sandbox and activates it only if it passes. Takes 30–90 seconds.

## Path parameters

- `environment_id` string, required

## Headers

- `X-Replicas-Api-Version` '2026-10-07'

## 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.dev/replicas/apis/replicas-api.md) - [All operations](https://skmtc.dev/replicas/apis/replicas-api/llms.txt) - [OpenAPI document](https://skmtc.dev/replicas/apis/replicas-api/revisions/2703ac1c9cb7?raw)
