JSON API » fields » fields/create
Creates a new custom field.
Input parameters
Requires authentication and the system role privilege.
Name | Type | Description | Required | Default value |
---|---|---|---|---|
auth_username | String | Authentication username. | Yes | |
auth_password | String | Authentication password. | Yes | |
name | String | Name of field. Not shown to users. | Yes | |
object | String | Object field applies to. "customer" or "phone". | Yes | |
title | String | Name as shown to users. | Yes | |
customer | Integer | ID of customer to show field to. 0 for all customers. | No | 0 |
default_value | String | Default value. | No | 0 for type "boolean", else empty string. |
description | String | Description. | No | Empty string. |
help | String | Help text shown to users. | No | Empty string. |
hidden | Integer | 1 if hidden from users, 0 if shown. | No | 0 |
placeholder | String | Placeholder text shown to users. Only used for "text" type. | No | Empty string. |
rank | Integer | Order to show custom field in. 1 for first, 100 for last. | No | 1 |
type | String | Type of field. "allowed" for set of allowed values. "boolean" for yes/no. "text" for text. | No | "text" |
validate | String | A regular expression used to validate the user's input. Empty string for none. | No | Empty string. |
validation | Integer | 1 to validate input then return, 0 for full action. | No | 0 |
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
Code | Description |
---|---|
200 | Success. |
201 | Input passed validation. Only returned if validation=1. |
400 | Invalid input parameters specified. Check the key and message fields for more details. |
401 | The authentication details provided are invalid. |
402 | Your 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
Version | Changes |
---|---|
4.0 | Function added. |