logo

Get Custom Fields List

This interface is used to retrieve the list of created custom fields.

Request Method

GET /custom_fields To use this interface, you would send a GET request to the specified endpoint (/custom_fields) to receive a list of custom fields that have been set up in the system. These fields can be used to store additional information about contacts or other entities within the system. The response will likely be a JSON object containing the details of each custom field, such as the field name, type, and any other relevant metadata.

Request Parameters

Parameter NameRequiredTypeDescriptionRestrictions
categoryOptionalStringThe type of custom fields to retrieve, see details below, default is ticketEnum, Value Range: ["ticket", "customer", "organization"] If other values are passed in, it will not result in an error, but it will be treated as ticket

category Description

OptionDescription
ticketTicket custom fields
customerCustomer custom fields
organizationCustomer company custom fields

Response Data

Attribute NameTypeDescription
codeIntegerExecution result code, 1000 means success
fieldsArrayList of custom fields, see details below

custom_fields Element Description

Attribute NameTypeDescription
idIntegerID
field_nameStringField identifier
field_labelStringField display name
content_typeStringField type, see details below
commentStringField remark
updated_atDateTimeLast update time of the field
optionsArrayField options, only returned for select type fields, see details below
customer_permissionStringCustomer permissions, only returned for customer and ticket fields
agent_permissionStringAgent permissions, only returned for customer and customer company fields
calculate_result_typeStringCalculation field result type, only returned for calculation fields

content_type Value Range

ValueDescription
textSingle line text
area_textMulti-line text
dateDate
timeTime
datetimeDate and time
linkHyperlink
locationLocation
numberPositive integer
numericNumeric
droplistDropdown list
radioRadio button
checkboxCheckbox
chained_droplistCascade
calculateCalculation field
  • The value range of content_type will expand with the addition of features, it is recommended to maintain extensibility for new types in business logic.
  • The structure of options for each custom field type is shown in the example.

calculate_result_type Value Range

ValueDescription
numericNumber
durationDuration
percentagePercentage

options Description

Array element structure

Attribute NameTypeDescription
titleStringOption text description
valueStringOption value
defaultBooleanWhether it is the default option
is_hideBooleanWhether it is hidden
subsArraySub-options, only included in cascade fields, with the same structure as options

customer_permission Value Range

ValueDescription
noneInvisible to customers
readonlyVisible to customers, but not editable
readwriteEditable by customers
mustRequired by customers

agent_permission Value Range

ValueDescription
readonlyVisible to agents, but not editable
readwriteEditable by agents
mustRequired by agents

Example

Request

curl -s https://demo.udesk.cn/open_api_v1/custom_fields?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2
&category=customer

Response

