Prepairing Data Sources: ServiceNow API
Overview
Below is a consolidated reference for the most commonly used ServiceNow REST API endpoints. These built-in APIs enable CRUD operations on tables, statistical aggregations, attachment handling, import set staging, and custom logic via scripted endpoints. Use the REST API Explorer in your instance (System Web Services ▶ Inbound ▶ REST API Explorer) to test requests and inspect available parameters.
In summary, ServiceNow provides the following core REST interfaces:
Table API (/api/now/table/{tableName}) for standard CRUD on any table servicenow.comservicenow.com
Aggregate API (/api/now/stats/{tableName}) for record counts and statistical summaries servicenow.com
Attachment API (/api/now/attachment/*) for uploading, downloading, and listing file attachments servicenow.com
Import Set API (/api/now/import/{stagingTableName}) for bulk staging and transformation of external data servicenow.com
Scripted REST API (custom /api/{namespace}/{api_id}/…) for bespoke endpoints with server-side logic servicenow.com
Below, each endpoint is described with its URI pattern, supported methods, key query parameters, and a brief usage example.
Table API
Performs Create, Read, Update, and Delete operations on any ServiceNow table.
Base URI
https://<instance>.service-now.com/api/now/table/{tableName}
``` :contentReference[oaicite:5]{index=5}
Supported Methods
GET– retrieve recordsPOST– create a new recordPUT/PATCH– update an existing recordDELETE– delete a record
Common Query Parameters
sysparm_query– encoded query string (e.g.active=true^priority=1)sysparm_limit/sysparm_offset– pagination controlssysparm_fields– comma-separated list of fields to returnsysparm_display_value–true/false, return display vs. raw values
Example: Retrieve Top 10 Incidents
GET https://<instance>.service-now.com/api/now/table/incident
?sysparm_limit=10
&sysparm_query=priority=1
&sysparm_fields=number,short_description,priority
``` :contentReference[oaicite:6]{index=6}
Aggregate API
Generates summary statistics (counts, sums, averages) on table data without retrieving full records.
Base URI
https://<instance>.service-now.com/api/now/stats/{tableName}
``` :contentReference[oaicite:7]{index=7}
Supported Methods
GETonly
Key Query Parameters
sysparm_count–trueto return total record countsysparm_sum_fields– comma-separated numeric fields to sumsysparm_group_by– comma-separated fields to group resultssysparm_query– filtered subset for aggregation
Example: Count High-Priority Incidents
GET https://<instance>.service-now.com/api/now/stats/incident
?sysparm_count=true
&sysparm_query=priority=1
``` :contentReference[oaicite:8]{index=8}
Attachment API
Handles file attachments for any recordable table.
Upload a File
POST https://<instance>.service-now.com/api/now/attachment/file
?table_name={tableName}
&table_sys_id={recordSysId}
&file_name={filename}
Content-Type: multipart/form-data or binary servicenow.com
Download a File
GET https://<instance>.service-now.com/api/now/attachment/{attachmentSysId}/file
List Attachments on a Record
GET https://<instance>.service-now.com/api/now/attachment
?sysparm_query=table_name={tableName}^table_sys_id={recordSysId}
Delete an Attachment
DELETE https://<instance>.service-now.com/api/now/attachment/{attachmentSysId}
Import Set API
Stages external data in an “import set” table for transformation and loading into target tables.
Single Record Insert
POST https://<instance>.service-now.com/api/now/import/{stagingTableName}
Body: JSON object representing one record servicenow.com
Bulk Insert (Insert Multiple)
POST https://<instance>.service-now.com/api/now/import/{stagingTableName}/insertMultiple
Body: { "records": [ { … }, { … } ] }ahmeddrar.me
Key Query Parameters
None; all mapping and transformation is handled after staging
Scripted REST API
Allows creation of fully custom endpoints backed by server-side scripts.
Definition Location
Navigate to System Web Services ▶ Scripted REST APIs in your instance. servicenow.com
URI Pattern
https://<instance>.service-now.com/api/{namespace}/{api_id}/{resourcePath}
Typical Methods
GET,POST,PUT,DELETE, as defined in your script- Custom request/response scripting in the Scripted REST resource
Use Cases
- Complex business workflows
- Data transformations not covered by core APIs
- Secured, versioned custom interfaces
Discovering and Testing Endpoints
REST API Explorer
- Within your ServiceNow instance: System Web Services ▶ REST API Explorer
- Browse built-in APIs, dynamically construct sample requests, and view response schemas servicenow.com
Versioning
- Endpoints may include a version:
/api/now/v1/...or/api/now/v2/... - Omitting the version defaults to the current API stability level servicenow.com
Authentication & Security
Supported Schemes
- Basic Authentication (username/password)
- OAuth 2.0 (recommended for integrations)
- Mutual TLS (instance-level certificate)
Rate Limits & Best Practices
- Respect
sysparm_limitandsysparm_offsetto avoid large, blocking queries blog.josephvelliah.com - Use index-friendly filters (
sysparm_query) to optimize performance
By leveraging these built-in ServiceNow REST interfaces, you can integrate and manage the communication with the Noreja tool —seamlessly and securely with your ServiceNow data model.