server.batchProcessing.enabled
in the Tyk Vendor Extension (Tyk Classic: enable_batch_request_support
).
/tyk/batch/
endpoint accepts requests in a specific “batch” format and processes them as described in the next section.
For example, if your API’s listen path is /myapi/
the batch request endpoint would be /myapi/tyk/batch/
.
Note that the trailing slash /
at the end of the URL is required when calling this endpoint.
POST
requests with a JSON payload that follows this structure:
requests
: An array of individual requests to be processed
method
: The HTTP method for the individual request (GET
, POST
, PUT
, DELETE
, etc.)headers
: Any HTTP headers to include with the requestbody
: The request body (for POST
, PUT
requests) in the format prescribed by the API (e.g. JSON string)relative_url
: The endpoint for the request, which can include query parameterssuppress_parallel_execution
: A boolean flag to control whether requests should be processed in parallel (false
) or sequentially in the order that they appear in the array (true
)POST /my-api/tyk/batch
with this payload, Tyk would process three requests in parallel:
GET /my-api/resource/123
passing x-header-1
and Authorization
headersPOST /my-api/resource/create
passing x-header-2
and Authorization
headers and the payload descrbied in body
GET /my-api/resource/invalid
passing x-header-3
and Authorization
headersrequests
array. The suppress_parallel_execution
setting is used to determine whether Tyk should wait for each request to complete before starting the next (true
), or if it should issue all of the requests in parallel (false
).
If sequential execution is in use, Tyk will work through the entire requests
array regardless of whether any requests return errors. All responses (success and failure) will be logged and returned to the client as described below.
requests
array:
relative_url
: The URL of the endpoint targeted by the requestcode
: The HTTP status code returned from the individual requestheaders
: The response headersbody
: The response body as a stringHTTP 200 OK
status code as long as the batch request was properly formatted and processed, regardless of whether individual requests within the batch succeeded or failed.
To determine the success or failure of individual requests, you need to examine the status code for each request in the response array.
In the previous example, we can see that the first two requests were successful, returning HTTP 200 OK
and HTTP 201 Created
, whereas the third failed returning HTTP 404 Not found
.
TykBatchRequest
function that is included in Tyk’s JavaScript API.
This integration enables you to:
/tyk/batch/
endpoint do not require any authentication, however the requests within the batch (declared in the payload) do not bypass any security mechanisms.
As this endpoint is keyless, no rate limiting is applied to the requests to /tyk/batch/
.
Each request in a batch is processed through Tyk’s full security pipeline, including authentication and rate limiting, so API keys or other authentication credentials must be included in each individual request within the batch.
Rate limiting and quotas are applied to each request in the batch individually - so a batch containing three requests using the same API key will add three to their rate limit and quota counts. This could lead to one or more of the batched requests being rejected.
This means that, whilst anyone can make a request to the batch endpoint, they can only successfully execute requests within the batch by providing valid authentication credentials in those requests.
This means that the batch endpoint could potentially be used for reconnaissance, as attackers might determine which APIs exist based on responses. If this is a concern then you could consider:
suppress_parallel_execution
to false
provides better performance but doesn’t guarantee response order.tyk/batch/
endpoint, it is essential that the trailing slash is included in the request, otherwise Tyk will return an HTTP 404
error.
/etc/hosts
file.
Internal vs. External Routing: When a batch request is made to a custom domain, Tyk needs to route the individual requests within the batch correctly. If the custom domain is only configured for external access but not for internal routing, the batch requests may fail.
Solution: Configure your custom domain to work with both external and internal routing.
Certificate Validation: If your custom domain uses HTTPS, certificate validation issues can occur during the internal processing of batch requests.
Solution: Ensure that the certificates for your custom domain are properly configured and trusted by the Tyk Gateway.