{
    "code": 1000,
    "custom_fields": [
        {
            "field_name": "TextField_1",
            "field_label": "text field",
            "content_type": "text",
            "comment": null,
            "updated_at": "2017-01-17T14:13:41.000+08:00",
            "options": null,
            "customer_permission": "readwrite",
            "agent_permission": "must"
        },
        {
            "field_name": "TextField_2",
            "field_label": "multi-line text field",
            "content_type": "area_text",
            "comment": null,
            "updated_at": "2017-01-17T14:13:41.000+08:00",
            "options": null,
            "cusotmer_permission": "readwrite",
            "agent_permission": "readwrite"
        },
        {
            "field_name": "TextField_3",
            "field_label": "date field",
            "content_type": "date",
            "comment": null,
            "updated_at": "2017-01-17T14:13:41.000+08:00",
            "options": null,
            "customer_permission": "read",
            "agent_permission": "must"
        },
        {
            "field_name": "TextField_4",
            "field_label": "date time field",
            "content_type": "datetime",
            "comment": null,
            "updated_at": "2017-01-17T14:13:41.000+08:00",
            "options": null,
            "customer_permission": "read",
            "agent_permission": "readwrite"
        },
        {
            "field_name": "TextField_5",
            "field_label": "link field",
            "content_type": "link",
            "comment": null,
            "updated_at": "2017-01-17T14:13:41.000+08:00",
            "options": null,
            "customer_permission": "must",
            "agent_permission": "readwrite"
        },
        {
            "field_name": "TextField_6",
            "field_label": "location field",
            "content_type": "location",
            "comment": null,
            "updated_at": "2017-01-17T14:13:41.000+08:00",
            "options": null,
            "customer_permission": "none",
            "agent_permission": "readwrite"
        },
        {
            "field_name": "TextField_7",
            "field_label": "time field",
            "content_type": "time",
            "comment": null,
            "updated_at": "2017-01-17T14:13:41.000+08:00",
            "options": null,
            "customer_permission": "none",
            "agent_permission": "readwrite"
        },
        {
            "field_name": "TextField_8",
            "field_label": "number field",
            "content_type": "number",
            "comment": null,
            "updated_at": "2017-01-17T14:13:41.000+08:00",
            "options": null,
            "customer_permission": "none",
            "agent_permission": "must"
        },
        {
            "field_name": "TextField_9",
            "field_label": "numeric field",
            "content_type": "numeric",
            "comment": null,
            "updated_at": "2017-01-17T14:13:41.000+08:00",
            "options": null,
            "customer_permission": "none",
            "agent_permission": "readwrite"
        },
        {
            "field_name": "SelectField_1",
            "field_label": "droplist field",
            "content_type": "droplist",
            "comment": null,
            "updated_at": "2017-01-17T14:13:41.000+08:00",
            "customer_permission": "read",
            "agent_permission": "readwrite",
            "options": [
                {"title": "option1", "value": "0"},
                {"title": "option2", "value": "1"}
            ]
        },
        {
            "field_name": "SelectField_2",
            "field_label": "radio field",
            "content_type": "radio",
            "comment": null,
            "updated_at": "2017-01-17T14:13:41.000+08:00",
            "customer_permission": "read",
            "agent_permission": "readwrite",
            "options": [
                {"title": "option1", "value": "1"},
                {"title": "option2", "value": "0"}
            ]
        },
        {
            "field_name": "SelectField_3",
            "field_label": "checkbox field",
            "content_type": "checkbox",
            "comment": null,
            "updated_at": "2017-01-17T14:13:41.000+08:00",
            "customer_permission": "none",
            "agent_permission": "must",
            "options": [
                {"title": "option1", "value": "3"},
                {"title": "option2", "value": "4"},
                {"title": "option3", "value": "1"},
                {"title": "option4", "value": "7"}
            ]
        },
        {
            "field_name": "SelectField_4",
            "field_label": "chained_droplist field",
            "content_type": "chained_droplist",
            "comment": null,
            "updated_at": "2017-01-17T14:13:41.000+08:00",
            "options": [
                {"title": "option1", "value": "0", "subs": [
                    {"title": "sub option 1", "value": "0", "subs": [
                        {"title": "sub option 2", "value": "0"}
                    ]}
                ]},
                {"title": "option2", "value": "0", "subs": [
                    {"title": "sub option3", "value": "0"}
                ]}
            ],
            "customer_permission": "none",
            "agent_permission": "must"
        }
    ]
}

Retrieve a Single Custom Field

This interface is used to retrieve details of a single custom field.

Request Method

GET /custom_fields/:field_name

Request Parameters

None

Response Data

Attribute NameTypeDescription
codeIntegerExecution result code, 1000 represents success
fieldObjectRefer to the custom_fields element description above for specific field meanings

Example

curl https://demo.udesk.cn/open_api_v1/custom_fields/SelectField_1?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2
Response:
{
  "code": 1000,
  "field": {
    "id": 1,
    "field_name": "SelectField_1",
    "field_label": "Dropdown List",
    "content_type": "droplist",
    "comment": "",
    "updated_at": "2020-10-19T13:37:01.000+08:00",
    "customer_permission": "readwrite",
    "options": [
        {
            "title": "a",
            "value": "0"
        },
        {
            "title": "b",
            "value": "1",
            "default": true
        },
        {
            "title": "c",
            "value": "2"
        }
    ]
  }
}

