Skip to main content
POST
/
v2
/
sandcastles
/
{id}
/
library
/
changes
Create Library Change (writeback)
curl --request POST \
  --url https://app.textql.com/v2/sandcastles/{id}/library/changes \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "title": "<string>",
  "description": "<string>",
  "draft": false,
  "change_number": 123
}
'
{
  "change_id": "<string>",
  "change_number": 123,
  "git_ref": "<string>",
  "has_conflicts": true,
  "conflicts": "<string>",
  "auto_approved": true,
  "diffs": [
    {
      "name": "<string>",
      "old_path": "<string>",
      "new_path": "<string>",
      "additions": 123,
      "deletions": 123,
      "is_new": true,
      "is_delete": true,
      "is_rename": true,
      "is_binary": true
    }
  ],
  "raw_diff": "<string>"
}
This is the writeback half of the Context Library. The library is mounted into every sandcastle at /sandbox/files/library, pruned to your OWNERS permissions. Reads happen over the filesystem; writes back to canonical, versioned org context happen here — as a reviewable change, not a silent commit.

Workflow

1

Stage your changes

Edit files under /sandbox/files/library using Exec or Upload. A change can only be created from real, staged file changes.
2

(Optional) Preview the diff

Call Diff Library to confirm what will be written back before authoring a change.
3

Create the change

POST /v2/sandcastles/:id/library/changes with a title and description. The change is submitted OPEN for admin review (or DRAFT if you set draft: true).
4

Handle conflicts / iterate

If has_conflicts is true the change stays RESERVED and the session’s library/ is re-materialized with .rej markers. Resolve them and re-submit with the same change_number to file a new changeset.

Driving this from an agent loop

If you let an LLM decide when to write back, give the tool a description that teaches the stage-then-change workflow — otherwise models try to “save” before editing, or file empty changes. A description that mirrors the in-product tool works well:
Writeback your changes under /sandbox/files/library to the organization's
Context Library by creating or updating a change. Changes are the only way to
persist library changes; they are submitted for admin review.

Edit the files first and make sure all changes are written to the local
library/ directory — only then create a change (creating one with no changes
fails). Write a descriptive title (<=50 chars) and a Markdown description.

To revise an existing change, pass its change_number (this creates a new
changeset). If the response reports merge conflicts, resolve the .rej files and
re-submit with the same change_number. Do not create .bak backup files in the
library before creating a change.
Permissions are enforced twice: the mount you edited was already pruned to your OWNERS access, and every changed path is re-validated at merge — a change can never widen access. If an auto-approve rule matches, status comes back approved and the change is already live.

Authorizations

Authorization
string
header
required

API key or JWT token

Path Parameters

id
string
required

Sandbox ID

Body

application/json
title
string

Short summary (≤50 chars). Required for a new change.

Maximum string length: 50
description
string

Markdown explanation of the changes. Required for a new change.

draft
boolean
default:false

File as DRAFT instead of OPEN (not yet ready for review).

change_number
integer<int32>

Set to revise an existing change (creates a new changeset).

Response

Change created or updated

change_id
string
change_number
integer<int32>
status
enum<string>

Change lifecycle state after submission.

Available options:
open,
draft,
approved,
reserved
git_ref
string
has_conflicts
boolean
conflicts
string

Human-readable conflict view (present when has_conflicts).

auto_approved
boolean
diffs
object[]
raw_diff
string