Batch API
-
- UpdatedAug 1, 2024
- 5 minutes to read
- Xanadu
- API reference
The Batch API provides endpoints to send a single request containing multiple REST API calls, and returns a stream of response payloads.
This REST API enables integrators to:
- Decrease the amount of time required to send API requests by batching them together, and reduce overhead by narrowing authentication, session setup, and round-trip traffic to a single step.
- Create more efficient code for client-side integrations.
- Mix batch item formats and include them in single batch request. For example, one batch can include a Bases64-encoded request in XML format to send to one endpoint and a Base64 encoded request in JSON format to send to a different endpoint.
- Receive a stream of response payloads in return.
- Apply existing ACLs to each API call in the batch.
You can include any API available on the instance in a Batch API call. For performance reasons, avoid including long-running requests and requests that retrieve large amounts of data.
Size and processing limits
Payloads adhere to these size limits:
- Each item in the request: 5 MB. You can change this default by updating the glide.rest.batch.max.inputSize system property. Maximum value: 10 MB.
- Each item in the response: 10 MB. You can change this default by updating the glide.rest.batch.max.outputSize system property or adding the X-BATCHREQUEST-MAX-OUTPUT-SIZE header to your request. The X-BATCHREQUEST-MAX-OUTPUT-SIZE header value cannot exceed the value of the system property.
When a batch request reaches a size or processing limit, the system cancels the transaction and returns unprocessed requests in the unserviced JSON array in the response.
Batch - POST /now/batch
Sends multiple REST API requests in a single call.
You can include any API available on the instance in a Batch API call. For performance reasons, avoid including long-running requests and requests that retrieve large amounts of data.
URL format
Versioned URL: /api/now/{api_version}/batch
Supported request parameters
Name | Description |
---|---|
api_version | Version of the endpoint to access. For example, v1 or v2. Data type: String |
Name | Description |
---|---|
None |
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. |
Content-Type | Data format of the request body. Only supports application/json. |
X-BATCHREQUEST-MAX-OUTPUT-SIZE | Size limit for each item in the batch response. Add this header to provide a
lower size limit than the default set by the
glide.rest.batch.max.outputSize system property. You cannot
set a value higher than the value in the system property. Default: 10 MB. |
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. |
401 | Unauthorized. The user credentials are incorrect or have not been passed. |
500 | Internal server error. An unexpected error occurred while processing the request. The response contains additional information about the error. |
Response body parameters (JSON)
Example: cURL request
This batch request sends two GET requests to the instance and one POST request to the incident table. The body of the POST request is Base64 encoded.