Is there API support use for the OpsGenie free trial version? I have noticed that when I make an API post call to https://api.opsgenie.com/v2/alerts or https://api.eu.opsgenie.com/v2/alerts,
I would get a authentication error using the API key that was used from the OpsGenie UI under Teams -> t$eam_name -> Integrations -> $API_Name.
Hi @Kenny Cho ,
Our API should be supported even on the Free plan. But you need to use the API key from an API integration. It sounds like you are using an API key from the API Key Management tab instead.
Under the Free plan, you need to add integrations from under a team. Once you save an API integration, you should be able to use this as the GenieKey to create alerts:
Hope this helps! Let us know if you have any other questions, issues, etc.
Thanks Nick,
I went to "Teams" -> $team_name -> Integrations -> $API_Name to get the API key so I don't think that is it.
I tried again using this curl command to create the OpsGenie alert but it still gives me an authentication error:
curl --location --request POST 'https://api.opsgenie.com/v2/alerts' \
--header 'Content-Type: application/json' \
--header 'GenieKey: b882d083-ef33-4dad-b31e-003ff61fe539' \
--data-raw '{
"message": "An example alert message",
"alias": "Life is too short for no alias",
"description":"Every alert needs a description",
"responders":[
{"id":"4513b7ea-3b91-438f-b7e4-e3e54af9147c", "type":"team"},
{"name":"NOC", "type":"team"},
{"id":"bb4d9938-c3c2-455d-aaab-727aa701c0d8", "type":"user"},
{"username":"trinity@opsgenie.com", "type":"user"},
{"id":"aee8a0de-c80f-4515-a232-501c0bc9d715", "type":"escalation"},
{"name":"Nightwatch Escalation", "type":"escalation"},
{"id":"80564037-1984-4f38-b98e-8a1f662df552", "type":"schedule"},
{"name":"First Responders Schedule", "type":"schedule"}
],
"visibleTo":[
{"id":"4513b7ea-3b91-438f-b7e4-e3e54af9147c","type":"team"},
{"name":"rocket_team","type":"team"},
{"id":"bb4d9938-c3c2-455d-aaab-727aa701c0d8","type":"user"},
{"username":"trinity@opsgenie.com","type":"user"}
],
"actions": ["Restart", "AnExampleAction"],
"tags": ["OverwriteQuietHours","Critical"],
"details":{"key1":"value1","key2":"value2"},
"entity":"An example entity",
"priority":"P3"
}'
{"message":"Could not authenticate","took":0.0,"requestId":"f75bde16-dbfc-4e2a-9943-6dcca6f951e7"}.
% curl -X GET 'https://api.opsgenie.com/v2/alerts/requests/f75bde16-dbfc-4e2a-9943-6dcca6f951e7'
{"message":"Could not authenticate","took":0.0,"requestId":"149ecb74-debf-4846-9e71-f91fa9784ea9"}%
% curl -X GET 'https://api.opsgenie.com/v2/alerts/requests/f75bde16-dbfc-4e2a-9943-6dcca6f951e7' -H 'Authorization: GenieKey b882d083-ef33-4dad-b31e-003ff61fe539'
{"message":"Request not found. It might not be processed, yet.","took":0.004,"requestId":"1a9794bf-2985-4d4e-8134-48dec34f8264"}
It matches up with the API key from the OpsGenie UP under API integrations:
I'm not sure what I'm doing wrong because everything seems to align here.
Please help.
Thanks,
Kenny
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try something as simple as thing:
curl -X POST https://api.opsgenie.com/v2/alerts -H "Content-Type: application/json" -H "Authorization: GenieKey API_KEY" -d '{"message": "An example alert message"}'
and let us know whether or not that works.
Also, you may want to consider editing your last post and removing your API key so others do not have access to your account. Or you can refresh the API integration's key, save it, and use that new one moving forward.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
^ Note as well, you will want to enter your integration's API key in that curl command where it shows API_KEY.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.