How to export bulk data from ServiceNow using REST API paginationIssue <!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } Learn how to export bulk data from a ServiceNow instance using REST API pagination. When exporting large data sets with millions of records, export data in chunks to avoid performance implications and impact on other services running on the instance. Release<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } All supported releases Resolution<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } How REST API pagination works By default, ServiceNow returns a maximum of 10,000 records per REST API call. This limit is controlled by the sysparm_limit parameter, which defaults to 10,000. You can specify a higher value in the URL to return more records, but increasing this value significantly can cause the transaction to time out. For example: /api/now/table/incident?sysparm_limit=40000 Note: The default quota rule for REST API transactions is set to 60 seconds per transaction. Increasing sysparm_limit drastically can cause the transaction to time out and get canceled. The preferred method for retrieving large amounts of records is pagination, which retrieves subsets of records in separate calls. For example, the first call retrieves records 1 through 10,000, the second call retrieves records 10,001 through 20,000, and so on. Pagination parameters Use the following parameters to control pagination: sysparm_limit — Defines how many records to return in one call (10,000 by default).sysparm_offset — Defines the starting record position, excluding preceding records from the query.sysparm_query=ORDERBYsys_created_on — Sorts the results by created date and time. Pagination example The following examples show how to structure paginated REST API calls. First call: /api/now/table/incident?sysparm_limit=10000&sysparm_offset=0&sysparm_query=ORDERBYsys_created_on Second call: /api/now/table/incident?sysparm_limit=10000&sysparm_offset=10000&sysparm_query=ORDERBYsys_created_on Third call: /api/now/table/incident?sysparm_limit=10000&sysparm_offset=20000&sysparm_query=ORDERBYsys_created_on Continue this pattern in a loop until all records are retrieved. Example bulk download script The following bash script uses cURL to bulk download data from an instance using REST API pagination. This example is provided as a general guideline and can be adapted to your requirements. #!/bin/bash ## Example of how to use REST API pagination to bulk download data ## Settings PAGESIZE=10000 PAGESTOFETCH=10 TABLE=tablename # e.g incident, question_answer, task INSTANCENAME=myinstancename # e.g if instance is acme.service-now.com then put 'acme' here USERNAME=myuser PASSWORD=mypassword OUTPUTFORMAT=json # either xml or json ## Program echo "Starting at `date`" i=0 pageoffset=0 while [[ $i -le $PAGESTOFETCH ]]; do echo "Starting download of $PAGESIZE records from table $TABLE at offset $pageoffset" curl "https://$INSTANCENAME.service-now.com/api/now/table/$TABLE?sysparm_offset=$pageoffset&sysparm_limit=$PAGESIZE" \ --request GET \ --header "Accept:application/$OUTPUTFORMAT" \ --header "Content-Type:application/json" \ --data "{}" \ --user ${USERNAME}:${PASSWORD} \ --output question_answer$i.xml \ --silent echo "Saved $PAGESIZE records to question_answer$i.xml" ((pageoffset+=$PAGESIZE)) ((i++)) done echo "Finished at `date`" Important: ServiceNow Support does not provide assistance with custom scripting. This example can be accomplished in many ways, for example, using Python instead of a bash shell. Related Links<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } How to bulk export attachments from a ServiceNow instance — for exporting attachment binary data, which uses a different procedure than the REST API pagination method described in this article Default quota rules