---
title: "Save a new version of a page's code"
description: "Never overwrites: every save is a new version, and the page points at the latest."
canonical: "https://gtable.app/docs/builder-api/pages/code-set"
updated: "2026-10-05"
---

# Save a new version of a page's code

`PUT https://studio.gtable.app/v1/apps/{appId}/pages/{pageId}/code`

Never overwrites: every save is a new version, and the page points at the latest.

A note says why, for the history. Send `baseVersion` (the page's `version` when you read it) to be refused with 409 if somebody saved since, instead of burying their version under yours.

Requires the `pages:write` scope. Operation `pages.code.set`. MCP tool `pages_code_set`. CLI, once published: `gtable pages code set`.

## Path parameters

| Name     | Type   | Required | Description |
| -------- | ------ | -------- | ----------- |
| `appId`  | string | yes      |             |
| `pageId` | string | yes      |             |

## Headers

| Name              | Type   | Required | Description                                                                                                                                                                                                                                                        |
| ----------------- | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `Idempotency-Key` | string | no       | Any unique string. Sending the same key with the same request again returns the first response (marked `Idempotency-Replayed: true`) instead of running it twice. Reusing it for a different request is refused with 409. Kept for 24 hours. Up to 255 characters. |

## Request body

| Field         | Type                                        | Required | Description              |
| ------------- | ------------------------------------------- | -------- | ------------------------ |
| `source`      | string                                      | yes      | Up to 400000 characters. |
| `note`        | string                                      | no       | Up to 200 characters.    |
| `via`         | "assistant" or "hand" or "api" or "restore" | no       |                          |
| `baseVersion` | integer                                     | no       | At least 0.              |
