JSON API » fields » fields/create

Creates a new custom field.

Input parameters

Requires authentication and the system role privilege.

NameTypeDescriptionRequiredDefault value
auth_usernameStringAuthentication username.Yes
auth_passwordStringAuthentication password.Yes
nameStringName of field. Not shown to users.Yes
objectStringObject field applies to. "customer" or "phone".Yes
titleStringName as shown to users.Yes
customerIntegerID of customer to show field to. 0 for all customers.No0
default_valueStringDefault value.No0 for type "boolean", else empty string.
descriptionStringDescription.NoEmpty string.
helpStringHelp text shown to users.NoEmpty string.
hiddenInteger1 if hidden from users, 0 if shown.No0
placeholderStringPlaceholder text shown to users. Only used for "text" type.NoEmpty string.
rankIntegerOrder to show custom field in. 1 for first, 100 for last.No1
typeStringType of field. "allowed" for set of allowed values. "boolean" for yes/no. "text" for text.No"text"
validateStringA regular expression used to validate the user's input. Empty string for none.NoEmpty string.
validationInteger1 to validate input then return, 0 for full action.No0

When creating a field of type "allowed", do not specify a default value, or specify a default value of empty string. Then set the allowed values, and update the field to one of the allowed values.

Responses

CodeDescription
200Success.
201Input passed validation. Only returned if validation=1.
400Invalid input parameters specified. Check the key and message fields for more details.
401The authentication details provided are invalid.
402Your role does not allow this.

Data returned

The ID of the created custom field.

Example: With required parameters

http://enswitch.example.com/api/json/fields/create/?auth_username=user;auth_password=password;name=example;object=customer;title=Example+field

{ "responses":[ { "code":"200", "key":"", "message":"OK" } ], "data":{ "id":123 } }

Change history

VersionChanges
4.0Function added.