Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

API authentication for create alerts Edited

I am new to Opsgenie, trying to create alerts through calling Rest API in my own java application



The request simply included the parameters "message" and "alias", but get an return of error code 40301


Checked / Tried:

1. The API key used is new created. Can be found under Teams => Integrations, in the Opsgenie web page. Also the team is a new team.

2. Can get the list and details of existing alerts through Alert APIs using the same API Key. The existing alerts are created through Opsgenie web page, selected the same integration in "API integration" field

3. Checked the API integration is "true" in "allowConfigurationAccess", "allowDeleteAccess", "allowReadAccess", and "allowWriteAccess" through Integration APIs

4. Tried changing the path to in case I am using EU instance. It returns "Could not authenticate" so I don't think I am using the EU instance.


May someone kindly tell what is missing in my case?


Checked on the header "Authorization" and payload.
Here is my testing curl command:

curl -X POST -H "Content-Type: application/json" -H "Authorization: GenieKey MyApiKey" -d '{"message": "An example alert message", "alias": "Life is too short for no alias", "description":"Every alert needs a description", "responders":[{"id":"MyTeamId","type":"team"}],"visibleTo":[{"id":"MyTeamId","type":"team"}],"priority":"P4"}'

And the response I got

{"code":40301,"message":"To perform this action, use an API key from an API integration.","took":0.009,"requestId":"7f74b148-94b5-4352-be0f-a50ed381a842"}


1 answer

If you are sending to create alerts

You want to POST @

As a header you want to make sure you have:
"Authorization": "GenieKey yourapikeyorvariablesubstituted"

"Authorization": "GenieKey ${APIKEY}"

Make sure your payload is right: 

JSON example:

"message": "My Alert",

"description": "My Amazing Description",

"details": {

"YourKey1": "YourValue1",

"YourKey2": "YourValue2",

"ETC": "ETC"



You are going to have to break out everything nested in advance and map like the above. I've never been able to get anything else to work. There seems to be a fail-all instead of any sanitization/stringify within opsgenie's api.

Hope this helps EU friends! 

I have checked on the points you mentioned and I think I my request is valid.
Updated my question to include my request and the response I get.

Try removing the message altogether and just focus on the GET to the same endpoint. Can you get a valid response?

If not, I would check your stored variable(MYAPIKEY) for any ' or " and remove them. Just guessing, its a charactering that is breaking the JSON structure at the api key. 

The following works for me -> 
curl -X GET "" -H "Authorization: GenieKey $MYAPIKEY"

Variable is Stored as MYAPIKEY=1234567890

If you get this far, switch your request to POST, add -H "Content-Type: application/json" and your body with { "message": "Test Message", "description": "Test Description" }

If your still getting the green light, add in your normal messages and descriptions from your workflow and continue down one-by-one until you've got the exact message you desire. 

That's the point no. 2 of what I have tried. Can get the list and details of existing alerts through GET request. But it gives error response when I want to create alert through POST request.

curl -X GET -H "Authorization: GenieKey MyApiKey"

{"data":[{"seen":true,"id":"RandomId","tinyId":"1","alias":"MyAlias","message":"This is a test alert. Manually typed.","status":"closed","acknowledged":true,"isSeen":true,"tags":[],"snoozed":false,"count":1,"lastOccurredAt":"2020-09-03T08:56:39.322Z","createdAt":"2020-09-03T08:56:39.322Z","updatedAt":"2020-09-03T09:16:47.838Z","source":"","owner":"","priority":"P1","teams":[{"id":"MyTeamId"}],"responders":[{"type":"team","id":"MyTeamId"}],"integration":{"id":"MyApiIntegrationId","name":"MyApiName","type":"API"},"report":{"ackTime":1205489,"closeTime":1208516,"acknowledgedBy":"","closedBy":""},"ownerTeamId":"MyTeamId"}],"paging":{"next":"","first":"","last":""},"took":0.044,"requestId":"774310b3-9dcd-451c-9fe6-ccbe2d2a20ff"}
curl -X POST -H "Content-Type: application/json" -H "Authorization: GenieKey MyApiKey" -d '{"message": "Test Message", "description": "Test Description" }'

{"code":40301,"message":"To perform this action, use an API key from an API integration.","took":0.01,"requestId":"fdee5a42-9162-4474-93ed-95198ca99065"}

To clarify, should you be using the EU API subdomain?

No. Since I do not know which instance I am actually using, I tried on both normal and EU API (as stated in pt.4 in the tried action list).
And I got "Could not authenticate" response when using EU subdomain. So I don't think I should use EU API subdomain.

Trials in using EU subdomain:

curl -X GET -H "Authorization: GenieKey MyApiKey"

{"message":"Could not authenticate","took":0.0,"requestId":"1ef45d44-cc3d-4e8c-bcc0-6aab152df4f1"}
curl -X POST -H "Content-Type: application/json" -H "Authorization: GenieKey MyApiKey" -d '{"message": "Test Message", "description": "Test Description" }'

{"message":"Could not authenticate","took":0.007,"requestId":"781506fd-22fb-467d-b783-de275009ba77"} 

Hi @beta.lam ,

If your account is an EU instance, the account URL would be something like - otherwise US instances have the URL as

Nick H Atlassian Team Sep 16, 2020

Also like one of those errors indicates:


{"code":40301,"message":"To perform this action, use an API key from an API integration.","took":0.01,"requestId":"fdee5a42-9162-4474-93ed-95198ca99065"}
The Alert API (specifically the Create Alert API request) requires the API key to be from an API Integration. We recommend using a global API integration - meaning it is assigned to [No Team], and has these permissions:
Nick H Atlassian Team Sep 16, 2020

And since it look like your request was successful with a GET request using


your account is a US instance.

Hi, all.


I'm having the exact same problem.

Is this problem solved?


Thanks in advance.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Opsgenie

New GitLab integration in Incident Investigation view

We launched the first version of the Incident investigation view in April of 2020 for Bitbucket Pipelines. Shortly after that, we added the ability to investigate deployment-related incidents in Opsg...

325 views 0 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you