Bulk Operation: PUT vs. PATCH

The API supports bulk operation to add or update DNS records. The docs state that POST, PUT and PATCH are supported and behave lightly different.

  • POST: Can only create new records but not change existing ones.
  • PUT: Can create records or update existing ones. Requires both records and ttl.
  • PATCH: Can create records or update existing ones. Requires only one of records and ttl when updating records and (obviously) both for new records.

I understand when to use POST: When I want to make sure, that I do not accidentally change existing records.
But when and why would I prefer PUT over PATCH?
It seems to me that PATCH does all that PUT does and is more flexible. Did I miss something?

Hi black,

Your understanding is correct.

The reason for this behavior is that we implemented a REST-ful interface for non-bulk requests, with PATCH and PUT for specific RRsets (/api/v1/domains/{name}/rrsets/{subname}/{type}/) to either modify or replace the RRset, respectively. If you undertake a quick Internet search, you’ll find lots of articles explaining that that’s how these HTTP verbs are designed to work.

As we added the bulk operations, we decided to mimic this behavior so that any non-bulk requests still works if you send it to the bulk endpoint, adding the subname and type fields to the payload and enclosing it with [].

Stay secure,
Peter

Thank you for clearing that up. I’ll just ignore PUT for bulk operation then :wink: