Skip to main content

"changeLabels" (JSON Action)

Modify sets of labels in bulk

You use "filter" properties to select labels and "new" properties to change values. If you omit a "new" property, such as "newGroup", the action does not change that property. You can also deprecate or permanently delete labels.

  • This action cannot be undone.

    • The response to this action includes a list of labels that were successfully changed by this action.

    • Each object in the list contains the original value of the label before it was changed or deleted.

    • An application can use "alterLabel" to return each label to its original values.

  • If you do not configure the filter properties properly, the action may change more labels than you want.

    Tip

    Use the same filter in "listLabels" to verify the filter returns the labels you expect.

  • FairCom recommends you deprecate a label rather than permanently deleting it.

    • To deprecate a label, set its "deprecate" property to true.

    • When you permanently delete a label, records referencing the deleted label's "id" property will fail to join the label. This will cause referential integrity problems if records reference the label.

      Tip

      Permanently delete a label only when no records reference it.

    • If a label doesn't exist when the server attempts to delete it, the server considers the action a success because the label does not exist. It does not return an error. The server only returns an error when it fails to permanently delete an existing label.

  • If the server cannot process all the requested labels as requested, it returns an error, aborts the transaction, and rolls back all labels back to their previous state. Thus, this action runs in an atomic, all-or-nothing transaction.

The "changeLabels" action modifies labels that match its filter criteria. It uses properties to define the filter. 

The "idFilter" property filters all labels matching the specified "id" values. 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. The filter combines them using a logical AND 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.

Note

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

Request examples

Maximal changing label property values

This example changes labels that match the filters. The filter properties select labels, and the new data properties change values.

