---
title: "Write a version's text."
method: PATCH
path: "/scripts/{scriptUploadId}/content"
tags: ["Scripts"]
---

# Write a version's text.

`PATCH /scripts/{scriptUploadId}/content`

## Request

- Base URL: `https://docs.sleeperhit.studio/api/v1`
- URL: `https://docs.sleeperhit.studio/api/v1/scripts/{scriptUploadId}/content`
- Auth: HTTP bearer

The Writers Lab's editor save, through its core: the version's whole screenplay text. A draft is written as the draft editor writes it; a locked version as the version editor does. With `expectedContent` it is a compare-and-swap: the write lands only if the version still holds exactly that text, else 409 `script_state_invalid` — read it again and write over what is there. A version a season run wrote is not edited here (409). Free and naturally idempotent, so no `Idempotency-Key`.

## Request body

- ScriptContentWriteRequest
  - `content` string, required: The whole screenplay text the version should now hold.
  - `expectedContent` string: The text you last read: the write lands only if the version still holds exactly this.

## Response `200`

Written.

- ScriptContentWriteResponse
  - `scriptUploadId` string, required
  - `status` string, required: `draft`, or the locked version's status.
  - `wordCount` integer, required
  - `pageCount` integer, nullable, required

## Other responses

- `400`: Request payload failed validation. The error message names the offending field.
- `401`: Missing, malformed, revoked, or expired API key.
- `403`: API key is valid but lacks the scope, is blocked by IP allowlist, or the account is disabled.
- `404`: The named project or source does not exist or is owned by another account.
- `409`: The version moved on since you read it, or a season run wrote it (`script_state_invalid`).
- `429`: Rate limit for this API key + IP + route family was exceeded.
- `500`: The API failed unexpectedly. Safe to retry with the same Idempotency-Key.

---

[API](https://skmtc.dev/sleeperhit/apis/sleeper-hit-studio-story-api.md) · [All operations](https://skmtc.dev/sleeperhit/apis/sleeper-hit-studio-story-api/llms.txt) · [OpenAPI document](https://skmtc.dev/sleeperhit/apis/sleeper-hit-studio-story-api/revisions/4534f5d25540?raw)
