SG Services API
The SG Services API provides endpoints to create and manage application services and the upstream relationships between them.
Request apps on the Store
Visit the ServiceNow Store website to view all the available apps and for information about submitting requests to the store. For cumulative release notes information for all released apps, see the ServiceNow Store release notes.
This API can only be used when the CMDB Application API and CLI (sn_service_graph) plugin is activated. This API is used within the sn_service_graph namespace.
Using this API does not require details regarding source tables or relationship types.
To script critical operations which support automation across the enterprise, you can leverage APIs or run command line operations that the CMDB Application CLI and API store app provide instead of using the user interface. The CMDB Application CLI and API store app provides a robust framework which consolidates all the APIs that are related to application services and the command lines that let you access the interface to those APIs.
CMDB Application CLI and API commands enable the following tasks:
- Registering and creating an application service and establishing upstream relationships
- Getting details of a given application service and its upstream relationships
- Connecting higher level constructs such as business applications and business service offerings
- Populating an application service with a given population type
- Changing the state of an application service
For the command line solution, see CMDB Application CLI and API available commands.
Parent Topic:REST API reference
SG Services – POST /sg_services/app_service/convert
Converts a manual or empty type application service to a calculated application service. During conversion, the application service record moves into the [cmdb_ci_service_calculated] table with the newly assigned class.
The following properties for identifying a CI take precedence as follows:
- sys_id – If sys_id, the system only uses the sys_id and ignores any additional values.
- number – If provided without the sys_id, the system only uses the number and ignores any additional values.
- <IRE field name> – The system only uses these values if the sys_id or number are not provided.
URL format
Versioned URL: /api/sn_service_graph/{api_version}/sg_services/app_service/convert
Default URL: /api/sn_service_graph/sg_services/app_service/convert
Note: Available versions are specified in the REST API Explorer. For scripted REST APIs there is additional version information on the Scripted REST Service form.
Supported request parameters
| Name | Description |
|---|---|
| api\_version | Optional. Version of the endpoint to access. For example, `v1` or `v2`. Only specify this value to use an endpoint version other than the latest. Data type: String |
| Name | Description |
|---|---|
| None |
| Name | Description |
|---|---|
| <IRE field name> | One or more IRE fields identifying the application service. For example, name or version. Data type: String |
| levels | Number of levels to include in the conversion.Data type: String |
| number | Unique number that identifies the application service. Data type: String |
| sys\_id | Sys\_id of the application service listed in the Service Instance \[cmdb\_ci\_service\_auto\] table. Data type: String |
Headers
The following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see Supported REST API headers.
| Header | Description |
|---|---|
| Accept | Data format of the response body. Only supports application/json. |
| Header | Description |
|---|---|
| None |
Status codes
The following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see REST API HTTP response codes.
| Status code | Description |
|---|---|
| 200 | Successful. The request was successfully processed. |
| 400 | Bad Request. A bad request type or malformed request was detected. |
| 401 | Unauthorized. The user credentials are incorrect or the user does not have the app_service_admin role. |
| 500 | Internal server error. An unexpected error occurred while processing the request. The response contains additional information about the error. |
Response body parameters (JSON)
| Name | Description |
|---|---|
| status | Indicates success or failure.Data type: String |
cURL request
The following example shows how to convert an application service type.
curl "https://instance.service-now.com/api/sn_service_graph/sg_services/app_service/convert" \
--request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--data "{
\"name\": \"Test Register\",
\"environment\": \"Test\",
\"version\": \"1.0\",
\"levels\" : 8
}" \
--user 'username':'password'
Results indicating a successful conversion to a calculated application service.
{
"result": {
"status": "success"
}
}
SG Services – POST /sg_services/app_service/delete
Deletes an application service.
The following properties for identifying a CI take precedence as follows:
- sys_id – If sys_id, the system only uses the sys_id and ignores any additional values.
- number – If provided without the sys_id, the system only uses the number and ignores any additional values.
- <IRE field name> – The system only uses these values if the sys_id or number are not provided.
URL format
Versioned URL: /api/sn_service_graph/{api_version}/sg_services/app_service/delete
Default URL: /api/sn_service_graph/sg_services/app_service/delete
Note: Available versions are specified in the REST API Explorer. For scripted REST APIs there is additional version information on the Scripted REST Service form.
Supported request parameters
| Name | Description |
|---|---|
| api\_version | Optional. Version of the endpoint to access. For example, `v1` or `v2`. Only specify this value to use an endpoint version other than the latest. Data type: String |
| Name | Description |
|---|---|
| None |
| Name | Description |
|---|---|
| <IRE field name> | One or more IRE fields identifying the application service. For example, name or version. Data type: String |
| number | Unique number that identifies the application service. Data type: String |
| sys\_id | Sys\_id of the application service listed in the Service Instance \[cmdb\_ci\_service\_auto\] table. Data type: String |
Headers
The following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see Supported REST API headers.
| Header | Description |
|---|---|
| Accept | Data format of the response body. Only supports application/json. |
| Header | Description |
|---|---|
| None |
Status codes
The following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see REST API HTTP response codes.
| Status code | Description |
|---|---|
| 200 | Successful. The request was successfully processed. |
| 400 | Bad Request. A bad request type or malformed request was detected. |
| 401 | Unauthorized. The user credentials are incorrect or the user does not have the app_service_admin role. |
| 500 | Internal server error. An unexpected error occurred while processing the request. The response contains additional information about the error. |
Response body parameters (JSON)
| Name | Description |
|---|---|
| status | Indicates success or failure.Data type: String |
cURL request
The following example shows how to delete an application service.
curl "https://instance.service-now.com/api/sn_service_graph/sg_services/app_service/delete" \
--request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--data "{
\"name\": \"Test Register\",
\"environment\": \"Test\",
\"version\": \"1.0\"
}" \
--user 'username':'password'
Results indicating a successful removal of an application service.
{
"result": {
"status": "success"
}
}
SG Services – POST /sg_services/app_service/find
Finds the details of a given application service and its upstream relationships.
Users with the app_service_user role can use this API, but results are restricted to application services in Operational status. The app_service_admin role provides unlimited viewing of application services.
The following properties for identifying a CI take precedence as follows:
- sys_id – If sys_id, the system only uses the sys_id and ignores any additional values.
- number – If provided without the sys_id, the system only uses the number and ignores any additional values.
- <IRE field name> – The system only uses these values if the sys_id or number are not provided.
URL format
Versioned URL: /api/sn_service_graph/{api_version}/sg_services/app_service/find
Default URL: /api/sn_service_graph/sg_services/app_service/find
Note: Available versions are specified in the REST API Explorer. For scripted REST APIs there is additional version information on the Scripted REST Service form.
Supported request parameters
| Name | Description |
|---|---|
| api\_version | Optional. Version of the endpoint to access. For example, `v1` or `v2`. Only specify this value to use an endpoint version other than the latest. Data type: String |
| Name | Description |
|---|---|
| None |
| Name | Description |
|---|---|
| <IRE fields> | One or more IRE fields identifying the application service. For example, name or version. Data type: String |
| number | Unique number that identifies the application service. Data type: String |
| sys\_id | Sys\_id of the application service listed in the Service Instance \[cmdb\_ci\_service\_auto\] table. Data type: String |
Headers
The following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see Supported REST API headers.
| Header | Description |
|---|---|
| Accept | Data format of the response body. Only supports application/json. |
| Header | Description |
|---|---|
| None |
Status codes
The following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see REST API HTTP response codes.
| Status code | Description |
|---|---|
| 200 | Successful. The request was successfully processed. |
| 400 | Bad Request. A bad request type or malformed request was detected. |
| 401 | Unauthorized. The user credentials are incorrect or the user does not have the app_service_admin role. |
| 500 | Internal server error. An unexpected error occurred while processing the request. The response contains additional information about the error. |
Response body parameters (JSON)
| Name | Description |
|---|---|
| <IRE field name> | One or more IRE fields identifying the application service. For example, name or version. Data type: String |
| number | Unique number that identifies the application service. Data type: String |
| operational\_status | Operational status of the application service. For example, active.Data type: String |
| relationships | List of objects defining the application service's upstream relationships.Data type: Array ``` "relationships": [ { "name": "String", "number": "String", "sys_id": "String", "class_name": "String", "relationship": "String" } ] |
| population\_method.levels | Number of levels to use in building the service. If the level value is not provided, the system checks the sys\_property for the value. If svc.manual.convert.levels.default\_value is not populated, a default value of 3 is used.Data type: Number ``` "population_method": { "levels": Number, "type": "dynamic_service" } |
| population\_method.service\_relations | List of objects containing hierarchy data for the CIs within the application service. All CIs form pairs with a parent and child CI. The top-level CI, referred to as the entry point of an application service, does not have a parent CI.Data type: Array ``` "population_method": { "service_relations":[ { "child": "String", "parent": "String" } ], "type": "service_hierarchy" } |
| population\_method.tags.tag | Tag name.Data type: String |
| population\_method.tags.value | Tag value.Data type: String |
| population\_method.type | Required. Population type to add to the application service.Data type: Object Valid values: - cmdb\_group - service\_hierarchy - dynamic\_service - tag\_list - tag\_based\_service\_family |
| sys\_id | Sys\_id of the application service listed in the Service Instance \[cmdb\_ci\_service\_auto\] table. Data type: String |
Headers
The following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see Supported REST API headers.
| Header | Description |
|---|---|
| Accept | Data format of the response body. Only supports application/json. |
| Header | Description |
|---|---|
| None |
Status codes
The following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see REST API HTTP response codes.
| Status code | Description |
|---|---|
| 200 | Successful. The request was successfully processed. |
| 400 | Bad Request. A bad request type or malformed request was detected. |
| 401 | Unauthorized. The user credentials are incorrect or the user does not have the app_service_admin role. |
| 500 | Internal server error. An unexpected error occurred while processing the request. The response contains additional information about the error. |
Response body parameters (JSON)
| Name | Description |
|---|---|
| status | Indicates success or failure.Data type: String |
cURL request
The following example shows how to populate an application service with a dynamic_service type.
curl "https://instance.service-now.com/api/sn_service_graph/sg_services/app_service/populate" \
--request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--data "{
\"name\": \"Test Register\",
\"environment\": \"Test\",
\"version\": \"1.0\",
\"population_method\": {
\"type\": \"dynamic_service\",
\"levels\" : 8
}
}" \
--user 'username':'password'
Results indicating a successful population of an application service.
{
"result": {
"status": "success"
}
}
SG Services – POST /sg_services/app_service/register
Creates an application service, tags and constructs upstream relationships such as business applications, business service offerings, and other application services.
The following properties for identifying a CI take precedence as follows:
- sys_id – If sys_id, the system only uses the sys_id and ignores any additional values.
- number – If provided without the sys_id, the system only uses the number and ignores any additional values.
- <IRE field name> – The system only uses these values if the sys_id or number are not provided.
URL format
Versioned URL: /api/sn_service_graph/{api_version}/sg_services/app_service/register
Default URL: /api/sn_service_graph/sg_services/app_service/register
Note: Available versions are specified in the REST API Explorer. For scripted REST APIs there is additional version information on the Scripted REST Service form.
Supported request parameters
| Name | Description |
|---|---|
| api\_version | Optional. Version of the endpoint to access. For example, `v1` or `v2`. Only specify this value to use an endpoint version other than the latest. Data type: String |
| Name | Description |
|---|---|
| None |
| Name | Description |
|---|---|
| <IRE field name> | One or more IRE fields identifying the application service. For example, name or version. Data type: String |
| number | Unique number that identifies the application service. Data type: String |
| relationships | Upstream relationships categorized by type.Data type: Object ``` "relationships": { "business_app": [Array], "business_service_offering": [Array], "parent_app_service": [Array], "technical_service_offering": [Array] } |
| app\_service.name | Name of the application service.Data type: String |
| app\_service.number | Unique number that identifies the application service. Data type: String |
| app\_service.sys\_id | Sys\_id of the application service listed in the Service Instance \[cmdb\_ci\_service\_auto\] table. Data type: String |
| message | Message describing the status.Possible values: - Service already exists - Service registered successfully Data type: String |
| status | Status indicating whether the service has been registered.Possible values: - Insert: The application service was successfully created. - No action: The application service already exists. No action taken. Data type: String |
cURL request
The following example shows how to register an application service.
curl "instance.service-now.com/api/sn_service_graph/sg_services/app_service/register" \--request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--data "{
\"name\": \"Test Register\",
\"environment\": \"Test\",
\"version\": \"1.0\",
\"number\": \" SNSVC0001014\",
\"relationships\": {
\"business_application\": [
{
\"sys_id\": \"0250a94040697410f87713b656474250\"
},
{
\"number\": \"APM0001002\"
},
{
\"name\": \"Test Biz App1\"
}
],
\"business_service_offering\": [
{
\"sys_id\": \"ed32e98040697410f87713b656474259\"
}
],
\"technical_service_offering\": [
{
\"sys_id\": \"80e12d8040697410f87713b65647421c\"
},
{
\"number\": \"BSN0001005\"
},
{
\"name\": \"Tech Service Offering2\"
}
],
\"parent_app_service\": [
{
\"sys_id\": \"a2f0618040697410f87713b656474255\"
}
]
},
\"tags\": [
{
\"key\": \"key1\",
\"value\": \"value1\"
},
{
\"key\": \"key2\",
\"value\": \"value2\"
}
]
}" \
--user 'username':'password'
The response body includes ID and status information.
{
"result": {
"app_service": {
"sys_id": "5780cb604061f410f87713b656474271",
"name": "Test Register",
"number": " SNSVC0001014"
},
"message": "Service registered successfully",
"status": "INSERT"
}
}
SG Services – POST /sg_services/app_service/relationship/create
Constructs upstream relations such as business applications, business service offerings, and other application services.
This API creates a relationship, taking input with a single parent and a corresponding child object.
The following properties for identifying a CI take precedence as follows:
- sys_id – If sys_id, the system only uses the sys_id and ignores any additional values.
- number – If provided without the sys_id, the system only uses the number and ignores any additional values.
- <IRE field name> – The system only uses these values if the sys_id or number are not provided.
URL format
Versioned URL: /api/sn_service_graph/{api_version}/sg_services/app_service/relationship/create
Default URL: /api/sn_service_graph/sg_services/app_service/relationship/create
Note: Available versions are specified in the REST API Explorer. For scripted REST APIs there is additional version information on the Scripted REST Service form.
Supported request parameters
| Name | Description |
|---|---|
| api\_version | Optional. Version of the endpoint to access. For example, `v1` or `v2`. Only specify this value to use an endpoint version other than the latest. Data type: String |
| Name | Description |
|---|---|
| None |
| Name | Description |
|---|---|
| child | Information identifying the child application service with which to create a relationship.A dynamic CI group can be added as a child but cannot be parent. Data type: Object |
| child.<service\_app\_identifier> | Details identifying the child application service with which to create a relationship.Only one option is required. Each option is listed by processing precedence: - sys\_id: Sys\_id of the child application service. - number: Unique number that identifies the child application service. - <IRE field name>: IRE fields identifying the application service. For example, name or version. Data type: String |
| parent | Details identifying the parent application service with which to create a relationship.Data type: Object |
| parent.<service\_app\_identifier> | Information identifying the application service.Only one option is required. Each option is listed by processing precedence: - sys\_id: Sys\_id the application service listed in the Service Instance \[cmdb\_ci\_service\_auto\]. - number: Unique number that identifies the application service. - <IRE field name>: One or more IRE fields identifying the application service. For example, name or version. Data type: String |
| parent.class\_name | Name of the class that contains the application service.The parent class name should be from one of the following tables: - cmdb\_ci\_business\_app - cmdb\_ci\_service\_auto - cmdb\_ci\_service\_by\_tags - cmdb\_ci\_service\_calculated - cmdb\_ci\_service\_discovered - service\_offering Default: cmdb\_ci\_service\_auto Data type: String |
Headers
The following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see Supported REST API headers.
| Header | Description |
|---|---|
| Accept | Data format of the response body. Only supports application/json. |
| Header | Description |
|---|---|
| None |
Status codes
The following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see REST API HTTP response codes.
| Status code | Description |
|---|---|
| 200 | Successful. The request was successfully processed. |
| 400 | Bad Request. A bad request type or malformed request was detected. |
| 401 | Unauthorized. The user credentials are incorrect or the user does not have the app_service_admin role. |
| 500 | Internal server error. An unexpected error occurred while processing the request. The response contains additional information about the error. |
Response body parameters (JSON)
| Name | Description |
|---|---|
| status | Indicates success or failure.Data type: String |
cURL request
The following example shows how create a relationship from an application service.
curl "https://instance.service-now.com/api/sn_service_graph/sg_services/app_service/relationship/create" \
--request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--data "{
\"child\": {
\"name\": \"wdfsdf\",
\"environment\": \"Test\",
\"version\": \"1.0\"
},
\"parent\": {
\"sys_id\": \"abcdefg\",
\"name\": \"business App1\",
\"class_name\": \"service_offering\"
}
}" \
--user 'username':'password'
Results indicating a successful creation of an application service relationship.
{
"result": {
"status": "success"
}
}
SG Services – POST /sg_services/app_service/relationship/delete
Deletes an application service upstream relationship.
The following properties for identifying a CI take precedence as follows:
- sys_id – If sys_id, the system only uses the sys_id and ignores any additional values.
- number – If provided without the sys_id, the system only uses the number and ignores any additional values.
- <IRE field name> – The system only uses these values if the sys_id or number are not provided.
URL format
Versioned URL: /api/sn_service_graph/{api_version}/sg_services/app_service/relationship/delete
Default URL: /api/sn_service_graph/sg_services/app_service/relationship/delete
Note: Available versions are specified in the REST API Explorer. For scripted REST APIs there is additional version information on the Scripted REST Service form.
Supported request parameters
| Name | Description |
|---|---|
| api\_version | Optional. Version of the endpoint to access. For example, `v1` or `v2`. Only specify this value to use an endpoint version other than the latest. Data type: String |
| Name | Description |
|---|---|
| None |
| Name | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| child | Information describing the child relationship to be deleted from the service application.Data type: Object ``` "child": { "parent.<IRE field name> | One or more IRE fields identifying the application service. For example, name or version. Data type: String | parent.number | Unique number that identifies the application service. Data type: String | parent.sys\_id | Sys\_id of the application service listed in the Service Instance \[cmdb\_ci\_service\_auto\] table. Data type: String | parent.class\_name | Name of the class that contains the application service.The parent class name should be from one of the following tables: - cmdb\_ci\_service\_auto - cmdb\_ci\_service\_discovered - cmdb\_ci\_service\_by\_tags - cmdb\_ci\_service\_calculated - service\_offering - cmdb\_ci\_business\_app Default: cmdb\_ci\_service\_auto Data type: String | HeadersThe following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see Supported REST API headers.
Status codesThe following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see REST API HTTP response codes.
Response body parameters (JSON)
cURL requestThe following example shows how to remove a relationship from an application service. Results indicating a successful removal of an application service relationship. SG Services – POST /sg_services/app_service/stateChanges the application service lifecycle state to activate, deactivate, or retire. The following properties for identifying a CI take precedence as follows:
URL formatVersioned URL: Default URL: Note: Available versions are specified in the REST API Explorer. For scripted REST APIs there is additional version information on the Scripted REST Service form. Supported request parameters
HeadersThe following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see Supported REST API headers.
Status codesThe following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see REST API HTTP response codes.
Response body parameters (JSON)
cURL requestThe following example shows how to change an application service lifecycle state to activate. Results indicating a successful operation. SG Services – POST /sg_services/app_service/updateUpdates an existing application service provided and creates tags for the given application service. The following properties for identifying a CI take precedence as follows:
URL formatVersioned URL: Default URL: Note: Available versions are specified in the REST API Explorer. For scripted REST APIs there is additional version information on the Scripted REST Service form. Supported request parameters
HeadersThe following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see Supported REST API headers.
Status codesThe following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see REST API HTTP response codes.
Response body parameters (JSON)
cURL requestThe following example shows how to update an application service, using name as an IRE field. Response includes application service identification information and updated fields. |