Opsgenie Actions API
Create an API Integration and obtain your apiKey to make requests listed below.
If using the EU instance of Opsgenie, the URL needs to be https://api.eu.opsgenie.com for requests to be successful.
Create Action Channel
HTTP Method | URL |
---|---|
POST |
JSON Body Fields
Field | Mandatory | Description |
---|---|---|
name | true | Name of the channel |
actionType | true | Type of action channel |
awsSmActionChannel | If actionType value is "aws-systems-manager" then true | AWS Systems Manager configurations |
awsSnsActionChannel | If actionType value is "aws-sns" then true | AWS SNS configurations |
restChannel | If actionType value is "rest" then true | RESTful configurations |
awsSmActionChannel
field example:
"awsSmActionChannel" : { "roleName" : "opsgenie-automation-action-cem", "accountId" : "1234567-21325467", "region" : "us-west-2" }
awsSnsActionChannel
field example:
"awsSnsActionChannel": { "topicName" : "example-topic-name", "accountId" : "123", "region" : "eu-central-1" }
restChannel
field example:
"restActionChannel": { "url" : "https://cem.ngrok.io", "headers" : { "test1" : "test2" } }
Sample Request
curl --request POST \ --url 'https://api.opsgenie.com/v1/actions/channels?teamId=40fba2a9-503a-4460-b0e0-7059335d7e68' \ --header 'authorization: GenieKey f9f5b3aa-6822-4391-8b36-ab8847ec58ea' \ --header 'content-type: application/json' \ --data '{ "actionType" : "aws-systems-manager", "name" : "new-test", "awsSmActionChannel": { "roleName" : "opsgenie-automation-action-cem", "accountId" : "123", "region" : "us-west-2" } }'
Sample Response
{ "data": { "id": "4a3c42d8-78c1-4639-8d55-23a68394c151" }, "took": 0.356, "requestId": "e18bc2f2-f0b9-4b84-a4a2-efbca447e5ad" }
RESPONSE CODE: 201
For OEC channel type after Create API call is successful, ApiKey for the OEC channel will become visible on OpsGenie UI underTeams -> Actions -> Action Channels (select your channel)
Update Action Channel
HTTP Method | URL |
---|---|
PATCH or PUT |
Query Parameters
Parameter | Mandatory | Description |
---|---|---|
teamId | true | Team ID who owns the requested channel |
JSON Body Fields
Field | Mandatory | Description |
---|---|---|
name | true | Name of the channel |
awsSmActionChannel | If actionType value was "aws-systems-manager" then true | AWS Systems Manager configurations |
awsSnsActionChannel | If actionType value was "aws-sns" then true | AWS SNS configurations |
restChannel | If actionType value was "rest" then true | RESTful configurations |
Sample Request
curl --request PATCH \ --url 'https://api.opsgenie.com/v1/actions/channels/13683609-1432-4d98-bae0-ffdb6ae4ae0d?teamId=40fba2a9-503a-4460-b0e0-7059335d7e68' \ --header 'authorization: GenieKey f9f5b3aa-6822-4391-8b36-ab8847ec58ea' \ --header 'content-type: application/json' \ --data '{ "name" : "hepbirlikte", "restActionChannel": { "url" : "https://updated-opsgenie.io" } }'
Sample Response
{ "data": { "id": "13683609-1432-4d98-bae0-ffdb6ae4ae0d" }, "took": 0.109, "requestId": "79b6c050-e882-4570-8dcd-74646972b249" }
RESPONSE CODE: 200
Delete Action Channel
HTTP Method | URL |
---|---|
DELETE |
In-Line Parameters
Referred Name | Description |
---|---|
channelId | Channel ID of the requested channel |
Query Parameters
Parameter | Mandatory | Description |
---|---|---|
teamId | true | Team ID who owns the requested channel |
Sample Requests
curl --request DELETE \ --url 'https://api.opsgenie.com/v1/actions/channels/4a3c42d8-78c1-4639-8d55-23a68394c151?teamId=40fba2a9-503a-4460-b0e0-7059335d7e68' \ --header 'authorization: GenieKey f9f5b3aa-6822-4391-8b36-ab8847ec58ea'
Sample Response
{ "data": { "result": "Deleted" }, "took": 0.283, "requestId": "cb133e41-8952-4118-888e-374d927c7895" }
RESPONSE CODE: 200
Get Action Channel
HTTP Method | URL |
---|---|
GET |
In-Line Parameters
Referred Name | Description |
---|---|
channelId | Channel ID of the requested channel |
Query Parameters
Parameter | Mandatory | Description |
---|---|---|
teamId | true | Team ID who owns the requested channel |
Sample Request
curl -X GET -H "Authorization: GenieKey eb243592-faa2-4ba2-a551q-1afdf565c889" 'https://api.opsgenie.com/v1/actions/channels/d903a1dd-8afd-49ba-88f7-34498eb8113c?teamId=f57e4588-0c96-410b-8afa-24b31b117c22'
Sample Response
{ "data": { "id": "13683609-1432-4d98-bae0-ffdb6ae4ae0d", "teamId": "40fba2a9-503a-4460-b0e0-7059335d7e68", "name": "test_1", "actionType": "rest", "restActionChannel": { "url": "https://test.com", "headers": {} } }, "took": 1.886, "requestId": "6d0c548d-f109-458f-a702-184cb38e02c9" }
RESPONSE CODE: 200
List Action Channels
HTTP Method | URL |
---|---|
GET |
Query Parameters
Parameter | Mandatory | Description |
---|---|---|
teamId | true | Getting channels for specified team |
Sample Request
curl -X GET -H "Authorization: GenieKey eb243592-faa2-4ba2-a551q-1afdf565c889" 'https://api.opsgenie.com/v1/actions/channels?teamId=f57e4588-0c96-410b-8afa-24b31b117c22'
Sample Response
{ "data": [ { "id": "13683609-1432-4d98-bae0-ffdb6ae4ae0d", "teamId": "40fba2a9-503a-4460-b0e0-7059335d7e68", "name": "hepbirlikte", "actionType": "rest", "restActionChannel": { "url": "", "headers": {} } }, { "id": "9299521f-11ee-4b1d-93a4-a963b65423c1", "teamId": "40fba2a9-503a-4460-b0e0-7059335d7e68", "name": "", "actionType": "aws-systems-manager", "awsSmActionChannel": { "accountId": "123", "roleName": "opsgenie-automation-action-cem", "region": "us-west-2" } } ], "took": 0.063, "requestId": "38b62f10-ad1f-477c-b895-5dc80cd90429" }
RESPONSE CODE: 200
Create Action
Create Action API only supports Rest and OEC channel types for now.
HTTP Method | URL |
---|---|
POST |
Query Parameters
Parameter | Mandatory | Description |
---|---|---|
teamId | true | Team ID who owns the requested channel |
JSON Body Fields
Field | Mandatory | Description |
---|---|---|
name | true | Name of the action |
channelId | true | Channel ID who owns the requested action |
channelType | true | Channel type who owns the requested action |
state | true | State of being enabled or disabled |
permissions | true | Permissions that specifies to allowed member to perform the action |
parameters | false | |
awsSmDocument | If channelType value is "aws-systems-manager" then true | AWS Systems Manager configurations |
Sample Requests
curl -X POST \ 'https://api.opsgenie.com/v1/actions/actions?teamId=f57e4588-0c96-410b-8afa-24b31b117c22' \ -H 'Authorization: GenieKey eb243592-faa2-4ba2-a551q-1afdf565c889' \ -H 'content-type: application/json' \ -d '{ "name" : "Action2", "channelId": "e72b4966-f5de-4b00-b062f-16c4f300000", "channelType": "rest", "state": { "enabled" : false, "disableReason" : "something went wrong" }, "permissions": { "allTeamMembersAllowed" : true, "allowedMembers" : [ { "username" : "[email protected]" } ], "policiesEnabled" : false }, "parameters" : [ { "name": "parameter123", "description": "this makes difference", "valueType": "string", "required" : "true", "defaultValue" : [ "val1", "val2" ], "parameterType": "prompt-user", "inputType": "free-form", "availableValues" : [ "val1", "val2" ] } ] }'
Sample Response
{ "data": { "name": "Action2", "teamId": "f57e4588-0c96-410b-8afa-24b31b117c22", "channelId": "e72b4966-f5de-4b00-b062f-16c4f300000", "channelType": "rest", "state": { "enabled": false, "disableReason": "something went wrong" }, "permissions": { "allTeamMembersAllowed": true, "allowedMembers": [ { "username": "[email protected]", "id": "80ab38b5-4434-4a17-9092c-14974b00000" } ], "policiesEnabled": false }, "parameters": [ { "name": "parameter123", "description": "this makes difference", "valueType": "string", "required": true, "defaultValue": [], "parameterType": "prompt-user", "inputType": "free-form", "availableValues": [ "val2", "val1" ] } ] }, "took": 0.385, "requestId": "6aad4cde-9e9a-4ce8-acf50-f3074500000" }
RESPONSE CODE: 201
Update Action
Update Action API only supports Rest and OEC channel types for now.
HTTP Method | URL |
---|---|
PATCH or PUT |
In-Line Parameters
Referred Name | Description |
---|---|
actionName | Action name of the requested action. |
Query Parameters
Parameter | Mandatory | Description |
---|---|---|
teamId | true | Team ID who owns the requested channel |
Updates are applied as partially, so only altered fields are sufficient to update according to the fields inCreate Action
section.
Sample Request
curl -X PUT \ 'https://api.opsgenie.com/v1/actions/actions/Action2?teamId=f57e4588-0c96-410b-8afa-24b31b117c22' \ -H 'Authorization: GenieKey eb243592-faa2-4ba2-a551q-1afdf565c889' \ -H 'content-type: application/json' \ -d '{ "name" : "Updated-Action2", "channelType": "oec", "permissions": { "allTeamMembersAllowed" : false, "allowedMembers" : [ { "username" : "[email protected]" }, { "id" : "80ab38b5-4434-4a17-9092c-14974b00000" } ] } }'
Sample Response
{ "data": { "name": "Updated-Action2", "channelId": "e72b4966-f5de-4b00-b062f-16c4f300000", "channelType": "oec", "state": { "enabled": false, "disableReason": "something went wrong" }, "permissions": { "allTeamMembersAllowed": false, "allowedMembers": [ { "username": "[email protected]", "id": "80ab38b5-4434-4a17-9092c-14974b00001" }, { "username": "[email protected]", "id": "80ab38b5-4434-4a17-9092c-14974b00000" } ], "policiesEnabled": false }, "parameters": [ { "name": "parameter123", "description": "this makes difference", "valueType": "string", "required": true, "defaultValue": [], "parameterType": "prompt-user", "inputType": "free-form", "availableValues": [ "val2", "val1" ] } ] }, "took": 0.546, "requestId": "d0e1130f-1326-4cd9-81f51-4bf28400000" }
RESPONSE CODE: 200
Delete Action
HTTP Method | URL |
---|---|
DELETE |
In-Line Parameters
Referred Name | Description |
---|---|
actionName | Action name of the requested action. |
Query Parameters
Parameter | Mandatory | Description |
---|---|---|
teamId | true | Team ID who owns the requested channel |
Sample Request
curl -X DELETE \ 'https://api.opsgenie.com/v1/actions/actions/Action2?teamId=f57e4588-0c96-410b-8afa-24b31b117c22' \ -H 'Authorization: GenieKey eb243592-faa2-4ba2-a551q-1afdf565c889'
Sample Response
{ "result": "Deleted", "took": 0.476, "requestId": "1c99bc61-3414-4b29-a18a7-373c9300000" }
RESPONSE CODE: 200
Get Action
HTTP Method | URL |
---|---|
GET |
In-Line Parameters
Referred Name | Description |
---|---|
actionName | Action name of the requested action. |
Query Parameters
Parameter | Mandatory | Description |
---|---|---|
teamId | true | Team ID who owns the requested action |
Sample Request
curl -X GET \ 'https://api.opsgenie.com/v1/actions/actions/Action1?teamId=f57e4588-0c96-410b-8afa-24b31b117c22' \ -H 'Authorization: GenieKey eb243592-faa2-4ba2-a551q-1afdf565c889'
Sample Response
{ "data": { "name": "Action1", "teamId": "f57e4588-0c96-410b-8afa-24b31b117c22", "channelId": "e72b4966-f5de-4b00-b062f-16c4f300000", "channelType": "rest", "state": { "enabled": true, "disableReason": "" }, "permissions": { "allTeamMembersAllowed": false, "allowedMembers": [ { "username": "[email protected]", "id": "2065a58b-61f8-44e3-b7fd-efc4d7500000" } ], "policiesEnabled": true }, "parameters": [] }, "took": 1.749, "requestId": "7e08524c-3efb-45ef-a5a35-12c8fe00000" }
RESPONSE CODE: 200
List Action
HTTP Method | URL |
---|---|
GET |
Query Parameters
Parameter | Mandatory | Description |
---|---|---|
teamId | true | Team ID who owns the requested action |
Sample Request
curl -X GET \ 'https://api.opsgenie.com/v1/actions/actions?teamId=f57e4588-0c96-410b-8afa-24b31b117c22' \ -H 'Authorization: GenieKey eb243592-faa2-4ba2-a551q-1afdf565c889'
Sample Response
{ "data": [ { "name": "Action1", "channelId": "e72b4966-f5de-4b00-b062f-16c4f300000", "channelType": "rest", "state": { "enabled": true, "disableReason": "" } }, { "name": "Action2", "channelId": "e72b4966-f5de-4b00-b062f-16c4f300000", "channelType": "rest", "state": { "enabled": true, "disableReason": "" } } ], "took": 2.241, "requestId": "2e0a501d-530d-4b41-89e66-5a366e00000" }
RESPONSE CODE: 200
Execute Action
HTTP Method | URL |
---|---|
POST | https://api.opsgenie.com/v1/actions/actions/executions/:actionName |
In-line Parameters
Parameter | Mandatory | Description |
---|---|---|
actionName | true | The name of Opsgenie action |
JSON Body Fields
Parameter | Mandatory | Description |
---|---|---|
identifier | true | Identifier id of entity(alert or incident) |
type | true | Type of entity. It can be alert or incident. You can refer below for example values. |
ownerTeam | true | Owner team of entity. Either name or id should be provided. |
parameters | false | Parameter fields are mandatory for only defined as prompted-user and required fields. name, valueType and values fields are mandatory for each item. You can refer below for example values. |
Sample Request
curl -X POST \ 'https://api.opsgenie.com/v1/actions/actions/executions/post-to-rest-endpoint' \ -H 'Authorization: GenieKey fe8b5cec-2e53-4d94-86fc-fcdea7f06bd5' \ -H 'Cache-Control: no-cache' \ -H 'Content-Type: application/json' \ -d '{ "identifier":"f16dfd3a-f5ba-454b-8da4-1b0f32c45ed2-1590670606997", "type": "alert", "ownerTeam":{ "id":"e5f85ef7-3bd3-4c32-9d69-dcaf20079d0e", "name":"teamName" }, "parameters":[ { "name":"testValue", "valueType": "boolean", "values":["true"] }] }'
curl -X POST \ 'https://api.opsgenie.com/v1/actions/actions/executions/startInstanceEx1' \ -H 'Authorization: GenieKey 2asdlkf2b-516d-asd2-a0f7-83e234ee82d8' \ -H 'Cache-Control: no-cache' \ -H 'Content-Type: application/json' \ -d '{ "identifier":"0asdkke-6ca2-234n-lkas-cb2f23hdns4f-155las1232472", "type": "alert", "ownerTeam":{ "id":"e5f85ef7-3bd3-4c32-9d69-dcaf20079d0e", "name":"teamName" }, "parameters":[ { "name":"InstanceId", "valueType": "string-list", "values":["i-019d86dcb5ac833ab"] }] }'
Sample Response
{ "data": { "message": "Request will be processed" }, "took": 1.824, "requestId": "763f9d3e-0e95-4b49-8cc5-587ca9591879" }
Get Execution Request Status
HTTP Method | URL |
---|---|
GET | https://api.opsgenie.com/v1/actions/actions/executions/:requestId |
In-line Parameters
Parameter | Mandatory | Description |
---|---|---|
requestId | true | Universally unique identifier of the tracked request. Please note: that ID of the request was provided within execution action response. |
Sample Request
curl -X GET 'https://api.opsgenie.com/v1/actions/actions/executions/9ans345370-d120-498c-laks1-66dlajsd20d3' \ -H 'Authorization: GenieKey fe8b5cec-2e53-4d94-86fc-fcdea7f06bd5' \ -H 'Content-Type: application/json'
Sample Response
{ "data": { "requestId": "1885e8ab-e227-4874-8af6-71cf39114a31", "opsgenieEntity": { "id": "f16dfd3a-f5ba-454b-8da4-1b0f32c45ed2-1590670606997", "type": "alert" }, "actionName": "post-to-rest-endpoint", "success": true, "result": "Successfully processed action: ActionExecutionState{actionType='rest', state=finished}" }, "took": 1.393, "requestId": "b1f69f62-7961-4022-99b9-71c24cda462c" }
Updated 4 months ago