Service Audience Template API

If using the EU instance of Opsgenie, the URL needs to be https://api.eu.opsgenie.com for requests to be successful.

Update Audience Template(Partial)

Update audience template request is used to update the audience template (responder and/or stakeholder) of a service and it is a write request. If the integration of the API key configured as read-only, the request will not be accepted. For more information, you can refer to API Access Management.

Field
Mandatory
Description
Limit

serviceId

true

Id of the service on which audience template will be updated.

130 characters

audienceTemplate

false

Field will be updated.For more information about audience template object click here.

Sample Requests

curl -X PATCH 'https://api.opsgenie.com/v1/services/725fa6c4-ef29-4bda-8172-135135a9e8f3/audience-templates'
    -H 'Authorization: GenieKey eb24alp-faa2-4ba2-a551q-1alpf565c889'
    -H 'Content-Type: application/json'
    -d
'{
	"responder": {
		"individuals": ["22b852e0-cf95-4fe6-927b-ebf221331dc6"],
		"teams": ["dd64998f-80fd-4a1d-9b36-aeb1a86eb0ad"]
	},
	"stakeholder": {
		"individuals": ["22b852e0-cf95-4fe6-927b-ebf221331dc6"],
		"conditionMatchType": "match-any-condition",
		"conditions": [{
			"matchField": "country",
			"value": "canada"
		}, {
			"matchField": "customProperty",
			"key": "country",
			"value": "usa"
		}]
	}
}'

Response:

{
  "result": "Updated",
  "requestId": "29516144-e1a2-11e7-b939-05f0fad0ed41"
}

Get Audience Template

Get audience template request is used to retrieve the audience template of a service

Field
Mandatory
Description
Limit

serviceId

true

Id of the service from which audience template will be retrieved.

130 characters

Request

curl -X GET 'https://api.opsgenie.com/v1/services/23b852C0-cf95-4fe6-927b-ebf221331dc6/audience-templates'
    -H 'Authorization: GenieKey eb24alp-faa2-4ba2-a551q-1alpf565c889'
    -H 'Content-Type: application/json'
https://api.opsgenie.com/v1/services/a418e1de-fa89-48b0-8a83-5e649bc1a1ee/audience-templates

Response

{
  "data": {
    "responder": {
      "teams": [
        "dd64998f-80fd-4a1d-9b36-aeb1a86eb0ad"
      ],
      "individuals": [
        "22b852e0-cf95-4fe6-927b-ebf221331dc6"
      ]
    },
    "stakeholder": {
      "individuals": [
        "22b852e0-cf95-4fe6-927b-ebf221331dc6"
      ],
      "conditionMatchType": "match-any-condition",
      "conditions": [
        {
          "matchField": "country",
          "value": "turkey"
        },
        {
          "matchField": "customProperty",
          "key": "country",
          "value": "turkey"
        }
      ]
    }
  },
  "requestId": "bd0c9c2a-e19b-11e7-8406-4dd3ac13f41e"
}

Audience Template Fields

Field
Mandatory
Description

responder

false

Responder of the audience template. It may contain responder team and user ids.For more information about responder object click here.

stakeholder

false

Stakeholder of the audience template. It may contain pre-defined individuals and match type configuration conditions for rule based notifications.For more information about stakeholder object click here.

Responder Fields

Field
Mandatory
Description
Limit

teams

false

teamId list to be used as responder teams.

50 teams

individuals

false

userId list to be used as responder users.

50 userIds

Stakeholder Fields

Field
Mandatory
Description

individuals

false

userId list to be used as stakeholders.

conditionMatchType

false

Match type for given conditions. Possible values are [match-all-conditions, match-any-condition]. Default value is [match-any-condition].

conditions

false

Condition array which contains match-type conditions.For more information about conditions object click here.

Conditions Fields

Field
Mandatory
Description

matchField

true

field to be matched for users. Possible values are [country, state, city, zipCode, line, tag, customProperty]. customProperty can be used while actionType is keyValue.

key

false

if matchField is customProperty, key must be given.

value

true

value to be check for the match field.

Service Audience Template API


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.