Contact API

🚧

If using the EU instance of Opsgenie, the URL needs to be https://api.eu.opsgenie.com for requests to be successful.

General Information

Create Contact

Creates a contact for the specified user and it is a write request. If the integration of the API key configured as read-only, the request will not be accepted. For more information, you can refer to API Access Management.

🚧

You may need to verify user’s contact number after creating. Learn how to verify contact numbers.

In-Line Parameters

Referred NameDescription
userIdentifierIdentifier of the user that contact will belong to. This identifier should be either id or username of the user.

JSON Body Fields

FieldsMandatoryDescription
methodtrueThis parameter is the contact method of user and should be one of email, sms or voice. Please note that adding mobile is not supported from API.
totrueto field is the address of given method.

🚧

Adding mobile contact is not supported from API.

Sample Requests

curl -X POST  'https://api.opsgenie.com/v2/users/[email protected]/contacts'
    --header 'Authorization: GenieKey 02638d8f-d8fe-4ce3-9428-1e2a6b6425e6'
    --header 'Content-Type: application/json'
    --data
'{
    "method": "email",
    "to": "[email protected]"
}'

Response:

{
    "result": "Created",
    "data": {
        "id": "4fb6ad93-ffed-4c04-b62a-f3bfd993fb3d"
    },
    "took": 1.112,
    "requestId": "b5862ad7-d805-4901-8b6d-2ea75dba0f15"
}

Get Contact

Gets the specified contact of the user. It takes the following parameters:

In-Line Parameters

Referred NameDescription
userIdentifierIdentifier of the user that contact will belong to. This identifier should be either id or username of the user.
contactIdId of the contact.

Sample Request

curl -X GET  'https://api.opsgenie.com/v2/users/[email protected]/contacts/4fb6ad93-ffed-4c04-b62a-f3bfd993fb3d'
    --header 'Authorization: GenieKey 02638d8f-d8fe-4ce3-9428-1e2a6b6425e6'

Response:

{
    "data": {
        "id": "4fb6ad93-ffed-4c04-b62a-f3bfd993fb3d",
        "method": "email",
        "to": "[email protected]",
        "status": {
            "enabled": true
        }
    },
    "took": 0.042,
    "requestId": "03976ff1-81ba-4772-b243-42c776e17fe2"
}

Update Contact (Partial)

Update contact request is used to update contact of the user and it is a write request. If the integration of the API key configured as read-only, the request will not be accepted. For more information, you can refer to API Access Management.

In-Line Parameters

Referred NameDescription
userIdentifierIdentifier of the user that contact will belong to. This identifier should be either id or username of the user
contactIdId of the contact

JSON Body Fields

FieldsMandatoryDescription
totrueAddress of contact method

Sample Request

curl -X PATCH 'https://api.opsgenie.com/v2/users/[email protected]/contacts/4fb6ad93-ffed-4c04-b62a-f3bfd993fb3d'
    --header 'Authorization: GenieKey 02638d8f-d8fe-4ce3-9428-1e2a6b6425e6'
    --header 'Content-Type: application/json'
    --data'
{
	"to": "[email protected]"
}'

Response:

{
    "result": "Updated",
    "data": {
        "id": "4fb6ad93-ffed-4c04-b62a-f3bfd993fb3d"
    },
    "took": 0.417,
    "requestId": "9d8c16ce-b37b-4cb8-bb9d-6c62efa76b98"
}

Delete Contact

Delete contact request is used to delete contact of the user in OpsGenie and it is a write request. If the integration of the API key configured as read-only, the request will not be accepted. For more information, you can refer to API Access Management.

In-Line Parameters

Referred NameDescription
userIdentifierIdentifier of the user that contact will belong to. This identifier should be either id or username of the user
contactIdId of the contact

Sample Request

url -X DELETE 'https://api.opsgenie.com/v2/users/[email protected]/contacts/4fb6ad93-ffed-4c04-b62a-f3bfd993fb3d'
    --header 'Authorization: GenieKey 02638d8f-d8fe-4ce3-9428-1e2a6b6425e6'

Response:

{
    "result": "Deleted",
    "took": 0.229,
    "requestId": "e79e8f79-f786-4cc4-8fdb-412c4425b1ea"
}

List Contacts

List contacts request is used to list contacts of a user in OpsGenie. It takes the following parameters:

In-Line Parameters

Referred NameDescription
userIdentifierIdentifier of the user that contact will belong to. This identifier should be either id or username of the user.

Sample Request

curl -X GET 'https://api.opsgenie.com/v2/users/[email protected]/contacts'
    --header 'Authorization: GenieKey 02638d8f-d8fe-4ce3-9428-1e2a6b6425e6'

Response:

{
    "data": [
        {
            "id": "b18496d8-bf91-4013-8d23-d16bd4af4eb8",
            "method": "email",
            "to": "[email protected]"
            "status": {
                "enabled": true
            },
            "applyOrder": 0
        },
        {
            "id": "8f6eb690-4176-49ca-ad9a-a2dd22b4cfef",
            "method": "sms",
            "to": "1-9999999999",
            "status": {
                "enabled": true
            },
            "applyOrder": 1
        }
    ],
    "took": 0.023,
    "requestId": "793decd9-0b81-4981-bf82-af5a0cdcb06c"
}

Enable Contact

Enable contact request is used to enable contact of the user in OpsGenie and it is a write request. If the integration of the API key configured as read-only, the request will not be accepted. For more information, you can refer to API Access Management.

In-Line Parameters

Referred NameDescription
userIdentifierIdentifier of the user that contact will belong to. This identifier should be either id or username of the user.
contactIdId of the contact.

Sample Request

curl -X POST 'https://api.opsgenie.com/v2/users/[email protected]/contacts/4fb6ad93-ffed-4c04-b62a-f3bfd993fb3d/enable'
    --header 'Authorization: GenieKey 02638d8f-d8fe-4ce3-9428-1e2a6b6425e6'
    --header 'Content-Type: application/json'

Response:

{
    "result": "Enabled",
    "data": {
        "id": "b18496d8-bf91-4013-8d23-d16bd4af4eb8"
    },
    "took": 2.612,
    "requestId": "525e1556-416b-4973-bc1e-dfef68bc09b1"
}

Disable Contact

Disable contact request is used to disable contact of the user in OpsGenie and it is a write request. If the integration of the API key configured as read-only, the request will not be accepted. For more information, you can refer to API Access Management.

userIdentifierIdentifier of the user that contact will belong to. This identifier should be either id or username of the user
contactIdId of the contact

Sample Request

curl -X POST 'https://api.opsgenie.com/v2/users/[email protected]/contacts/4fb6ad93-ffed-4c04-b62a-f3bfd993fb3d/disable'
    --header 'Authorization: GenieKey 02638d8f-d8fe-4ce3-9428-1e2a6b6425e6'
    --header 'Content-Type: application/json'

Response:

{
    "result": "Disabled",
    "data": {
        "id": "b18496d8-bf91-4013-8d23-d16bd4af4eb8"
    },
    "took": 2.612,
    "requestId": "525e1556-416b-4973-bc1e-dfef68bc09b1"
}