{
  "api": "admin",
  "action": "changeLabels",
  "params": {
    "partialGroupFilter": "product/color/",
    "nameFilter": [
      "my label 1",
      "myLabel2",
      "myLabel3"
    ],
    "deprecatedFilter": false,
    "enumFilter": [ 0,"1" ],
    "sequenceFilter": [ 1, 3.2, "4.4" ],

    "newGroup": "product/color/",
    "newValue": 99,
    "newEnum": 1,
    "newSequence": 4.4,
    "newDeprecated": false,
    "newDescription": "My new label description.",
    "newMetadata": {"myKey": "myValue"},

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

This example deletes all labels that match the filter properties.

Note

When "permanentlyDeleteLabels" is true, this action permanently deletes the labels matching your filter requirements. When deleting labels, the server ignores the following properties: "newGroup", "newName", "newValue", "newEnum", "newSequence", "newDeprecated", "newDescription", and "newMetadata".

{
  "api":       "admin",
  "action":    "changeLabels",
  "params":    {
    "permanentlyDeleteLabels": true,
    "idFilter":                [ 1, "2" ],
    "partialGroupFilter":      "product/color/",
    "nameFilter":              [ "my label 1", "myLabel2" ],
    "deprecatedFilter":        false,
    "enumFilter":              [ 0, "1" ],
    "sequenceFilter":          [ 3.2, "4.4" ]
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

This example permanently deletes two labels with "id" values 1 and 2. You can embed an "id" value in a string.

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

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

{
  "api":       "admin",
  "action":    "changeLabels",
  "params":    {
    "permanentlyDeleteLabels": true,
    "partialGroupFilter":      "product/"
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

This example uses a partial group filter to find one or more matching groups. It then deletes 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":    "changeLabels",
  "params":    {
    "permanentlyDeleteLabels": true,
    "partialGroupFilter":      "product/",
    "nameFilter":              [ "my label 1", "myLabel2" ]
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

This example deletes all deprecated labels.

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

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

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

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

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

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

{
  "api":       "admin",
  "action":    "changeLabels",
  "params":    {
    "permanentlyDeleteLabels": true,
    "partialNameFilter": "myNa"
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}
{
  "result": {
    "changedLabels": [
      {
        "id": 1,
        "group": "mylabelGroupName",
        "name": "mylabelName",
        "value": 99,
        "enum": 0,
        "sequence": "3.14",
        "deprecated": false,
        "description": "My label description.",
        "metadata": { "my": "metadata" }
      },
      {
        "id": 2,
        "group": "anotherlabelGroupName",
        "name": "anotherlabelName",
        "value": 99,
        "enum": 0,
        "sequence": null,
        "deprecated": false,
        "description": null,
        "metadata": null
      }
    ]
  },
  "authToken": "authToken",
  "debugInfo": {},
  "errorCode": 0,
  "errorMessage": ""
}
{
  "result": {
    "deletedLabels": [
      {
        "id": 1,
        "group": "mylabelGroupName",
        "name": "mylabelName",
        "value": 99,
        "enum": 0,
        "sequence": "3.14",
        "deprecated": false,
        "description": "My label description.",
        "metadata": { "my": "metadata" }
      },
      {
        "id": 2,
        "group": "anotherlabelGroupName",
        "name": "anotherlabelName",
        "value": 99,
        "enum": 0,
        "sequence": null,
        "deprecated": false,
        "description": null,
        "metadata": null
      }
    ]
  },
  "authToken": "authToken",
  "debugInfo": {},
  "errorCode": 0,
  "errorMessage": ""
}

The "changeLabels" (JSON Action) modifies sets of labels in bulk. It uses filter properties to select labels and data properties to change their values. The action uses filter properties like "idFilter", "partialGroupFilter", "nameFilter", "deprecatedFilter", "enumFilter", and "sequenceFilter" for label selection. It also allows for deprecating or permanently deleting labels.

change labelchangeLabelsJSON Actionlabel APImodify labeldelete labelmodify bulk setsmodify data tagschange data tagsmanage labelslabel managementlabel filteringmodify sets of labels in bulkmodify sets of data tagsupdate sets of data tags
Table 1. changeLabels "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

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

newDeprecated

(optional) updates the "deprecated" property of a label.

null

Boolean

true
false
null

newDescription

(optional) updates the "description" property of a label.

""

string

1 to 65,500 bytes

newEnum

(optional) updates the "enum" property of a label with a new integer value.

null

smallint

-32768 to 32767

newGroup

(optional) provides a new name for renaming a label. The new name must be unique in its group.

null

string

1 to 64 bytes

newMetadata

(optional) updates the "metadata" property of a label.

{}

JSON

0 to 65,500 bytes

newName

(optional) provides a new name for renaming a label. The new name must be unique in its group.

null

string

1 to 64 bytes

newSequence

(optional) updates the "sequence" property of a label.

null

double

Any floating point or integer number

newValue

(optional) updates the "value" property of a label.

null

JSON

0 to 65,500 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.

permanentlyDeleteLabels

(optional) specifies whether to permanently delete a label.

null

Boolean

true
false
null

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 "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 "newDeprecated" property is available in the "changeLabels" action. It optionally updates the "deprecated" property of an existing label. It defaults to null, which means the action does not change the label's deprecated status.

The "newDescription" property is available in the "changeLabels" action. It optionally updates the "description" property of an existing label. It defaults to null, which means the action does not change the label's description.

The "newEnum" property is available in the "changeLabels" action. It optionally updates the "enum" property of an existing label with a new integer value. It defaults to null, which means the action does not change the label's enum value.

The "newGroup" property is available in the "alterLabel" and "changeLabels" action. It optionally assigns a new group name to an existing label. It defaults to null, which means the action does not change the label's group.

The "newMetadata" property is available in the "changeLabels" action. It optionally updates the "metadata" property of an existing label. It defaults to null, which means the action does not change the label's metadata.

The "newName" property is available in the "alterLabel" and "changeLabels" actions. It optionally assigns a new label name to an existing label. It defaults to null, which means the action does not change the label's name.

The "newSequence" property is available in the "changeLabels" action. It optionally updates the "sequence" property of an existing label. It defaults to null, which means the action does not change the label's sequence number.

The "newValue" property is available in the "changeLabels" action. It optionally updates the "value" property of an existing label. It defaults to null, which means the action does not change the label's value.

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 "permanentlyDeleteLabels" property is available in the "changeLabels" action. It optionally specifies for the server to permanently delete the labels specified by the label filter properties. It defaults to null.

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. changeLabels "result" property summaries

Property

Description

Type

Contents

changedLabels

lists each label that was updated with new values.

array of objects

An object for each changed label.

deletedLabels

lists each label that was deleted with its associated values.

array of objects

An object for each deleted label.

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

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 "changedLabels" property lists an object for each label that has been updated with new values. Each object contains the "id", "group", "name", "value", "enum", "sequence", "deprecated", "description", and "metadata" properties and their new values for the label that was updated.

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

The "deletedLabels" property lists an object for each label that has been deleted. Each object contains the "id", "group", "name", "value", "enum", "sequence", "deprecated", "description", and "metadata" properties and their values for the label that was deleted.

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

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