Custom Attributes

Custom Attributes

Custom attributes offer a seamless integration experience with our platform and can be managed through either the Solarize UI or the API Reference. The following entities support custom attributes:

  • Site
  • Customer
  • Meter
  • Contract
  • Price Component

Values

To assign a custom attribute value to an entity, it is essential to create the corresponding custom attribute first. All custom attribute values are encapsulated within a customAttributes object and can be utilized in POST, UPDATE, and GET actions. Below is an example of an entity object with custom attributes:

{
  "id": "a689a45d-2a05-425a-ba47-74434382fd3d",
  ...
  "customAttributes": {
    "aText": "Example Text",
    "aNumber": 42.2,
    "aDate": "2023-11-11",
    "aNull": null
  }
}

It's important to note that an entity always includes all custom attribute keys, even if no value has been added yet. The default value for an attribute is always null.

Data types

Our platform supports a variety of data types, enhancing flexibility in your application. The following custom attribute types are supported:

TypeExample
text"Example Text"
number42.2
date"2023-11-11"
date_time"2023-11-11T10:30:00.000Z"
booleantrue

Example

This example demonstrates how to create a custom attribute called Business Sector for a customer and set its value via the API.

Step 1: Create the Custom Attribute

curl -X POST 'https://api.solarize.energy/v1/custom-attributes' \
-H 'Content-Type: application/json' \
-d '{
    "title": "Business Sector",
    "name": "business_sector",
    "entity": "customer",
    "type": "text"
}'

Step 2: Set the Custom Attribute for a Customer

After the Business Sector attribute is created, its value can be set by referencing the custom attribute name, business_sector, when creating or updating a customer:

# Request:
curl -X PUT 'https://api.solarize.energy/v1/customers/:id' \
--header 'Content-Type: application/json' \
--data '{
    "customAttributes": {
        "business_sector": "Food"
    }
}'
# Response:
{
    "data": {
        ...
        "customAttributes": {
            "business_sector": "Food"
        }
    }
}