# insertSpaceTextLines

Insert lines into a text file by line number (from getSpaceTextLines), every existing line left exactly as it was (headings, an intro, a summary) as a new version, like a save. `beforeLine` 1 is the top, `totalLines + 1` the end; several insertions before one line keep their order. Use it instead of saveSpaceTextFile whenever the file is too large to re-send whole.

- Call: `POST https://server.goliathdata.com/api/v1/call` with `{ "operationId": "insertSpaceTextLines", "variables": {...} }`
- Scope: `WRITE`
- Type: mutation
- Idempotency: honors `Idempotency-Key` (24 h)
- Rate-limited: no

## Variables

- `input`: `InsertSpaceTextLinesInput!` (required)
  - `itemId`: `ID!` (required)
  - `baseVersionId`: `ID!` (required). The versionId the line numbers were read from; refused if someone saved since.
  - `insertions`: `[SpaceTextLineInsertion!]!` (required)
    - `beforeLine`: `Int!` (required). The line the text goes before (1 = the top; the file's line count + 1 = the end).
    - `text`: `String!` (required). One or more lines.

## Response (data, an example)

```json
{
  "spacesMutation": {
    "insertTextLines": {
      "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"
    }
  }
}
```

## Example

```bash
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": "insertSpaceTextLines",
    "variables": {
      "input": {
        "itemId": "<itemId>",
        "baseVersionId": "<baseVersionId>",
        "insertions": [
          {
            "beforeLine": 10,
            "text": "<String>"
          }
        ]
      }
    }
  }'
```
