Skip to content

Writing to Sheetlabs APIs (POST, PATCH, PUT, DELETE)

Some Sheetlabs APIs will allow you to write data back to them. This is quite uncommon, so you should check the API documentation you have been provided first to see if this is enabled for your Sheetlabs API.

Creating new records (POST)

To create a new record, use the POST method and supply an array with one or more records in JSON format. For example:

curl "https://sheetlabs.com/ACME/domains" \
 -X POST  \
 -H "Content-Type: application/json" \
 -d '[ {
  "rank" : 1234,
  "date" : "2022-08-31T13:02:05",
  "domain" : "string",
  "registeredto" : "string"
} ]'

If the records are successfully created, you will receive an HTTP 204 response code with an empty body. In the event of an error, you will receive a 4xx or 5xx code with a descriptive error message.

Replacing records (PUT)

To replace a record in its entirety, use the PUT method and supply an array with one or more records in JSON format. You will need to supply the Sheetlabs record identifier in the __id field to uniquely identify the record that should be replaced. For example:

curl "https://sheetlabs.com/ACME/domains" \
 -X PUT  \
 -H "Content-Type: application/json" \
 -d '[ {
  "__id" : 1,
  "rank" : 1234,
  "date" : "2022-08-31T13:02:05.733705848",
  "domain" : "string",
  "registeredto" : "string"
} ]'

If the records are successfully replaced, you will receive an HTTP 204 response code with an empty body. In the event of an error, you will receive a 4xx or 5xx code with a descriptive error message.

Amending records (PATCH)

To partially update a record, use the PATCH method and supply an array with one or more records in JSON format. If you omit some fields, then the existing values in those fields will be retained (this is the difference from the POST method).

You will need to supply the Sheetlabs record identifier in the __id field to uniquely identify the record that should be updated. For example:

$ curl "https://sheetlabs.com/ACME/domains" \
 -X PATCH  \
 -H "Content-Type: application/json" \
 -d '[ {
  "__id" : 1,
  "rank" : 999
} ]'

If the records are successfully updated, you will receive an HTTP 204 response code with an empty body. In the event of an error, you will receive a 4xx or 5xx code with a descriptive error message.

Deleting records (DELETE)

To delete a record, use the DELETE method and supply an array with one or more records in JSON format. You will need to supply the Sheetlabs record identifier in the __id field to uniquely identify the record that should be deleted. For example:

$ curl "https://sheetlabs.com/ACME/domains" \
 -X DELETE  \
 -H "Content-Type: application/json" \
 -d '[ { 
  "__id" : 1
} ]'

If the records are successfully deleted, you will receive an HTTP 204 response code with an empty body. In the event of an error, you will receive a 4xx or 5xx code with a descriptive error message.