# saveWorkflowTableRows

Create or replace rows (`rows`: a row is replaced WHOLE, never merged) and delete rows (`deleteRowIds`) of one table in a single write; a deleted row or a replaced cell is gone for good, so this needs the person's approval. Pass `expectedUpdatedAt` = the table's `updatedAt` from getWorkflowTable so a save over someone else's newer edit is refused (CONFLICT) instead of overwriting it. Returns the table's shape and `rowCount`; read rows back with getWorkflowTable.

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

## Variables

- `input`: `SaveWorkflowTableRowsInput!` (required). Upserts and deletes rows of one table in a single write, which is what the grid does when a user saves.
  - `workflowTableId`: `ID!` (required)
  - `rows`: `[SaveWorkflowTableRowInput!]`. Rows to create or replace. A row is replaced whole, never merged.
    - `id`: `ID`. Null creates a new row.
    - `key`: `String!` (required). For a `COUNTY_FIPS` table, exactly 5 digits. Ignored when `keyParts` is given: the key is then derived from the parts.
    - `keyLabel`: `String`
    - `keyLevel`: `Int`. Which level of the table's `keyShape` the row belongs to. Absent means the primary level.
    - `keyParts`: `[WorkflowTableRowKeyPartInput!]`. The row's key, one entry per part of its level, in order. Absent means `key` and `keyLabel` as the single exact part, which is every table with one exact key.
      - `match`: `WorkflowTableKeyMatch!` (required, one of `EXACT`, `RANGE`). How one part of a Workflow Table's key is compared with the subject's value. EXACT: Equal, in the key kind's canonical spelling. RANGE: Inside the row's inclusive range. Only offered for kinds whose values have an order: a ZIP code, for one.
      - `value`: `String`
      - `label`: `String`
      - `rangeStart`: `String`
      - `rangeEnd`: `String`
    - `isDefault`: `Boolean!` (required). At most one row per table may be the default, counting rows this call is not touching.
    - `cells`: `[SaveWorkflowTableCellInput!]!` (required). Values by column. A column absent here, or present with an empty string, holds no value for this row.
      - `columnId`: `ID!` (required)
      - `value`: `String!` (required)
  - `deleteRowIds`: `[ID!]`. Rows to delete, by id.
  - `expectedUpdatedAt`: `DateTime`. Optimistic-concurrency token: the table's `updatedAt` as the editor loaded it. When provided and the row has changed since, the save is refused with CONFLICT rather than replacing whatever the other editor committed. Omit only on create, where there is nothing to conflict with.
  - `importPart`: `WorkflowTableImportPartInput`. Set when this save is one part of a CSV import. The part is labelled on its history entry, and may carry at most 200 rows so the entry records every one.
    - `fileName`: `String!` (required). The uploaded file's name.
    - `part`: `Int!` (required). 1-based.
    - `parts`: `Int!` (required)

## Response (data, an example)

```json
{
  "workflowAutomationsMutation": {
    "saveWorkflowTableRows": {
      "id": "<ID>",
      "name": "…",
      "description": "…",
      "keyKind": "COUNTY_FIPS",
      "keyFieldPath": "…",
      "keyShape": {
        "levels": [
          {
            "parts": [
              {
                "kind": "COUNTY_FIPS",
                "fieldPath": "…",
                "match": "EXACT"
              }
            ]
          }
        ]
      },
      "rowCount": 0,
      "isProvisioned": true,
      "updatedAt": "2026-01-01T00:00:00.000Z",
      "columns": [
        {
          "id": "<ID>",
          "name": "…",
          "kind": "TEXT",
          "displayOrder": 0,
          "tokenKey": "…",
          "options": [
            {
              "value": "…",
              "label": "…"
            }
          ]
        }
      ]
    }
  }
}
```

## 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": "saveWorkflowTableRows",
    "variables": {
      "input": {
        "workflowTableId": "<workflowTableId>"
      }
    }
  }'
```
