## ServiceNow Integration Documentation

This documentation for the ServiceNow integration describes the technical capabilities of this integration, including authorization, scopes/permissions, and utilized endpoints. For more information on how to integrate ServiceNow, visit our [connection instructions](https://docs.datagrail.io/docs/integrations/connection-instructions/servicenow).

## Version  
This integration utilizes the ServiceNow REST API **v1 and v2**.

## Base URL  
The base URL used for all ServiceNow API endpoints contains the **Instance ID**:

```
https://instance_id.service-now.com/api
```

#### Endpoints Utilized  
DataGrail uses the following endpoints to authorize and test the connection:

| Method | Endpoint | Purpose | Docs |
| --- | --- | --- | --- |
| GET | `/now/consumer` | Validate access permissions |  |
| GET | `/now/contact` | Validate access permissions |  |
| GET | `/now/table/table_name` | Validate access permissions |  |
| GET | `/now/table/sys_db_object` | Validate access permissions |  |
| POST | `/oauth_token.do` | Get and refresh access token |  |

## Authentication & Authorization  
The DataGrail ServiceNow integration connects using **OAuth 2.0** with the following credentials: **Client ID** and **Client Secret**.

### Sensitive Credentials  
Publicly exposing your API credentials can allow unauthorized access to ServiceNow API endpoints by a third party. DataGrail stores your API credentials encrypted and protected.

## Limits  
Limits in ServiceNow are calculated using the leaky bucket algorithm. All requests that are made after rate limits have been exceeded are throttled and an `HTTP 429 Too Many Requests` error is returned. Requests succeed again after enough requests have emptied out of the bucket.

- DataGrail supports requests throttling to stay within 70-80% of specified service rate limits.
- DataGrail processes API responses with HTTP 429 status to interrupt requests, waiting and retrying (using an exponential backoff strategy).

## Capabilities  
### Access  
DataGrail's **ServiceNow** integration provides **Synchronous** Access capabilities for the following supported identifier category: **Email**.

#### Data Interactions  
For **Access** requests, DataGrail will take the following actions:

1. List Contacts to collect a list of **Contacts** filtered using configured identifiers.
2. List Accounts to collect a list of **Accounts** that are associated with retrieved Contacts.
3. List Consumers to collect a list of **Consumers** filtered using configured identifiers.
4. List System Users to collect a list of **Users** filtered using configured identifiers.
5. List objects from the customer-defined tables. These tables can be specified through configuration by DataGrail Support ( [support@datagrail.io](mailto:support@datagrail.io)).

#### Endpoints Utilized  
| Method | Endpoint | Purpose | Docs |
| --- | --- | --- | --- |
| GET | `/now/account` | Collect a list of Accounts |  |
| GET | `/now/consumer` | Collect a list of Consumers |  |
| GET | `/now/contact` | Collect a list of Contacts |  |
| GET | `/now/table/table_name` | Collect a list of objects from the table defined by the customer |  |
| GET | `/now/table/sys_user` | Collect a list of System Users |  |

### Data Discovery  
DataGrail's **ServiceNow** integration provides data discovery capabilities based on the principle of finding any and all personal data that's stored in a data system.

#### Data Interactions  
For discovery request, DataGrail will take the following actions:

1. Fetch DB objects.
2. Count number of all records for each DB object.
3. Fetch records examples for each accessible DB object.
4. Sample data for the next analysis and classification.

#### Endpoints Utilized  
| Method | Endpoint | Purpose | Docs |
| --- | --- | --- | --- |
| GET | `/now/stats/table_name` | Count number of all records for each of DB objects |  |
| GET | `/now/table/sys_db_object` | Fetch DB objects |  |
| POST | `/now/v1/batch` | Fetch records examples for each of the accessible DB object |  |

Need help?

If you have any questions, please reach out to your dedicated Account Manager or contact us at [support@datagrail.io](mailto:support@datagrail.io).

_Disclaimer: The information contained in this message does not constitute as legal advice. We would advise seeking professional counsel before acting on or interpreting any material._
