comecerodocs
Concepts

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.

Most commerce object updates use partial updates: send a POST to the object's URL with only the fields you want to change. For those endpoints, everything you leave out stays as it is. Check the endpoint reference: some POST saves take a full definition instead, as described below.

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

For partial commerce updates:

  • Leave a field out to keep its value.
  • Send it as null to 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.

Full usage definitions

POST /usage/agreements and POST /usage/entitlements save full definitions, including when the id already exists. They are not partial updates. Read the current object, preserve its writable fields, change the intended values, and send the full definition using the request schema. Leave out read-only progress and internal state.

Omitted required fields fail validation. Omitted optional fields can reset to defaults; for example, leaving out an agreement's effective_to clears its cutoff. The entitlement's at_zero is an explicit exception: omission keeps its stored credit policy, and null clears it.

For active metered entitlements, change price or funding through POST /usage/entitlements/{id}/change_terms, with the expected agreement revision and a future effective hour. Do not overwrite active terms through the definition save. See Save an agreement, Save an entitlement and Change entitlement terms.

Other update methods

Replace a role and Create or replace a usage metric use PUT with a whole definition. Fields you leave out can reset to defaults.

Customer usage controls also use PUT and PATCH, with revision and consent checks. See Spending limits and automatic top-up. Follow each endpoint's method and required fields rather than applying the partial POST rule to it.

Next steps

On this page