How to use properly add or update API endpoint?

Hello, I need to add or update all values of a Grist table from a local csv using add or update API endpoint.

I am having difficulty on how to search all values of the table and update only the different values from the local csv. @Dmitry_Sagalovskiy ?
How to get the id of each record to udpate? Is that the correct payload structure?

json
{
  "records": [
    {
      "require": {"id": 1},
      "fields": {"field1": "value1", "field2": "value2"}
    },
    {
      "require": {"id": 2},
      "fields": {"field1": "value3", "field2": "value4"}
    }
  ]
}