Skip to main content

"listLabels" (JSON Action)

Retrieve a filtered list of label names

If you provide no filtering criteria, the server returns all labels.

The "idFilter" property filters all labels matching the specified "id" values. When using the "idFilter" property, the action returns an error if you include other filter properties.

The remaining filter properties work together to filter labels. Each is optional and does not filter labels when omitted or set to null. Each filter property is combined with the other filter properties using a logical AND operation. The values within the array of a filter property are combined using an OR operation.

  • "groupFilter" includes labels that match one group in the specified list.

  • "partialGroupFilter" includes labels that match the specified partial group names.

  • "nameFilter" includes labels that match the specified label names.

  • "partialnameFilter" includes labels that match a partial label name.

  • "deprecatedFilter" includes labels that are deprecated or not.

  • "enumFilter" includes labels that have the specified "enum" values.

  • "sequenceFilter" includes labels that have the specified sequence values.

The "includeDescription" and "includeMetadata" are set to true to include these properties in the results.

Note

The "groupFilter" and "partialGroupFilter" properties are mutually exclusive, and the "nameFilter" and "partialNameFilter" properties are mutually exclusive.

Request examples

Minimal

This example returns all labels.

{
  "api":       "admin",
  "action":    "listLabels",
  "params":    { },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

This example returns all labels that match the filters. 

{
  "api":        "admin",
  "action":     "listLabels",
  "params":     {
    "partialGroupFilter": "product/color/",
    "nameFilter":         [ "my label 1", "myLabel2" ],

    "deprecatedFilter":   false,
    "enumFilter":         [ 0, "1" ],
    "sequenceFilter":     [ 3.2, "4.4" ],

    "includeDescription": true,
    "includeMetadata":    true
  },
  "authToken":  "replaceWithAuthTokenFromCreateSession",
  "apiVersion": "1.0",
  "requestId":  "2",
  "debug":      "none"
}

This example returns all labels.

{
  "api":       "admin",
  "action":    "listLabels",
  "params":    { },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

This example returns two labels with "id" values 1 and 2. Notice how you can embed an "id" value in a string.

{
  "api":       "admin",
  "action":    "listLabels",
  "params":    {
    "idFilter": [ 1, "2" ]
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

This example uses a partial group filter to find one or more matching groups. It returns all labels in those groups.

{
  "api":       "admin",
  "action":    "listLabels",
  "params":    {
    "partialGroupFilter": "product/"
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

This example uses a partial group filter to find one or more matching groups. It returns all labels in those groups that exactly match the two specified label names. Different groups may have labels with the same name.

{
  "api":       "admin",
  "action":    "listLabels",
  "params":    {
    "partialGroupFilter": "product/",
    "nameFilter":         [ "my label 1", "myLabel2" ]
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

This example returns all deprecated labels.

{
  "api":       "admin",
  "action":    "listLabels",
  "params":    {
    "deprecatedFilter": true
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

This example uses a group filter to list all labels with the matching groups.

{
  "api":       "admin",
  "action":    "listLabels",
  "params":    {
    "groupFilter": [ "myGroup1", "myGroup2", "" ]
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

This example uses a group filter to list all labels with the matching groups.

{
  "api":       "admin",
  "action":    "listLabels",
  "params":    {
    "groupFilter": [ "myGroup1", "myGroup2" ],
    "partialNameFilter": "myNa"
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

This example uses a partial name filter to list labels with matching names. The labels may be part of any group.

{
  "api":       "admin",
  "action":    "listLabels",
  "params":    {
    "partialNameFilter": "myNa"
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

Maximal

{
  "result": {
    "labels": []
  },
  "requestId": "2",
  "debugInfo": {
    "request": {
      "authToken": "authToken",
      "api": "admin",
      "action": "listLabels",
      "params": {
        "partialGroupFilter": "product/color/",
        "nameFilter": [
          "my label 1",
          "myLabel2"
        ],
        "deprecatedFilter": false,
        "enumFilter": [
          0,
          "1"
        ],
        "sequenceFilter": [
          3.2,
          "4.4"
        ],
        "includeDescription": true,
        "includeMetadata": true
      },
      "apiVersion": "1.0",
      "requestId": "2",
      "debug": "max"
    }
  },
  "authToken": "authToken",
  "errorCode": 0,
  "errorMessage": ""
}

The "listLabels" action retrieves a filtered list of label names. If no filtering criteria are provided, it returns all labels.

list labelslistLabelslabel APIJSON Actionlist data tagsretrieve label namesfilter labelslabel managementget label namesget labels
Table 1. listLabels "params" property summaries

Property

Description

Default

Type

Limits (inclusive)

deprecatedFilter

(optional) includes deprecated labels when true.

false

Boolean

true
false
null

enumFilter

(optional) is an array of enum integers that specifies which labels to list or change.

[]

array of smallints

Each array item is an integer from -32768 to 32767

groupFilter

(optional) is an array of groups that specifies which labels to list or change.

[]

array of strings

1 or more strings, each up to 64 bytes long.

idFilter

(optional) is an array of IDs that specifies which labels to list or change.

[]

array of integers

Each array item is an integer from 0 to 2147483647

includeDescription

(optional) specifies whether to include the "description" property in the response.

true

Boolean

true
false
null

includeMetadata

(optional) specifies whether to include the "metadata" property in the response.

true

Boolean

true
false
null

nameFilter

(optional) is an array of label names that specifies which labels to list or change.

[]

array of strings

Each array item is a label string from 1 to 64 bytes

partialGroupFilter

(optional) is a partial or complete group name that specifies which labels to list or change.

""

string

1 to 64 bytes

partialNameFilter

(optional) is a partial or complete label name that specifies which labels to list or change.

null

array of strings

1 or more strings, each up to 64 bytes long.

sequenceFilter

(optional) is an array of sequence numbers that specifies which labels to list or change.

[]

array of doubles

Each array item is a floating point or integer number



The "deprecatedFilter" property optionally filters the results of the "listLabels" and "changeLabels" actions. It defaults to null, to include deprecated and non-deprecated labels; in other words, a value of null provides no filtering. Set it to true to include only deprecated labels and false to include only non-deprecated labels.

The "enumFilter" property optionally filters the results of the "listLabels" and "changeLabels" actions. It defaults to null, which provides no filtering. It is an array of integers with values from -32768 to 32767. The "enum" property of a label must match one of the integers in the array to be included in the results.

The "groupFilter" property optionally filters the results of the "listLabels" and "changeLabels" actions. It defaults to null, which provides no filtering. It is an array of strings, such as "groupFilter": [ "myGroup1", "myGroup2", "" ]. Each string is the name of a group and may be up to 64 bytes long. A label's group must match one of the groups in the array to be included in the results. The empty string "" is a valid group name.

Note

The "groupFilter" and "partialGroupFilter" properties are mutually exclusive.

This example uses a group filter to list all labels with the matching groups.

{
  "api":       "admin",
  "action":    "listLabels",
  "params":    {
    "groupFilter": [ "myGroup1", "myGroup2", "" ]
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

This example uses a group filter to list all labels with the matching groups.

{
  "api":       "admin",
  "action":    "listLabels",
  "params":    {
    "groupFilter": [ "myGroup1", "myGroup2" ],
    "partialNameFilter": "myNa"
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

The "idFilter" property optionally filters the results of the "listLabels" and "changeLabels" actions. It defaults to [], which provides no filtering. It is an array of integers with values from 0 to 2147483647. The "id" property of a label must match one of the integers in the array to be included in the results.

The "idFilter" property is mutually exclusive to the other filter properties. The "listLabels" action returns an error when it is used with other filter properties.

The "includeDescription" property is an optional Boolean that specifies whether to include the "description" property in the response. It defaults to true.

The "includeMetadata" property is an optional Boolean that specifies whether to include the "metadata" property in the response. It defaults to true.

The "nameFilter" property optionally filters the results of the "listLabels" and "changeLabels" actions. It defaults to null, which provides no filtering. It is an array of strings, such as "nameFilter": [ "myName1", "myName2" ]. Each string is the name of a label and may be up to 64 bytes long. A label's name must match one of the names in the array to be included in the results.

Note

The "nameFilter" and "partialNameFilter" properties are mutually exclusive.

The "partialGroupFilter" property optionally filters the results of the "listLabels" and "changeLabels" actions. It defaults to null, which provides no filtering. It is a string, such as "partialGroupFilter": "myGr". The string is the partial or full name of a group and may be up to 64 bytes long. A label's group must match the partial or complete value of this property to be included in the results. The empty string "" and null match all groups.

Note

The "groupFilter" and "partialGroupFilter" properties are mutually exclusive.

Warning

When deleting properties, ensure each partial and full group name in the array properly filters the labels; otherwise, the "changeLabels" action will delete more labels than you want.

The "partialNameFilter" property optionally filters the results of the "listLabels" and "changeLabels" actions. It defaults to null, which provides no filtering. It is an array of strings, such as "partialNameFilter": "myNa". Each string is the partial or full name and may be up to 64 bytes long. A label's name must partially match this value to be included in the results. The empty string "" and null match all groups.

Note

The "nameFilter" and "partialNameFilter" properties are mutually exclusive.

Warning

When deleting properties, ensure the partial name properly filters the labels; otherwise, the "changeLabels" action may delete more or fewer labels than you want.

This example uses a group filter to list all labels with the matching groups.

{
  "api":       "admin",
  "action":    "listLabels",
  "params":    {
    "groupFilter": [ "myGroup1", "myGroup2", "" ],
    "partialNameFilter": "myNa"
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

This example uses a partial name filter to list labels with matching names. The labels may be part of any group.

{
  "api":       "admin",
  "action":    "listLabels",
  "params":    {
    "partialNameFilter": "myNa"
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

The "sequenceFilter" property optionally filters the results of the "listLabels" and "changeLabels" actions. It defaults to [], which provides no filtering. It is an array of doubles. The "sequence" property of a label must match one of the doubles in the array to be included in the results.

Table 2. listLabels "result" property summaries

Property

Description

Type

Contents

deprecated

specifies whether a label is deprecated or not.

Boolean

true
false
null

description

describes a label.

string

1 to 65,500 bytes

enum

assigns an integer number to a label.

smallint

-32768 to 32767

group

assigns a group to a label to create named lookup lists and tag sets.

string

1 to 64 bytes

id

uniquely identifies each label.

integer

0 to 2147483647

labels

lists all labels that match the set filters.

array of objects

Contains an object for each label matching the set filters.

metadata

assigns metadata to a label.

JSON

0 to 65,500 bytes

name

names a label. The name must be unique in its group.

string

1 to 64 bytes

sequence

specifies the numerical order of labels within a group.

float

Any floating point or integer number.

value

assigns a value to a label.

JSON

0 to 65,500 bytes



The "deprecated" property optionally deprecates a label. Set it to true to deprecate a label and false to preserve it. It defaults to false. Deprecating a label is similar to marking a label as deleted.

The "description" property optionally provides additional information about a label. You can use it as internal or external documentation about the meaning, purpose, and usage of a label.

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:  \".

The "enum" property optionally assigns an integer from -32768 to 32767 to a label. By default, this property is set to 0. You can use this property to assign an application's hardcoded enumerated value to a label.

The "group" property optionally groups labels into a lookup list or tag set. It is an optional namespace for a set of labels that identifies their purpose. You can use the "listLabelGroups" action to return the list groups. You can use the "listLabels" action to return labels in one or more groups. 

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.

The group name may contain up to 64 bytes of UTF-8 encoded characters.

If the "group" property is omitted when creating a label, the group defaults to the empty string, "", which is the catch-all group.

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 "listLabelGroups" action returns. If the group name does not exist, the server adds the group name 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.

Tip

If your application creates many groups, you can use a delimiter character, such as the forward slash / in your group names to create a group hierarchy. Include the delimiter after each part of the hierarchy and at the end of the group name. In the "listLabels" action, you can use the "partialGroupFilter" filter to return subsets of groups in the hierarchy. For example, you if have groups named "product/size/", "product/weight/", "product/ranking/", "person/gender/", and "person/ranking/", you can set the "partialGroupFilter" to "product/" to return the product groups.

The "id" property is the unique identifier of a label. In JSON, you may use an integer number or a string containing an integer number. The server automatically generates the "id" when you create a label and stores it in the label table as an integer. You cannot alter the "id" value. If your application needs to specify a specific numeric identifier for a label, use the "enum" property.

The "labels" property lists all labels that match the filters set by the "listLabels" request.

    "labels": [
      {
        "id": 6,
        "group": "myLabelGroup",
        "name": "myLabelName",
        "value": 99,
        "enum": 0,
        "sequence": 1.2,
        "deprecated": false,
        "description": "My label description.",
        "metadata": {}
      },
    ]

The "metadata" field optionally allows a customer to add a JSON value to the label. It is typically a JSON object, but may be any JSON value. It defaults to null. Its purpose is to provide additional metadata about the label, such as translations in multiple languages, historical value changes, etc. The "alterLabel" action can only replace this value with a new JSON value.

The "name" property is the name of a label. It is a required UTF-8 string that is up to 64 bytes long.

The "group" and "name" properties combined uniquely identify each label. The "createLabel" and "alterLabel" actions return an error if the "group" and "name" properties do not create a unique label name.

The "id" property also uniquely identifies each label so you can rename a label's group and name without breaking "id" references to the label.

The "sequence" property optionally assigns an order to the labels in a group. You can use a floating point or integer number. You may embed the number in a JSON string. It defines the order of labels in a group. It is a floating point number to make it easy to change label order without renumbering all labels in a group. For example, to move a label in between two other labels, you can assign a fractional number to the label that is in between the sequence numbers of two other labels.

The "value" property associates a value with a label. It is an optional JSON value that is associated with a label. It can be any JSON value. It defaults to null

When you use the "alterLabel" action to update the "value" property, it replaces "value" with an entirely new value. It cannot replace parts of the JSON value.