Skip to main content

Field and tag substitution for JSON payloads

This topic describes how webhook endpoints render lists in tags and in fields such as ${service}. Note the following:

  • JSON substitution is aware of both quoted and unquoted strings. This is important for lists or strings that might have implicit quotes.

  • If the value for a substitution is undefined, the syntax for the substitution displays instead of a value.

  • Non-string fields are rendered as strings when you reference a specific tag such as ${tags.Timezone}. If you specify all tags (${tags}), the tags object is rendered as a list of lists, as shown in the last example in the following table.

The following incident field examples assume these field and tag definitions:

{
  ...
   "services": [ "service1", "service2", "service" ],
  ...
    "tags": {
       "domain": [ "abc", "def", "ghi" ],
       "name": ["joe", "bob", "billy" ],
       "timezone" : "CST" 
    }
}
Table 1. Field and tag substitution examples

Original payload in webhook endpoint definition

Result after substitution

{
 ...
   "services": ${services}
 ...
}
{
 ...  
   "services": [ 
       "service1", 
       "service2", 
       "service" 
   ]
 ...
}
{
 ...
   "services": "${services}"
 ...
}
{
 ...
   "services": "["service1", "service2", "service3"]"
 ...
}
{
 ...
   "services": "Here are the services: ${services} as a list"
 ...
}
{
 ...
   "services": "Here are the services: ["service1", "service2", "service3"] as a list"
 ...
}
{
 ...
   "Domain": ${tags.Domain},  
   "name": ${tags.Name},  
   "Timezone": ${tags.Timezone},  
   "Unknown": ${tags.Unknown}
 ...
}
{
 ...
   "Domain": ["abc","def","ghi"],  
   "name": ["joe","bob","billy"],  
   "Timezone": "CST",  
   "Unknown": []
 ...
}
{
 ...
   "Domain": "${tags.domain}",  
   "Name": "${tags.name}",  
   "timezone": "${tags.timezone}",  
   "Unknown": ${tags.Unknown}
 ...
}
{
 ...
   "Domain": "["abc", "def", "ghi"],  
   "name": ["joe", "bob", "billy"],  
   "timezone": ["CST"],  
   "Unknown": []
 ...
}
{
 ...
   "Domain": "Here are the Domain tags: ${tags.Domain}",  
   "Name": "Name tags: ${tags.Name}",  
   "Timezone": "The timezone is ${tags.Timezone}",  
   "Unknown": "The unknown tags: ${tags.Unknown}"
 ...
}
{
 ...
   "Domain": "Here are the Domain tags: ["abc", "def", "ghi"]",  
   "Name": "Name tags: ["joe", "bob", "billy"],  
   "Timezone": "The timezone is ["CST"]",  
   "Unknown": "The unknown tags: "
 ...
}
{
 ...
   "All Tags": ${tags}
 ...
}
{
 ...
   "All Tags": {    
      "Domain": ["abc","def","ghi"],    
      "Name": ["joe","bob","billy"],    
      "Timezone": ["CST"]  
   }
 ...
}