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.

Attributes

Optional unless marked required

content_typestringrequired
Records the attribute is for: activity, clientuser (contacts), company, deal, product or ticket. Contacts are clientuser here, but user in Get all attributes.
namestringrequired
Name of the attribute. Can't be empty, and must be unique among the model's attributes, ignoring letter case. The API doesn't enforce a maximum length.
value_typestring
Type of the attribute's values: boolean, date, datetime, fixed, float, integer, json or string. string when not sent.
choicesarray of strings
Options of a fixed attribute. Without them the attribute has no options.
allow_multiple_choicesboolean
Whether more than one option of a fixed attribute can be selected. false when not sent.

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 '{
"name": "Segment",
"value_type": "string",
"content_type": "company"
}'

Response examples​

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

A 400 names every field that was rejected, each with its messages:

MessageWhen
This field is required.name or content_type is missing.
This field may not be blank.name is empty.
'abc' is not a valid content type choice. Possible choices are: clientuser, activity, company, deal, product, ticketcontent_type isn't one of those, user included.
'abc' is not a valid value type choice. Possible choices are: boolean, fixed, string, date, datetime, integer, float, jsonvalue_type isn't one of those.
Expected a list of items but got type "str".choices isn't a list.

The 409 comes back when the model already has an attribute with that name, also when only the letter case differs. The same name on another model is fine. choices sent for a type other than fixed are saved but have no effect.

Attributes can't be deleted through the API: remove one in the panel.

Response fields​

Fields returned in the 201 Created response body.

idinteger
Unique identifier of the attribute, assigned by User.
namestring
Name of the attribute, as sent.
name_stdstring
Standardized name used in the API and in record bodies (Loyalty tier becomes loyalty_tier).
value_typestring
Type of the attribute's values: boolean, date, datetime, fixed, float, integer, json or string.
content_typestring
Records the attribute is for, as sent: activity, clientuser, company, deal, product or ticket.
note

Errors that can come from any endpoint (401, 429, 500, 502, 504) are described in HTTP response codes.

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"
}

The response doesn't include choices or allow_multiple_choices. Get all attributes lists them for the model (/all-attributes/user/ for contacts).