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.

FieldMandatoryDescriptionLimit
serviceIdtrueId of the service on which audience template will be updated.130 characters
audienceTemplatefalseField 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

FieldMandatoryDescriptionLimit
serviceIdtrueId 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

FieldMandatoryDescription
responderfalseResponder of the audience template. It may contain responder team and user ids.For more information about responder object click here.
stakeholderfalseStakeholder 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

FieldMandatoryDescriptionLimit
teamsfalseteamId list to be used as responder teams.50 teams
individualsfalseuserId list to be used as responder users.50 userIds

Stakeholder Fields

FieldMandatoryDescription
individualsfalseuserId list to be used as stakeholders.
conditionMatchTypefalseMatch type for given conditions. Possible values are [match-all-conditions, match-any-condition]. Default value is [match-any-condition].
conditionsfalseCondition array which contains match-type conditions.For more information about conditions object click here.

Conditions Fields

FieldMandatoryDescription
matchFieldtruefield to be matched for users. Possible values are [country, state, city, zipCode, line, tag, customProperty]. customProperty can be used while actionType is keyValue.
keyfalseif matchField is customProperty, key must be given.
valuetruevalue to be check for the match field.