Use the datasets/{datasetId}:updateRecords
endpoint to stream records as JSON documents to insert, update, or delete records in a dataset.
The endpoint datasets/{datasetId}:updateRecords
allows you to create, update, or delete records.
- A
CREATE
action overwrites an existing record or creates a new one. - A
DELETE
action removes the record from the dataset.
The POST body of the request contains newline-delimited JSON documents, one document per update command, as in the following example.
{"action": "CREATE","recordId": "101","record": {"name":"John","email":["[email protected]","[email protected]"]}}
{"action": "CREATE","recordId": "102","record": {"name":"Jane","email":["[email protected]","[email protected]"]}}
{"action": "DELETE","recordId": "102"}
The fields in the JSON are as follows:
Field | Description |
---|---|
action | The action being requested.CREATE or DELETE . |
recordId | The ID of the record. |
record | Optional. The information the new record will contain upon creation. Fields in the record must exist in the schema of the dataset they are being added to. If fields are not in the schema, they will be ignored. |
About Newline-delimited JSON documents
The POST body contains newline-delimited JSON documents. For convenience, using newline-delimited JSON documents is not required, since the API uses the JSON
document-end
to delimit the stream.However, exporting dataset's records as JSON requires that each line is newline-delimitated. For more information, see Stream a Dataset's Records.
Response Fields
A successful request returns a JSON file with metadata describing the action.
Field | Description |
---|---|
numCommandsProcessed | The number of commands successfully processed. |
allCommandsSucceeded | Whether all the commands were successful. true or false . |
validationErrors | A list of any validation errors that were returned for failed commands. Will only exist if allCommandSucceeded is false . |