Should I Use POST, PUT, or PATCH to Add Data?

What's the Difference of these three calls in the Pillars API?

Questions:

  • Why are there three different ways to add data to a record through the API?

  • What’s the difference between Post, Put, and Patch when submitting record changes through the Pillars API?

  • When should I use Post, Put, and Patch when editing records through the Pillars API?

    Main Points:

  • Post = Create a new record.

  • Put = Replace a record and all its fields.

  • Patch = Replace or add individual fields leaving the remainder of the record intact.

    Explanation:

The main difference lies in whether you are creating a brand-new item, replacing an existing one entirely, or just editing a specific field.

Key Differences at a Glance

  • POST (Create): Use this to create an entirely new record. It is not idempotent, meaning if you send the same POST request twice, you might accidentally create two identical records.

  • PUT (Full Record Update/Replace): Use this to completely replace an existing record. When using PUT, you must send the entire data object (all fields). If you leave a field out, the API may overwrite it with a null or default value. It is idempotent; sending the same replacement multiple times always results in the same final state. It does not create a duplicate record.

  • PATCH (Partial Update): Use this for minor modifications of a record. You only send the specific fields you want to change, e.g., just updating a user's email address. This is more efficient for large, complex resources when you don't want to re-upload the entire data set.

Comparison Table

FeaturePOSTPUTPATCH
Primary ActionCreate new resourceReplace entire resourceUpdate partial resource
Idempotent?NoYesSometimes
Payload RequiredNew resource data with all fieldsFull resource of all fieldsOnly changed fields
Use CaseAdding a new customerResetting a user profileChanging Active Status, editing an email address

Important Note

While these are standard REST conventions, some specific implementations of the Pillars API may behave differently. For instance, some "Pillar Update" endpoints specifically use POST for updating a Pillar's configuration in certain frameworks. Always check the specific Pillars Reference Documentation for the exact endpoint you are using.