# Create attribute
You can create custom attributes for any model.
Possible attribute types: boolean, date, datetime, fixed, float, integer, json, string.
POST /attributes/
| Attributes | Type | Required | Description |
|---|---|---|---|
| content_type | string | yes | The type of content you want create attribute for. Possible content types are: activity, clientuser, company, deal, product, ticket. |
| name | string | yes | A name of an attribute you want to create. Has to be at least 1 character, and cannot be longer than 32 characters. |
| value_type | string | yes | A type of the attribute value. Possible values: boolean, date, datetime, fixed, float, integer, json, string. |
| choices | array | no* | Array of option values for fixed choice attributes. Required when value_type is fixed. |
| allow_multiple_choices | boolean | no* | Allows multiple selections for fixed choice attributes. Required when value_type is fixed. |
* Required when value_type is fixed
# Request
- CURL
- JavaScript
- PHP
- Python
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
- JavaScript
- PHP
- Python
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
}