Service API
If using the EU instance of Opsgenie, the URL needs to be https://api.eu.opsgenie.com for requests to be successful.
Create Service
Create service request is used to add new services for teams 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 | 
JSON Body Fields
| Field | Mandatory | Description | Limit | 
|---|---|---|---|
| name | true | Name of the service | 100 characters | 
| teamId | true | Team id of the service. | 512 characters | 
| description | false | Description field of the service that is generally used to provide a detailed information about the service. | 10000 characters | 
| visibility | false | Teams and users that the service will become visible to. 
 | 
Sample Requests
curl -X POST 'https://api.opsgenie.com/v1/services'
    -H 'Authorization: GenieKey eb24alp-faa2-4ba2-a551q-1alpf565c889'
    -H 'Content-Type: application/json'
    -d
'{
  "teamId": "eb24alp-faa2-4ba2-a551q-1alpf565c889",
  "name": "Service API Test Service",
  "description": "Service API Test Service Description",
  "visibility": "TEAM_MEMBERS"
}'Response:
{
  "data": {
    "id": "8a2633c8-cd2d-4baa-ba7b-3ef18f854593",
    "name": "Service API Test Service"
  },
  "requestId": "656cfb15-e19f-11e7-ac88-af7c98633ff2"
}Update Service
Update service request is used to update existing services for teams 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 | 
| Field | Mandatory | Description | Limit | 
|---|---|---|---|
| id | true | Service id. | 130 characters | 
| description | false | Description field of the service that is generally used to provide a detailed information about the alert. | 10000 characters | 
| name | false | Name of the service. | 100 characters | 
| Visibility | false | Teams and users that the service will become visible to. - TEAM_MEMBERS would mean that service is visible to only given team members; whereas - OPSGENIE_USERS mean that service is visible to all users of the given customers. | 
Sample Requests
curl -X PATCH 'https://api.opsgenie.com/v1/services/6980c9d2-45ad-4458-9a72-127b87ef881d'
    -H 'Authorization: GenieKey eb24alp-faa2-4ba2-a551q-1alpf565c889'
    -H 'Content-Type: application/json'
    -d
'{
  "name": "Service API Test Service - Updated",
  "description": "Service API Test Service Description [Updated]",
  "visibility": "OPSGENIE_USERS"
}'Response:
{
  "result": "Updated",
  "data": {
    "id": "6980c9d2-45ad-4458-9a72-127b87ef881d",
    "name": "Service API Test Service"
  },
  "requestId": "656cfb15-e19f-11e7-ac88-af7c98633ff2"
}Delete Service
Delete service request is used to delete existing services for teams 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 | 
Sample Requests
curl -X DELETE 'https://api.opsgenie.com/v1/services/6980c9d2-45ad-4458-9a72-127b87ef881d'
    -H 'Authorization: GenieKey eb24alp-faa2-4ba2-a551q-1alpf565c889'
    -H 'Content-Type: application/json'Response:
{
  "result": "Deleted",
  "requestId": "c93ff1c2-e19f-11e7-a9ed-99cc1aa8489f"
}Get Service
Get service request is used to retrieve a service by id
| HTTP Method | URL | 
|---|---|
| GET | 
| Field | Mandatory | Description | Limit | 
|---|---|---|---|
| id | true | Id of the service. | 130 characters | 
Request
curl -X GET 'https://api.opsgenie.com/v1/services/eb24alp-faa2-4ba2-a551q-1alpf565c889'
    -H 'Authorization: GenieKey eb24alp-faa2-4ba2-a551q-1alpf565c889'
    -H 'Content-Type: application/json'Response
{
  "data": [
    {
      "visibility": "OPSGENIE_USERS",
      "teamId": "2e3c4c13-51e7-4cf6-a353-34c6f75494c7",
      "name": "Service API Test Service - Updated",
      "description": "Service API Test Service Description [Updated]",
      "id": "eb24alp-faa2-4ba2-a551q-1alpf565c889"
    }
  ],
  "requestId": "656cfb15-e19f-11e7-ac88-af7c98633ff2"
}List Team/Customer Services
List team/customer services request is used to retrieve a given team/customer's services. If the apiKey is belong to a team, then team services will be retrieved. Otherwise, customer services will be retrieved.
| HTTP Method | URL | 
|---|---|
| GET | 
You can also query by setting offset and limit properties. I.e.
https://api.opsgenie.com/v1/services?offset=20?limit=20curl -X GET 'https://api.opsgenie.com/v1/services'
    -H 'Authorization: GenieKey eb24alp-faa2-4ba2-a551q-1alpf565c889'
    -H 'Content-Type: application/json'Response
{
  "paging": {
    "next": "api.opsgenie.com/v1/services?offset=20?limit=20",
    "first": "api.opsgenie.com/v1/services?offset=0?limit=20",
    "last": "api.opsgenie.com/v1/services?offset=41?limit=20"
  },
  "data": [{
    "visibility": "OPSGENIE_USERS",
    "teamId": "2e3c4c13-51e7-4cf6-a353-34c6f75494c7",
    "name": "Service API Test Service - Updated",
    "description": "Service API Test Service Description [Updated]",
    "id": "6aa85159-9e2e-4e54-8088-546f9c15d513"
  }, {
    "visibility": "OPSGENIE_USERS",
    "teamId": "2e3c4c13-51e7-4cf6-a353-34c6f75494c7",
    "name": "Service API Test Service 2 - Updated",
    "description": "Service API Test Service 2 Description [Updated]",
    "id": "6aa85159-9e2e-4e54-8088-546f9c15d513"
  }],
  "requestId": "656cfb15-e19f-11e7-ac88-af7c98633ff2"
}Updated 5 months ago
