Getting started with Opsgenie API
Asked by Sam:

Hi! I'm trying to get familiar with using Opsgenie's APIs ([the alert APIs in particular](https://docs.opsgenie.com/docs/alert-api)), and I haven't been able to get any results at all.

I've tried using Postman to authorize myself using one the API keys found under "Settings" \> "API Key Management", but that just always gets a 401 Unauthorized response.

I've also tried using curl from the command line as shown below:

```
curl -X GET 'https://api.opsgenie.com/v2/alerts/requests/' -H 'Authorization: xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx'
```

But I keep getting results like:

```
curl: (1) Protocol "'https" not supported or disabled in libcurl
curl: (6) Could not resolve host: xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx'
```

When I use "http" instead of "https", I get a similar response.

Do you have any advice for returning some of the alerts used by your Opsgenie instance?

P.S. "eazyBI" is in the tags because I'd eventually want to use eazyBI's REST API feature to pull data from Opsgenie. But for now I'm trying to establish a connection.


Answers:
author: Nick H
body: Hi [@Sam](/t5/user/viewprofilepage/user-id/3690189) ,

You'll want to use the API key from an API integration to complete the Alert API requests.

Under the Standard and Enterprise plans, integrations can be added globally under the Settings tab \>\> Integration list tab.

Or under all plans, integrations can be added under a team's Integrations tab - but will only be able to create alerts for the team it's configured under.

<https://docs.opsgenie.com/docs/api-integration>

![API comm 1.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/125086iBF167BBE50205B9E/image-size/large?v=v2&px=999 "API comm 1.jpg")

Try adding one of these / testing, and let us know if you run into any other questions or issues!

comments: author: Sam
body: Thank you [@Nick H](/t5/user/viewprofilepage/user-id/2540930) , I can now connect to the API!


author: Michael Rogers
body: [@Sam](/t5/user/viewprofilepage/user-id/3690189) [@Nick H](/t5/user/viewprofilepage/user-id/2540930) Would you be able to post a picture of how it looks in postman? I have the API key but am still getting a "Could not authenticate" error. Not sure I have it formatted right.


author: Sam
body: [@Michael Rogers](/t5/user/viewprofilepage/user-id/4219858) Did you put "GenieKey " before the API key? That worked for me.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/125217iCCECF4F2AD73407F/image-size/large?v=v2&px=999 "image.png")


author: Nick H
body: Hi [@Michael Rogers](/t5/user/viewprofilepage/user-id/4219858) ,

Remember the API key (or GenieKey) needed will be from an API integration:

![API comm 4.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/125225i5B5DC09CD29C0268/image-size/large?v=v2&px=999 "API comm 4.jpg")

Below are a few examples of our Alert API and Postman. I used our Alert API doc to grab the body in the request below: <https://docs.opsgenie.com/docs/alert-api#create-alert>

![API comm 2.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/125220iBB8A17ED27393AB0/image-size/large?v=v2&px=999 "API comm 2.jpg")

The only mandatory field is the message. For testing, you could use a body as simple as this:

![API comm 3.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/125221iB5B356F598702D40/image-size/large?v=v2&px=999 "API comm 3.jpg")

Hope this helps! If you continue seeing a "Could not authenticate" error, let us know. Or feel free to share the syntax as well.


Tags: cloud

eazybi