Create and update custom labels using Tooling API

GOAL

To be able to create custom label along with translation programmatically.

SOLUTION

We can use tooling API to create the custom label and its translation as below.

The Master label is stored in External String and translation is stored in ExternalStringLocalization

Request to create master label:

Endpoint

/services/data/v51.0/tooling/sobjects/ExternalString

Payload

{
  "Name" : "API_Name_Of_Label",
  "MasterLabel" : "Label of Custom Label",
  "Value" : "Hi, how are you?",
  "IsProtected" : true,
  "Category" : null,
  "Language" : "en_US"
}

Response

{
  "id" : "1012v00000NNo06AAD",
  "success" : true,
  "errors" : [ ],
  "warnings" : [ ],
  "infos" : [ ]
}

We can grab the Id of Master Label and create translation by creating a record in ExternalStringLocalization. Payload would be like this:

{
  "ExternalStringId" : "1012v00000NNo06AAD",
  "Value" : "Salut comment ├ža va?",
  "Language" : "fr"
}

P.S: I came across the requirement to create label using API and did this POC using Workbench and thought to share this.