sh-3.2# curl --location --request POST 'https://api.opsgenie.com/v2/alerts' \--header 'Authorization: GenieKey 749797a2-8748-484b-8fc5-f48f006bc3f0' \--header 'Content-Type: application/json' \--data-raw ''\''{"message": "Test alert", "description": "This is just a test" }'\'''
{"code":40301,"message":"To perform this action, use an API key from an API integration.","took":0.001,"requestId":"66f7bfee-7f3c-4c65-8bb2-0e95c0c16bd0"}
Hi @premsaisala
Thank you for reaching out! The error message suggests that you may be using an apiKey from Settings > API key management. The apiKey from API key management cannot be used to create an alert.
If there isn't an API integration already created, you would need to add one and use its apiKey to create the alert. If on an Essentials plan, you would create the API integration via Teams > click on a Team > then go to the Integration tab to Add the API integration.
Hope that helps.
Best Regards,
Wei
P/S: suggest removing your apiKey from your curl statement and also from API key management as well since it is "exposed". ;-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.