Skip to main content
POST/attributes/

Create attribute

You can create custom attributes for any model.

Possible attribute types: boolean, date, datetime, fixed, float, integer, json, string.

AttributesTypeRequiredDescription
content_typestringyesThe type of content you want create attribute for. Possible content types are: activity, clientuser, company, deal, product, ticket.
namestringyesA name of an attribute you want to create. Has to be at least 1 character, and cannot be longer than 32 characters.
value_typestringyesA type of the attribute value. Possible values: boolean, date, datetime, fixed, float, integer, json, string.
choicesarrayno*Array of option values for fixed choice attributes. Required when value_type is fixed.
allow_multiple_choicesbooleanno*Allows multiple selections for fixed choice attributes. Required when value_type is fixed.

* Required when value_type is fixed

Request​

curl -X POST "https://<your_app_subdomain>.user.com/api/public/attributes/" \
-H "Authorization: Token <your_64_char_api_key>" \
-H "Accept: */*; version=2" \
-H "Content-Type: application/json" \
-d '{
"value_type": "string",
"name": "API string attribute",
"content_type": "clientuser"
}'

Response​

{
"id": 46,
"name": "API string attribute",
"name_std": "api_string_attribute",
"value_type": "string",
"content_type": "clientuser"
}

Fixed Choice Attributes Example​

Request​

curl -X POST "https://<your_app_subdomain>.user.com/api/public/attributes/" \
-H "Authorization: Token <your_64_char_api_key>" \
-H "Accept: */*; version=2" \
-H "Content-Type: application/json" \
-d '{
"content_type": "clientuser",
"name": "Newsletter preferences",
"value_type": "fixed",
"choices": ["Daily digest", "Weekly summary", "Monthly newsletter", "Product updates"],
"allow_multiple_choices": true
}'

Response​

{
"id": 47,
"name": "Newsletter preferences",
"name_std": "newsletter_preferences",
"value_type": "fixed",
"content_type": "clientuser",
"choices": ["Daily digest", "Weekly summary", "Monthly newsletter", "Product updates"],
"allow_multiple_choices": true
}