The "createLabel" action creates a new label with the required property "name" and optional properties "group", "sequence", "description", and "metadata". The server automatically generates an "id" value and uses it internally for referencing the label. If you use labels in your application, you should also use the "id" property to reference the label because it allows you to rename the label without breaking external references to it.
The "group" and "name" properties work together to uniquely identify each label. They are its natural key. A group assigned to the empty string "" is the default group.
Request examples
Minimal
This example creates a label in the empty "group". It is best to create a label in a specific group.
{
"action": "createLabel",
"params": {
"name": "myLabelName"
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}Typical
{
"api": "admin",
"action": "createLabel",
"params": {
"group": "product/color/",
"name": "myLabel2",
"value": 1,
"enum": 0,
"sequence": 1,
"deprecated": false,
"description": "unknown",
"metadata": {}
},
"authToken": "replaceWithAuthTokenFromCreateSession",
"debug": "none"
}Maximal
{
"api": "admin",
"action": "createLabel",
"params": {
"group": "myLabelGroupName",
"name": "mySecondLabelName",
"value": 99,
"enum": 0,
"sequence": 1.2,
"deprecated": false,
"description": "My label description.",
"metadata": { }
},
"authToken": "replaceWithAuthTokenFromCreateSession",
"apiVersion": "1.0",
"requestId": "3",
"debug": "max"
}
Response example
Minimal
{
"result": {
"id": 1,
"group": "mylabelGroupName",
"name": "mylabelName",
"value": 99,
"enum": 0,
"sequence": 1.2,
"deprecated": false,
"description": "My label description.",
"metadata": {}
},
"authToken": "authToken",
"errorCode": 0,
"errorMessage": "",
"debugInfo": {}
}
Request properties ("params")
| Property | Description | Default | Type | Limits (inclusive) |
|---|---|---|---|---|
deprecated |
The "deprecated" property optionally deprecates a label. Set it to true to deprecate a label and false to preserve it. Deprecating a label is similar to marking a label as deleted. |
Optional with default of false
|
Boolean |
|
description |
The "description" property describes objects such as code packages, labels, or things. The server indexes this field with a full-text index so that you can search for any word or phrase. You cannot use this property for filtering in the Thing API. |
Optional with default of
|
string |
0 to 65,500 bytes 1 to 512 bytes for the Thing API |
enum |
The
|
Optional with default of 0
|
smallint |
-32768 to 32767
|
group |
The The The group name may contain up to 64 bytes of UTF-8 encoded characters. If the When you assign a group name to a label, the server automatically checks if the group name exists in the list of groups that the
|
Optional with default of ""
|
string | 1 to 64 bytes |
id |
The
|
Automatically generated by the server | integer |
|
metadata |
The "metadata" property contains user-defined properties that add keywords and tags about the code package. The server indexes this field with a full-text index so you can search for any word or phrase to find code packages. |
Optional with default of {}
|
object | 0 or more key/value pairs |
name |
The The The
|
Required - No default value | string | 1 to 64 bytes |
value |
The "value" property is used by the server to compare the value assigned to "value" to the appropriate field data in records. |
Required - No default value | string |
|
sequence |
The |
Optional with default of 0
|
double | Any floating point or integer number. |
Response properties ("result")
| Property | Description | Default | Type |
|---|---|---|---|
id |
The |
integer |
|
group |
The The If the When you assign a group name to a label, the server automatically checks whether the group name exists in the list of groups returned by the "listLabelGroups" action. If the group name does not exist, the server adds it to the list. When you rename a group assigned to a label, the server automatically adds a new group name to the list and removes the previous group name if no other label uses it.
|
string | 1 to 64 bytes |
name |
The The The
|
string | 1 to 64 bytes |
value |
The "value" property associates a value with a label. It can be any JSON value that is associated with a label. |
JSON | 0 to 65,500 bytes |
enum |
The
|
smallint | -32768 to 32767 |
sequence |
The |
float | Any floating point or integer number. |
deprecated |
The |
Boolean |
|
description |
The Markdown is a good language for formatting description text. You must ensure the text is compatible with a JSON string. For example, you must escape a double quote character using the backslash character:
In the Thing API, It defaults to
|
string | 1 to 65,500 bytes |
metadata |
The |
JSON | 0 to 65,500 bytes |