Partial updates
How to update a Comecero object with a POST that holds only the fields you want to change, how null clears a field and which fields are replaced whole.
To change an object you send a POST to its URL with only the fields you want to change. Everything you leave out stays as it is. This page shows how that works and the few rules to keep in mind.
Send only what changes
To change a customer's email address, send just the email:
curl -X POST "https://api.comecero.com/api/v1/customers/0106784119870CueWmZ9P7" \
-H "Authorization: Bearer $COMECERO_TEST_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "email": "john@example.com" }'The name, addresses and every other field stay the same. The response is the whole customer after the change. See Update a customer for the fields you can send.
Leaving a field out is not the same as null
- Leave a field out to keep its value.
- Send it as
nullto clear it.
{ "phone": null }This removes the customer's phone number. Check the endpoint page before you clear a field: a required field cannot be cleared.
Child objects
Some child objects are updated the same way as the object itself. On a customer, sending part of billing_address changes only those fields of the address:
{ "billing_address": { "postal_code": "10023" } }Sending "billing_address": null resets the whole address.
meta is different: the value you send replaces the old one completely. To add one key to meta, read the object, change its meta, and send all of it back (see Meta data). Lists of values, such as a list service's licenses, are also replaced whole.
Fields the endpoint does not know
A field that is not part of the object is usually ignored rather than refused. So a misspelled field name fails quietly: check the response to make sure the change happened. Fields that are read only, such as date_created, cannot be changed.
The one exception
Roles are replaced, not updated: Replace a role is a PUT that needs the whole role, and fields you leave out are cleared. Every other update in the API is a POST that changes only the fields you send.
Next steps
Customizing output
Use the show and hide query parameters to return only the fields you need from the Comecero API, which keeps responses small, especially for long lists.
Meta data
Store your own data on Comecero carts, orders, customers, products and more with the meta field, and carry it from a cart or invoice to the order.