Custom Attributes are the additional fields you can add to your contacts in Chatbase. Each chatbot has its own custom attribute schema that defines what additional data can be stored for contacts.

Schema Management

Field Lifecycle

  • Custom attributes, once created, cannot be deleted from the schema
  • Fields can be archived to prevent new usage while preserving historical data
  • When a field is archived:
    • New contacts cannot be created with this field
    • Existing contacts cannot update this field
    • The field can only be set to null
    • Existing values are preserved and still readable

Available Endpoints

The Custom Attributes API provides the following endpoints:

Available Types

text
string
For storing text values
number
number
For storing numeric values
boolean
boolean
For storing true/false values
Data of type boolean passed to the contacts API will be coerced to a boolean.For example, a string of value “true” will be converted to a true. And a string of value “false” will be converted to a false.Also, a number of value 0 will be converted to a false. And a number of value 1 will be converted to a true.
date
string
For storing dates in ISO 8601 format
Data of type date passed to the contacts API will be coerced to a date.Supporting formats exactly supported by Javascript Date.

Custom Attribute Object

name
string
required
The unique identifier for the custom attribute
type
string
required
The type of the attribute. One of: text, number, boolean, date
label
string
required
The display label for the attribute
description
string
Description of the attribute
archived
boolean
Whether the attribute is archived. If true, the attribute cannot be used for new or updated values

Using Custom Attributes

Once you’ve created custom attributes, you can:
  1. Add values for these attributes when creating contacts
  2. Update values through the update contact endpoint
  3. View values when listing contacts or getting a single contact

Example

{
  "custom_attributes": {
    "company": "Acme Inc",        // text type
    "age": 25,                    // number type
    "is_active": true,            // boolean type
    "join_date": "2023-01-15",    // date type
    "unknown_field": "value"      // will be stripped out
  }
}

Field Handling

Custom Attributes Validation

Fields under the custom_attributes object go through the following validation:
  1. Field existence check against the schema, non-existent fields are silently removed
  2. Archival status check (archived fields are rejected)
  3. Type validation against the defined type in schema
  4. Value storage if all checks pass

Best Practices

  1. Choose descriptive names for your custom attributes
  2. Use appropriate types for your data
  3. Provide clear descriptions to help other team members understand the purpose of each attribute
  4. Keep the number of custom attributes manageable
  5. Plan your schema carefully as fields cannot be removed