Update Custom Field

This interface is used to update a specified custom field. Cascading fields are not supported.

Request Method

PUT /custom_fields/:field_name

You can obtain information about all custom fields through the Get Custom Field List interface.

Request Parameters

ParameterRequiredTypeDescriptionRestrictions
field_nameYesStringThe field_name parameter can be obtained from the field ID column in the custom field configuration page, or from the field_name field in the response data of the Get Custom Field List API. For example, TextField_97, SelectField_166
titleNoStringCustom field title
commentNoStringCustom field remark
select_optionsNoArraySelection field option parameters, required only when updating selection fields. If you do not update the options of a selection field, this parameter can be omitted.

Description of Elements in select_options

You can obtain information about custom fields through the Get Custom Field List interface.

ParameterRequiredTypeDescriptionRestrictions
titleYesStringOption title
valueYesStringOption value1. value is automatically generated by the system and should not be modified! 2. When adding a new option, there is no need to pass the value option!
defaultNoBooleanDefault active optionIf this parameter is used, its value can only be true

value is automatically generated by the system and should not be modified! When adding a new option, there is no need to pass the value option!

Example

Update a Single Select Field

curl https://demo.udesk.cn/open_api_v1/custom_fields/SelectField_1?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2
 \
-X PUT \
-H 'content-type:application/json' \
-d '
{
  "title": "API test change single select custom field",
  "comment": "API test change single select custom field",
  "select_options": [
      {
          "title": "First option",
          "value": "0",
          "default": true
      },
      {
          "title": "Second option",
          "value": "1",
          "is_hide": true
      },
      {
          "title": "Add third option",
      }
  ]
}'

Update a Single Line Text Field

curl https://demo.udesk.cn/open_api_v1/custom_fields/TextField_1?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2
 \
-X PUT \
-H 'content-type:application/json' \
-d '
{
  "title": "API test change single line text custom field",
  "comment": "API test change single line text custom field",
}'

Response Value

{
  "code": 1000,
  "message": "Update successful"
}

Update Custom Fields

This interface is used to update specified custom fields and does not support cascading fields.

Request Method

PUT /custom_fields/:field_name

You can obtain all custom field information through the Get Custom Field List interface.

Request Parameters

ParameterRequiredTypeDescriptionRestrictions
field_nameYesStringThe field_name parameter can be obtained from the field ID column in the custom field configuration page, or from the field_name field in the data returned by the Get Custom Field List API, such as TextField_97, SelectField_166
titleNoStringCustom field title
commentNoStringCustom field note
select_optionsNoArraySelection field option parameters, only required when updating selection fields. If you do not update the options of a selection field, this parameter can be omitted

Explanation of Elements in select_options

You can obtain custom field information through the Get Custom Field List interface.

ParameterRequiredTypeDescriptionRestrictions
titleYesStringOption title
valueYesStringOption value1. value is automatically generated by the system, do not modify it! 2. When adding a new option, there is no need to pass the value option!
defaultNoBooleanDefault active optionIf this parameter is used, its value can only be true

value is automatically generated by the system, do not modify it! When adding a new option, there is no need to pass the value option!

Examples

Update a Single Select Field

curl https://demo.udesk.cn/open_api_v1/custom_fields/SelectField_1?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2
 \
-X PUT \
-H 'content-type:application/json' \
-d '
{
  "title": "API test modifies a single-choice select box custom field",
  "comment": "API test modifies a single-choice select box custom field",
  "select_options": [
      {
          "title": "First option",
          "value": "0",
          "default": true
      },
      {
          "title": "Second option",
          "value": "1",
          "is_hide": true
      },
      {
          "title": "Add third option",
      }
  ]
}'

