GoliathDevelopersGet an API key
Reference/Spacesgenerated from the gateway manifest

editSpaceTextLines

Reorganize or rewrite part of a text file by line number.

POST/api/v1/callWRITEidempotent · 24 hruns as the key's owner
View as Markdown

Reorganize or rewrite part of a text file by line number (from getSpaceTextLines), as one new version like a save: each edit replaces a range startLine-endLine with text (empty deletes it), MOVES the range before beforeLine (no text: its characters are kept exactly, nothing re-sent), or with no range inserts text before beforeLine. Every number is the read version's, the edits apply together, and every line no edit names stays exactly as it was. Overlapping ranges, a target inside a range being changed, and a stale baseVersionId are refused. Use it to put a long file into sections, reorder it, or fix lines without re-sending the whole file.

curl https://server.goliathdata.com/api/v1/call \
  -H "Authorization: Bearer $GOLIATH_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "operationId": "editSpaceTextLines",
    "variables": {
      "input": {
        "itemId": "<itemId>",
        "baseVersionId": "<baseVersionId>",
        "edits": [
          {}
        ]
      }
    }
  }'
import { GoliathClient } from '@goliath-data/sdk'

const goliath = new GoliathClient({
  apiKey: process.env.GOLIATH_API_KEY!,
  baseUrl: 'https://server.goliathdata.com',
})

const result = await goliath.spaces.editSpaceTextLines(
  {
    input: {
      itemId: '<itemId>',
      baseVersionId: '<baseVersionId>',
      edits: [
        {}
      ]
    }
  },
  { idempotencyKey: crypto.randomUUID() },
)
const res = await fetch('https://server.goliathdata.com/api/v1/call', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.GOLIATH_API_KEY}`,
    'Content-Type': 'application/json',
    'Idempotency-Key': crypto.randomUUID(),
  },
  body: JSON.stringify({
    operationId: 'editSpaceTextLines',
    variables: {
      input: {
        itemId: '<itemId>',
        baseVersionId: '<baseVersionId>',
        edits: [
          {}
        ]
      }
    }
  }),
})
const { data, errors } = await res.json()

Variables

The example sends only what the schema requires. Some operations also need one of several optional variables (one filter or another, say); the description above says which.

inputEditSpaceTextLinesInput!required
itemIdID!required
baseVersionIdID!required

The versionId the line numbers were read from; refused if someone saved since.

edits[SpaceTextLineEdit!]!required

Applied together as one new version; ranges may not overlap.

Every field, all the way down
variables
[
  {
    "name": "input",
    "type": "EditSpaceTextLinesInput!",
    "required": true,
    "description": null,
    "defaultValue": null,
    "fields": [
      {
        "name": "itemId",
        "type": "ID!",
        "required": true,
        "description": null,
        "defaultValue": null
      },
      {
        "name": "baseVersionId",
        "type": "ID!",
        "required": true,
        "description": "The versionId the line numbers were read from; refused if someone saved since.",
        "defaultValue": null
      },
      {
        "name": "edits",
        "type": "[SpaceTextLineEdit!]!",
        "required": true,
        "description": "Applied together as one new version; ranges may not overlap.",
        "defaultValue": null,
        "fields": [
          {
            "name": "startLine",
            "type": "Int",
            "required": false,
            "description": "First line of the range to replace, delete or move.",
            "defaultValue": null
          },
          {
            "name": "endLine",
            "type": "Int",
            "required": false,
            "description": "Last line of that range (inclusive).",
            "defaultValue": null
          },
          {
            "name": "text",
            "type": "String",
            "required": false,
            "description": "The range's new lines (\"\" deletes it), or the lines to insert.",
            "defaultValue": null
          },
          {
            "name": "beforeLine",
            "type": "Int",
            "required": false,
            "description": "Where a moved range or inserted lines go: before this line (the file's line count + 1 = the end).",
            "defaultValue": null
          }
        ]
      }
    ]
  }
]

Response

What comes back under data: a list shows as one entry, and a value as its type.

response shape
{
  "data": {
    "spacesMutation": {
      "editTextLines": {
        "id": "<ID>",
        "spaceId": "<ID>",
        "spaceName": "…",
        "parentId": "<ID>",
        "kind": "FOLDER",
        "name": "…",
        "description": "…",
        "fileType": "…",
        "sizeBytes": 0,
        "accessMode": "INHERIT",
        "systemLocked": true,
        "viewerRole": "VIEWER",
        "abilities": {
          "addChildren": true,
          "edit": true,
          "move": true,
          "trash": true,
          "share": true
        },
        "owner": {
          "id": "<ID>",
          "name": "…"
        },
        "createdBy": {
          "kind": "PERSON",
          "label": "…"
        },
        "childCount": 0,
        "shareCount": 0,
        "currentVersion": {
          "id": "<ID>",
          "versionNumber": 0
        },
        "path": [
          {
            "id": "<ID>",
            "name": "…"
          }
        ],
        "updatedAt": "2026-01-01T00:00:00.000Z",
        "trashedAt": "2026-01-01T00:00:00.000Z"
      }
    }
  }
}

Errors

Idempotency

Send an Idempotency-Key of 1 to 255 characters. A finished request retried with the same key replays its stored response, marked Idempotency-Replayed: true; one still in flight returns 409 idempotency_conflict. Keys expire after 24 hours. Write without fear →