Contact API

General Information


Requests

Create an API Integration and obtain your apiKey to make requests listed above. Please make sure that the integration is not restricted to access configurations.

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.

HTTP Method URL
POST https://api.opsgenie.com/v2/users/:userIdentifier/contacts

In-Line Parameters

Referred Name Description
userIdentifier Identifier of the user that contact will belong to. This identifier should be either id or username of the user.

JSON Body Fields

Fields Mandatory Description
method true This 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.
to true to 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/user@opsgenie.com/contacts'
    --header 'Authorization: GenieKey 02638d8f-d8fe-4ce3-9428-1e2a6b6425e6'
    --header 'Content-Type: application/json'
    --data
'{
    "method": "email",
    "to": "user@opsgenie.com"
}'
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:

HTTP Method URL
GET https://api.opsgenie.com/v2/users/:userIdentifier/contacts/:contactId

In-Line Parameters

Referred Name Description
userIdentifier Identifier of the user that contact will belong to. This identifier should be either id or username of the user.
contactId Id of the contact.
Sample Request
curl -X GET  'https://api.opsgenie.com/v2/users/user@opsgenie.com/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": "user@opsgenie.com",
        "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.

HTTP Method URL
PATCH https://api.opsgenie.com/v2/users/:userIdentifier/contacts/:contactId

In-Line Parameters

Referred Name Description
userIdentifier Identifier of the user that contact will belong to. This identifier should be either id or username of the user
contactId Id of the contact

JSON Body Fields

Fields Mandatory Description
to true Address of contact method
Sample Request
curl -X PATCH 'https://api.opsgenie.com/v2/users/user@opsgenie.com/contacts/4fb6ad93-ffed-4c04-b62a-f3bfd993fb3d'
    --header 'Authorization: GenieKey 02638d8f-d8fe-4ce3-9428-1e2a6b6425e6'
    --header 'Content-Type: application/json'
    --data'
{
	"to": "user2@opsgenie.com"
}'
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

HTTP Method URL
DELETE https://api.opsgenie.com/v2/users/:userIdentifier/contacts/:contactId

In-Line Parameters

Referred Name Description
userIdentifier Identifier of the user that contact will belong to. This identifier should be either id or username of the user
contactId Id of the contact
Sample Request
curl -X DELETE 'https://api.opsgenie.com/v2/users/user@opsgenie.com/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:

HTTP Method URL
GET https://api.opsgenie.com/v2/users/:userIdentifier/contacts

In-Line Parameters

Referred Name Description
userIdentifier Identifier 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/user@opsgenie.com/contacts'
    --header 'Authorization: GenieKey 02638d8f-d8fe-4ce3-9428-1e2a6b6425e6'
Response:
{
    "data": [
        {
            "id": "b18496d8-bf91-4013-8d23-d16bd4af4eb8",
            "method": "email",
            "to": "user1@opsgenie.com"
            "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

HTTP Method URL
POST https://api.opsgenie.com/v2/users/:userIdentifier/contacts/:contactId/enable

In-Line Parameters

Referred Name Description
userIdentifier Identifier of the user that contact will belong to. This identifier should be either id or username of the user.
contactId Id of the contact.
Sample Request
curl -X POST 'https://api.opsgenie.com/v2/users/user@opsgenie.com/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

HTTP Method URL
POST https://api.opsgenie.com/v2/users/:userIdentifier/contacts/:contactId/disable

In-Line Parameters

Referred Name Description
userIdentifier Identifier of the user that contact will belong to. This identifier should be either id or username of the user
contactId Id of the contact
Sample Request
curl -X POST 'https://api.opsgenie.com/v2/users/user@opsgenie.com/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"
}