Skip to content

Staged write-back: approve SharePoint changes first

SPSync is read-only toward SharePoint by default. Staged write-back is the one exception, and it is off until you turn it on for a list. An agent or an internal app proposes a change, a named person approves it, and SPSync then applies it to the SharePoint item. Nothing is written without an approval, and SharePoint wins any conflict.

In the replication config, add writeback to each list you want to allow changes on and name the columns a proposal may change:

lists:
- id: 11111111-1111-1111-1111-111111111111
name: Projects
writeback:
enabled: true
columns: [Status, Budget]

A list without writeback, or with enabled: false, can never be written to. A column that is not in columns is refused.

Supported columns: single-line text, multi-line plain text, number, currency, date, yes/no and single choice. Lookup, person, managed metadata, attachments and calculated columns are unsupported: the proposal is refused with a reason. There are no deletes and no creates.

The Entra app needs the write role on that site only (Sites.Selected with write), or on the one list. Keep read-only for every other site. spsync doctor checks the write role for each opted-in list (a writeback[<list>] line) and spsync proposals apply refuses to run without it.

spsync mcp serve --allow-proposals adds a propose_change tool that inserts a row into the spsync_proposals table next to your replica (see the MCP server page). Anything else that can insert a row into that table works too. spsync proposals reads that table with the role named in mcp.proposals_connection_string_env, which needs SELECT on the replica tables and SELECT, INSERT and UPDATE on spsync_proposals. Its first run adds the decision columns, so it also needs ALTER once.

Terminal window
spsync proposals list replication.yaml --status proposed
spsync proposals approve replication.yaml 12 --by "[email protected]"
spsync proposals reject replication.yaml 13 --by "[email protected]" --reason "wrong item"
spsync proposals apply replication.yaml 12 --dry-run # prints the PATCH body, sends nothing to SharePoint
spsync proposals apply replication.yaml 12 --by "[email protected]"

apply with no id applies every approved proposal. --by defaults to your login and is recorded as the person who decided.

Statuses: proposed, approved, applied, rejected, conflict.

  • Applied. SPSync sent the change with If-Match set to the etag it last read for the item, and records the new etag. The next sync brings the new value into the replica.
  • Conflict. Someone changed the item in SharePoint after SPSync last read it, so SharePoint answered 412. SPSync does not retry and does not overwrite: SharePoint keeps its value and the proposal is marked conflict. Run a sync, look at the item, and propose again if the change still applies. Two approved proposals on the same item, applied before a sync, behave the same way: the second gets a conflict, because SPSync’s copy of the etag is still the old one until the next sync.
  • Failed. A missing write role (403) or a deleted item (404) leaves the proposal approved with the reason in its error column, so you can fix the cause and retry.
  • Throttled. A 429 or 503 is retried on the Retry-After SharePoint sends, as for every other Graph call.

Each proposal keeps who proposed it and when, who decided it and when, the old values (read from the replica when it was approved and again when it was applied), the new etag and any error. Each apply is also written to the SPSync log with the before and after values, the item, the approver and the time.