Update a Single Line Text Field

curl https://demo.udesk.cn/open_api_v1/custom_fields/TextField_1?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2
 \
-X PUT \
-H 'content-type:application/json' \
-d '
{
  "title": "API test modifies a single-line text custom field",
  "comment": "API test modifies a single-line text custom field",
}'

Return Value

{
  "code": 1000,
  "message": "update success"
}

Get Corresponding Options for Large Drop-down Fields

Basic Information

Path:
/open_api_v1/custom_fields/large_droplists/{field_id} Method:
POST Interface Description:
This interface is for large drop-down fields and gets the corresponding options list based on the given filter conditions (supports pagination).

Request Parameters

Headers Content-Type: application/json Path Parameters

Parameter NameExampleRemarks
field_idSelectField_1Drop-down field name
Query
Parameter NameRequiredExampleRemarks
emailYes<test@udesk.cn>Administrator email
timestampYes1676616977Timestamp
nonceYes42a5551cNonce
sign_versionYesv2
signYesc24ad2a82901c1014572a51381ef0f32b278bd7ccf998af5a0ed592536e6ecc1Signature

Body

NameTypeRequiredDefaultNotesAdditional Information
titlestringNot RequiredDropdown option titleExact query
valuestringNot RequiredDropdown option value
create_rangestringNot RequiredOption creation time range (YYYY-MM-DD HH:mm,YYYY-MM-DD HH:mm)
update_rangestringNot RequiredOption update time range (YYYY-MM-DD HH:mm,YYYY-MM-DD HH:mm)
pagenumberNot RequiredPage number (default is 1)
per_pagenumberNot RequiredNumber of records per page (maximum 100, default 20)

Response Data

NameTypeRequiredDefaultNotesAdditional Information
codenumberNot RequiredResponse status code (1000 for success)
messagestringNot RequiredDescription of response status
metaobjectNot Required
├─ pagenumberNot RequiredPage number
├─ total_pagesnumberNot RequiredTotal number of pages
├─ total_countnumberNot RequiredTotal number of records
select_optionsobject []Not RequiredItem Type: object
├─ titlestringNot RequiredOption title
├─ valuestringNot RequiredOption value
├─ is_hidebooleanNot RequiredWhether to hide
├─ defaultbooleanNot RequiredWhether it is the default option
├─ created_atstringNot RequiredCreation time
├─ updated_atstringNot RequiredUpdate time

Request Example

{
    "page": 1,
    "update_range": "2023-02-17 08:00,2023-02-17 12:00"
}

Response Example

{
    "code": 1000,
    "message": "success",
    "meta": {
        "page": 1,
        "total_pages": 10,
        "total_count": 300
    },
    "select_options": [
        {
            "title": "Option Title",
            "value": "1",
            "is_hide": false,
            "default": true,
            "created_at": "2023-02-17 11:11:11",
            "updated_at": "2023-02-17 11:11:11"
        }
    ]
}

Custom Field Structure Description

Description

Udesk currently supports two types of custom field names SelectField and TextField

Field NameTypeDescription
SelectField_1ArraySelect field type (including dropdown, checkbox, and associative fields), Type Name_Unique ID
TextField_1StringText field type, Type Name_Unique ID

Error Codes

Error Codemessage Informationexception:message InformationDescription
2005The resource was not foundThe specified custom field was not foundThe format of the passed field_name is incorrect or the corresponding resource cannot be found based on the passed field_name
2015Non-administrators cannot operateNon-administrators cannot operateThe email used to call the interface must be an administrator email, and non-administrators cannot operate
2059Open API signature is incorrectOpen API signature is incorrectOpen API signature is incorrect, refer to the authentication section of the documentation for details
2062Parameter errorThe title in the select_options array element is requiredWhen modifying a custom field, the title in the select_options array element is required
Parameter errorThe field_name parameter only supports TextFieldSelectField