POST
/
api
/
v1
/
accounts
/
{account_id}
/
custom_attribute_definitions
Add a new custom attribute
curl --request POST \
  --url https://app.chatwoot.com/api/v1/accounts/{account_id}/custom_attribute_definitions \
  --header 'Content-Type: application/json' \
  --header 'api_access_token: <api-key>' \
  --data '{
  "attribute_display_name": "Custom Attribute",
  "attribute_display_type": 0,
  "attribute_description": "This is a custom attribute",
  "attribute_key": "custom_attribute",
  "attribute_values": [
    "value1",
    "value2"
  ],
  "attribute_model": 0,
  "regex_pattern": "^[a-zA-Z0-9]+$",
  "regex_cue": "Please enter a valid value"
}'
{
  "id": 123,
  "attribute_display_name": "<string>",
  "attribute_display_type": "<string>",
  "attribute_description": "<string>",
  "attribute_key": "<string>",
  "regex_pattern": "<string>",
  "regex_cue": "<string>",
  "attribute_values": "<string>",
  "attribute_model": "<string>",
  "default_value": "<string>",
  "created_at": "<string>",
  "updated_at": "<string>"
}

Authorizations

api_access_token
string
header
required

This token can be obtained by visiting the profile page or via rails console. Provides access to endpoints based on the user permissions levels. This token can be saved by an external system when user is created via API, to perform activities on behalf of the user.

Path Parameters

account_id
integer
required

The numeric ID of the account

Body

application/json
attribute_display_name
string

Attribute display name

Example:

"Custom Attribute"

attribute_display_type
integer

Attribute display type (text- 0, number- 1, currency- 2, percent- 3, link- 4, date- 5, list- 6, checkbox- 7)

Example:

0

attribute_description
string

Attribute description

Example:

"This is a custom attribute"

attribute_key
string

Attribute unique key value

Example:

"custom_attribute"

attribute_values
string[]

Attribute values

Example:
["value1", "value2"]
attribute_model
integer

Attribute type(conversation_attribute- 0, contact_attribute- 1)

Example:

0

regex_pattern
string

Regex pattern (Only applicable for type- text). The regex pattern is used to validate the attribute value(s).

Example:

"^[a-zA-Z0-9]+$"

regex_cue
string

Regex cue message (Only applicable for type- text). The cue message is shown when the regex pattern is not matched.

Example:

"Please enter a valid value"

Response

Success

id
integer

Identifier

attribute_display_name
string

Attribute display name

attribute_display_type
string

Attribute display type (text, number, currency, percent, link, date, list, checkbox)

attribute_description
string

Attribute description

attribute_key
string

Attribute unique key value

regex_pattern
string

Regex pattern

regex_cue
string

Regex cue

attribute_values
string

Attribute values

attribute_model
string

Attribute type(conversation_attribute/contact_attribute)

default_value
string

Attribute default value

created_at
string

The date and time when the custom attribute was created

updated_at
string

The date and time when the custom attribute was updated