GoliathDevelopersGet an API key
Reference/Spacesgenerated from the gateway manifest

editSpaceSheetCells

Change cells of a spreadsheet.

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

Change cells of a spreadsheet (.xlsx, CSV, TSV) by A1 address as one new version, without re-sending the sheet: each of edits writes values (rows of cells) right and down from its start cell (a value, a formula (=SUM(B2:B9)) or "" to clear) and appendRows adds rows under the last filled row. Every other cell, sheet, hidden sheet, number format, column width and row height stays as it was, and every formula on the sheet is computed again (one over another sheet keeps the value Excel saved), so read it back with readSpaceSheet for totals. A value is written as typed: a plain number as a number, anything else (a date, "$1,200") as text. Pass the versionId readSpaceSheet returned as baseVersionId: a save since is refused. At most 10,000 cells per call. An .xlsx with charts, images, pivot tables, comments, Excel tables, macros, conditional formatting, data validation, sparklines, links to other workbooks, data connections, slicers or embedded objects is refused (a save would drop them); cell colours and fonts are not kept, as when it is edited in Library.

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": "editSpaceSheetCells",
    "variables": {
      "input": {
        "itemId": "<itemId>",
        "baseVersionId": "<baseVersionId>"
      }
    }
  }'
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.editSpaceSheetCells(
  {
    input: {
      itemId: '<itemId>',
      baseVersionId: '<baseVersionId>'
    }
  },
  { 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: 'editSpaceSheetCells',
    variables: {
      input: {
        itemId: '<itemId>',
        baseVersionId: '<baseVersionId>'
      }
    }
  }),
})
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.

inputEditSpaceSheetCellsInput!required
itemIdID!required
baseVersionIdID!required

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

sheetString

Default: the first visible sheet.

edits[SpaceSheetCellEdit!]

Cells written right and down from `start`: a value, a formula (`=…`), or "" to clear the cell.

appendRows[[String!]!]

Rows added under the sheet's last filled row, from column A.

Every field, all the way down
variables
[
  {
    "name": "input",
    "type": "EditSpaceSheetCellsInput!",
    "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 cells were read from; refused if someone saved since.",
        "defaultValue": null
      },
      {
        "name": "sheet",
        "type": "String",
        "required": false,
        "description": "Default: the first visible sheet.",
        "defaultValue": null
      },
      {
        "name": "edits",
        "type": "[SpaceSheetCellEdit!]",
        "required": false,
        "description": "Cells written right and down from `start`: a value, a formula (`=…`), or \"\" to clear the cell.",
        "defaultValue": null,
        "fields": [
          {
            "name": "start",
            "type": "String!",
            "required": true,
            "description": "The top-left cell, as B2.",
            "defaultValue": null
          },
          {
            "name": "values",
            "type": "[[String!]!]!",
            "required": true,
            "description": null,
            "defaultValue": null
          }
        ]
      },
      {
        "name": "appendRows",
        "type": "[[String!]!]",
        "required": false,
        "description": "Rows added under the sheet's last filled row, from column A.",
        "defaultValue": null
      }
    ]
  }
]

Response

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

response shape
{
  "data": {
    "spacesMutation": {
      "editSheetCells": {
        "sheet": "…",
        "cellsChanged": 0,
        "rowsAppended": 0,
        "rowCount": 0,
        "columnCount": 0,
        "item": {
          "id": "<ID>",
          "name": "…",
          "fileType": "…",
          "sizeBytes": 0,
          "currentVersion": {
            "id": "<ID>",
            "versionNumber": 0
          }
        }
      }
    }
  }
}

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 →