Update Customer's Custom Attributes

PUT https://api.chartmogul.com/v1/customers/{CUSTOMER_UUID}/attributes/custom

Updates the custom attributes of a given customer. Attribute must first be created using the POST call.

curl -X PUT "https://api.chartmogul.com/v1/customers/cus_de305d54-75b4-431b-adb2-eb6b9e546012/attributes/custom" \
     -u YOUR_API_KEY: \
     -H "Content-Type: application/json" \
     -d '{
            "custom":{
              "pro": true,
              "channel": {"value": "Twitter", "source": "integration2"}
            },
            "overrides": { "custom": { "channel": true } }
         }'
customer = ChartMogul::Customer.retrieve("cus_de305d54-75b4-431b-adb2-eb6b9e546012")

customer.update_custom_attributes!(
  pro: true,
  channel: { value: "Twitter", source: "integration2" },
)
ChartMogul.CustomAttribute.update(
  config,
  "cus_de305d54-75b4-431b-adb2-eb6b9e546012",
  {
    custom: {
      pro: true,
      channel: { value: "Twitter", source: "integration2" },
    },
  }
);
$customer = ChartMogul\Customer::retrieve("cus_de305d54-75b4-431b-adb2-eb6b9e546012");

$customer->updateCustomAttributes(
  ["channel" => ["value" => "Twitter", "source" => "integration2"]],
  ["pro" => true]
);
api.UpdateCustomAttributesOfCustomer(
  "cus_de305d54-75b4-431b-adb2-eb6b9e546012",
  map[string]interface{}{
    "channel": cm.AttributeWithSource{
      Value:  "Twitter",
      Source: "integration2",
    },
    "pro": true,
  }
)
chartmogul.CustomAttributes.update(
  config,
  uuid="cus_de305d54-75b4-431b-adb2-eb6b9e546012",
  data={
    "custom": {
      "channel": {"value": "Twitter", "source": "integration2"},
      "pro": True,
    }
  },
)
{
  "custom": {
    "CAC": 213,
    "utmCampaign": "social media 1",
    "convertedAt": "2022-09-08 00:00:00",
    "pro": true,
    "channel": "Twitter"
  },
  "overrides": { "custom": { "channel": true } }
}
{
  :CAC => 213,
  :utmCampaign => "social media 1",
  :convertedAt => "2022-09-08 00:00:00",
  :pro => true,
  :salesRep => "Gabi",
  :channel => "Twitter",
  :age => 8,
}
{
  custom: {
    CAC: 213,
    utmCampaign: "social media 1",
    convertedAt: "2022-09-08 00:00:00",
    pro: true,
    channel: "Twitter"
  }
}
array (
  "CAC" => 213,
  "utmCampaign" => "social media 1",
  "convertedAt" => "2022-09-08 00:00:00",
  "pro" => true,
  "channel" => "Twitter"
)
(*chartmogul.CustomAttributes)(0xc04206e030)({
  Custom: (map[string]interface {}) (len=5) {
    (string) (len=3) "CAC": (float64) 213,
    (string) (len=11) "utmCampaign": (string) (len=14) "social media 1",
    (string) (len=11) "convertedAt": (string) (len=19) "2022-09-08 00:00:00",
    (string) (len=3) "pro": (string) (bool) true,
    (string) (len=7) "channel": (string) (len=7) "Twitter"
  }
 })
<CustomAttributes{
  custom={
    "CAC": 213,
    "utmCampaign": "social media 1",
    "convertedAt": "2022-09-08 00:00:00",
    "pro": True, 
    "channel": "Twitter"}
}>

Path parameters

customer_uuid string required
The ChartMogul UUID of the customer.

Body parameters

custom object required

A Hash containing the custom attributes to be updated. Each custom attribute must have a key and value as described below.

key string required

The name of the custom attribute that is to be updated. Accepts alphanumeric characters and underscores.

value string required

The new value for the custom attribute. Should be of the data type as specified in type.

Supported data types and their accepted formats.

  • String – Accepts alphanumeric characters. Maximum of 255 characters allowed.
  • Integer – Accepts only numeric characters.
  • Decimal – Accepts floating point numbers.
  • Timestamp – In the ISO 8601 format.
  • Boolean – Can be one of TRUE, true, t, 1, FALSE, false, f, or 0.
source string optional default: "API"

Optional parameter to specify where the custom attribute was created. Defaults to API. Not included in the response.

overrides object optional

Boolean flags that set or remove overrides on custom attributes, nested by namespace, e.g. {"custom": {"channel": true}}. true overrides the attribute with its value once this request is applied — an overridden value is protected, so later updates from your billing system, or API requests without an override flag, no longer change it. false removes an existing override; if the request carries no new value for the attribute, it reverts to the latest value from the customer’s edit history. The attribute must already exist in your account with history tracking enabled (false is always accepted). Namespaced and nested attribute names from your integrations work too, e.g. {"stripe": {"metadata": {"plan": true}}}, and a flagged attribute needs no value in the same request — its current value is protected as-is.

Response

In the response, custom contains all the custom attributes now on this customer, and overrides flags the currently overridden ones.

Note that each attribute has to be already present, non-existent attributes will result in Bad request.