Service API

🚧

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

📘

Service API is only available to Standard and Enterprise plans.

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.

JSON Body Fields

Field

Mandatory

Description

Limit

name

true

Name of the service

100 characters

teamId

false

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

tags

false

Tags of the service.

Maximum number of tags: 20

Sample Request

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",
  "tags": [
    "tag1",
    "tag2"
  ]
}'

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.

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

true

Name of the service.

100 characters

Sample Request

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]",
}'

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.

Sample Request

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

Field

Mandatory

Description

Limit

id

true

Id of the service.

130 characters

Sample 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": [
    {
      "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",
      "tags": [
        "service-tag",
        "service-tag2
      ]
    }
  ],
  "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.

Query Parameters

Field Name

Mandatory

Value Definiton

query

false

Search query to apply while filtering the services.

limit

false

Maximum number of items to provide in the result. Must be a positive integer value. Default value is 20 and maximum value is 100. Minimum value is 1.

sort

false

Name of the field that result set will be sorted by. Default value is name. Possible values are specified below:

  • updatedAt
  • insertedAt
  • createdAt
  • name
  • isExternal

order

false

Sorting order of the result set. Possible values are desc and asc. Default value is desc.

  • desc: Sort result set in descending order
  • asc: Sort result set in ascending order

offset

false

Start index of the result set (to apply pagination). Minimum value (and also default value) is 0.

https://api.opsgenie.com/v1/services?offset=20&limit=20

Sample Requests

curl -X GET 'https://api.opsgenie.com/v1/services'
    -H 'Authorization: GenieKey eb24alp-faa2-4ba2-a551q-1alpf565c889'
    -H 'Content-Type: application/json'
curl -X GET 'https://api.opsgenie.com/v1/services?query=name%3AexampleService&limit=2&sort=name'
    -H 'Authorization: GenieKey eb24alp-faa2-4ba2-a551q-1alpf565c889'
    -H 'Content-Type: application/json'

Response

{
  "data": [{
    "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",
    "tags": [],
    "isExternal": false
  }, {
    "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",
    "tags": [],
    "isExternal": false
  }],
    "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"
  },
  "requestId": "656cfb15-e19f-11e7-ac88-af7c98633ff2"
}

Updated 8 days ago


Service API


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.