---
title: "Save code changes as one version (0 Build Credits): committed, previewed, then checked (TypeScript and the dev server)"
method: PUT
path: "/builder/sessions/{sessionId}/code"
tags: ["Builder"]
---

# Save code changes as one version (0 Build Credits): committed, previewed, then checked (TypeScript and the dev server)

`PUT /builder/sessions/{sessionId}/code`

## Request

- Base URL: `https://hostingsurge.com/api/v1`
- URL: `https://hostingsurge.com/api/v1/builder/sessions/{sessionId}/code`
- Auth: one of:
  - HTTP bearer
  - API key in cookie `__Host-hs_session`

## Path parameters

- `sessionId` string, uuid, required

## Request body

- object
  - `baseVersion` integer, required: The version the editor loaded; 409 conflict (reason stale) when the site changed since
  - `changes` object[], required
    - `path` string, required
    - `content` string, nullable, required: The new content; null deletes the file
  - `message` string: What changed, in a few words (the version's title and the commit message)

## Response `200`

Saved

- object
  - `version` integer, required
  - `turnId` string, uuid, required
  - `commitSha` string, nullable, required
  - `changedFiles` object[], required
    - `path` string, required
    - `change` 'added' | 'modified' | 'deleted', required
  - `check` object, required
    - `state` 'ok' | 'problems' | 'checking' | 'unavailable', required: checking: the preview is still starting (ask again)
    - `problems` object[], required
      - `path` string, nullable, required
      - `line` integer, nullable, required
      - `column` integer, nullable, required
      - `message` string, required
      - `source` 'typescript' | 'vite' | 'preview', required

## Other responses

- `400`: Invalid request (code invalid_request)
- `401`: Missing or invalid session/token (code unauthorized)
- `402`: Code editing and GitHub sync need a paid plan (code upgrade_required, details.feature builder.github_export), or a limit was reached
- `403`: Authenticated but not permitted (code forbidden)
- `404`: Not found or not visible to the caller (code not_found)
- `409`: A change is running, the editor is stale (details.reason stale), a secret is in the code (secret_detected), or the draft is closed
- `501`: Not available on this server (code not_configured)

---

[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)
