Tyk

Tyk Batch Requests API

Tyk supports batch requests, so a client makes a single request to the API but gets a compound response object back. This is especially handy if clients have complex requests that have multiple synchronous dependencies and do not wish to have the entire request / response cycle running for each event. To enable batch request support, set the `enable_batch_request_support` value to `true` Batch requests that come into Tyk are *run through the whole Tyk machinery* and *use a relative path to prevent spamming*. This means that a batch request to Tyk for three resources with the same API key will have three requests applied to their session quota and request limiting could become active if they are being throttled. Tyk reconstructs the API request based on the data in the batch request. This is to ensure that Tyk is not being used to proxy requests to other hosts outside of the upstream API being accessed. Batch requests are created by POSTING to the `/{listen_path}/tyk/batch/` endpoint. These requests **do not require a valid key**, but their request list does. Sample Request ```{json} { "requests": [ { "method": "GET", "headers": { "x-tyk-test": "1", "x-tyk-version": "1.2", "authorization": "1dbc83b9c431649d7698faa9797e2900f" }, "body": "", "relative_url": "get" }, { "method": "GET", "headers": { "x-tyk-test": "2", "x-tyk-version": "1.2", "authorization": "1dbc83b9c431649d7698faa9797e2900f" }, "body": "", "relative_url": "get" } ], "suppress_parallel_execution": false } ``` The response will be a structured reply that encapsulates the responses for each of the outbound requests. If `suppress_parallel_execution` is set to `true`, requests will be made synchronously. If set to `false` then they will run in parallel and the response order is not guaranteed. Sample Response ``` [ { "relative_url": "get", "code": 200, "headers": { "Access-Control-Allow-Credentials": [ "true" ], "Access-Control-Allow-Origin": [ "*" ], "Content-Length": [ "497" ], "Content-Type": [ "application/json" ], "Date": [ "Wed, 12 Nov 2014 15:32:43 GMT" ], "Server": [ "gunicorn/18.0" ], "Via": [ "1.1 vegur" ] }, "body": "{ "args": {}, "headers": { "Accept-Encoding": "gzip", "Authorization": "1dbc83b9c431649d7698faa9797e2900f", "Connect-Time": "2", "Connection": "close", "Host": "httpbin.org", "Total-Route-Time": "0", "User-Agent": "Go 1.1 package http", "Via": "1.1 vegur", "X-Request-Id": "6a22499a-2776-4aa1-80c0-686581a8be4d", "X-Tyk-Test": "2", "X-Tyk-Version": "1.2" }, "origin": "127.0.0.1, 62.232.114.250", "url": "http://httpbin.org/get" }" }, { "relative_url": "get", "code": 200, "headers": { "Access-Control-Allow-Credentials": [ "true" ], "Access-Control-Allow-Origin": [ "*" ], "Content-Length": [ "497" ], "Content-Type": [ "application/json" ], "Date": [ "Wed, 12 Nov 2014 15:32:43 GMT" ], "Server": [ "gunicorn/18.0" ], "Via": [ "1.1 vegur" ] }, "body": "{ "args": {}, "headers": { "Accept-Encoding": "gzip", "Authorization": "1dbc83b9c431649d7698faa9797e2900f", "Connect-Time": "7", "Connection": "close", "Host": "httpbin.org", "Total-Route-Time": "0", "User-Agent": "Go 1.1 package http", "Via": "1.1 vegur", "X-Request-Id": "1ab61f50-51ff-4828-a7e2-17240385a6d2", "X-Tyk-Test": "1", "X-Tyk-Version": "1.2" }, "origin": "127.0.0.1, 62.232.114.250", "url": "http://httpbin.org/get" }" } ] ``` With the body for each request string encoded in the `body` field. * `expire_analytics_after`: If you are running a busy API, you may want to ensure that your MongoDB database does not overflow with old data. Set the `expire_analytics_after` value to the number of seconds you would like the data to last for. Setting this flag to anything above `0` will set an `expireAt` field for each record that is written to the database. **Important:** Tyk will not create the expiry index for you. In order to implement data expiry for your analytics data, ensure that the index is created This is easily achieved using the [MongoDB command line interface](https://docs.mongodb.com/getting-started/shell/client/). * `dont_set_quota_on_create`: This setting defaults to `false`, but if set to `true`, when the API is used to edit, create or add keys, the quota cache in Redis will not be re-set. By default, all updates or creates to Keys that have Quotas set will re-set the quota (This has been the default behaviour since 1.0). This behaviour can be bypassed on a case-by-case basis by using the `suppress_reset` parameter when making a REST API request. This is the advised mode of operation as it allows for manual, granular control over key quotas and reset timings. * `cache_options`: This section enables you to configure the caching behaviour of Tyk and to enable or disable the caching middleware for your API. * `cache_options.enable_cache`: Set this value to `true` if the cache should be enabled for this endpoint, setting it to false will stop all caching behaviour. * `cache_options.cache_timeout`: The amount of time, in seconds, to keep cached objects, defaults to `60` seconds. * `cache_options.cache_all_safe_requests`: Set this to `true` if you want all *safe* requests (GET, HEAD, OPTIONS) to be cached. This is a blanket setting for APIs where caching is required but you don't want to set individual paths up in the definition. * `cache_options.enable_upstream_cache_control`: Set this to `true` if you want your application to control the cache options for Tyk (TTL and whether to cache or not). See [Caching](/docs/basic-config-and-security/reduce-latency/caching/) for more details. * `response_processors`: Response processors need to be specifically defined so they are loaded on API creation, otherwise the middleware will not fire. In order to have the two main response middleware components fire, the following configuration object should be supplied. ```{json} "response_processors": [ { "name": "header_injector", "options": { "add_headers": {"name": "value"}, "remove_headers": ["name"] } }, { "name": "response_body_transform", "options": {} } ] ``` The options for the `header_injector` are global, and will apply to all outbound requests.

Operations 1

POST /{listen_path}/tyk/batch Tyk Run Batch Request. #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/tyk-batch-requests-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

tyk-batch-requests-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  contact:
    email: support@tyk.io
    name: Tyk Technologies
    url: https://tyk.io/contact
  description: 'The Tyk Gateway API is the primary means for integrating your application with the Tyk API Gateway system. This API is very small, and has no granular permissions system. It is intended to be used purely for internal automation and integration.


    **Warning: Under no circumstances should outside parties be granted access to this API.**


    The Tyk Gateway API is capable of:


    * Managing session objects (key generation).

    * Managing and listing policies.

    * Managing and listing API Definitions (only when not using the Tyk Dashboard).

    * Hot reloads / reloading a cluster configuration.

    * OAuth client creation (only when not using the Tyk Dashboard).


    In order to use the Gateway API, you''ll need to set the **secret** parameter in your tyk.conf file.


    The shared secret you set should then be sent along as a header with each Gateway API Request in order for it to be successful:


    **x-tyk-authorization: <your-secret>***

    <br/>


    <b>The Tyk Gateway API is subsumed by the Tyk Dashboard API in Pro installations.</b>


    '
  license:
    name: Mozilla Public License Version 2.0
    url: https://github.com/TykTechnologies/tyk/blob/master/LICENSE.md
  title: Tyk Gateway Batch Requests API
  version: 5.7.1
servers:
- url: https://{tenant}
  variables:
    tenant:
      default: localhost:8080
      description: Your gateway host
security:
- api_key: []
tags:
- description: "Tyk supports batch requests, so a client makes a single request to the API but gets a compound response object back.\n\nThis is especially handy if clients have complex requests that have multiple synchronous dependencies and do not wish to have the entire request / response cycle running for each event.\n\nTo enable batch request support, set the `enable_batch_request_support` value to `true`\n\nBatch requests that come into Tyk are *run through the whole Tyk machinery* and *use a relative path to prevent spamming*. This means that a batch request to Tyk for three resources with the same API key will have three requests applied to their session quota and request limiting could become active if they are being throttled.\n\nTyk reconstructs the API request based on the data in the batch request. This is to ensure that Tyk is not being used to proxy requests to other hosts outside of the upstream API being accessed.\n\nBatch requests are created by POSTING to the `/{listen_path}/tyk/batch/` endpoint. These requests **do not require a valid key**, but their request list does.\n\n<h3>Sample Request</h3>\n\n    ```{json}\n    {\n      \"requests\": [\n        {\n          \"method\": \"GET\",\n          \"headers\": {\n            \"x-tyk-test\": \"1\",\n            \"x-tyk-version\": \"1.2\",\n            \"authorization\": \"1dbc83b9c431649d7698faa9797e2900f\"\n          },\n          \"body\": \"\",\n          \"relative_url\": \"get\"\n      },\n      {\n        \"method\": \"GET\",\n        \"headers\": {\n          \"x-tyk-test\": \"2\",\n          \"x-tyk-version\": \"1.2\",\n          \"authorization\": \"1dbc83b9c431649d7698faa9797e2900f\"\n        },\n        \"body\": \"\",\n        \"relative_url\": \"get\"\n        }\n      ],\n      \"suppress_parallel_execution\": false\n    }\n    ```\n\nThe response will be a structured reply that encapsulates the responses for each of the outbound requests. If `suppress_parallel_execution` is set to `true`, requests will be made synchronously. If set to `false` then they will run in parallel and the response order is not guaranteed.\n\n<h3>Sample Response</h3>\n\n  ```\n  [\n    {\n      \"relative_url\": \"get\",\n      \"code\": 200,\n      \"headers\": {\n        \"Access-Control-Allow-Credentials\": [\n          \"true\"\n        ],\n        \"Access-Control-Allow-Origin\": [\n          \"*\"\n        ],\n        \"Content-Length\": [\n          \"497\"\n        ],\n        \"Content-Type\": [\n          \"application/json\"\n        ],\n        \"Date\": [\n          \"Wed, 12 Nov 2014 15:32:43 GMT\"\n        ],\n        \"Server\": [\n          \"gunicorn/18.0\"\n        ],\n        \"Via\": [\n          \"1.1 vegur\"\n        ]\n      },\n      \"body\": \"{\n    \"args\": {},\n    \"headers\": {\n      \"Accept-Encoding\": \"gzip\",\n      \"Authorization\": \"1dbc83b9c431649d7698faa9797e2900f\",\n      \"Connect-Time\": \"2\",\n      \"Connection\": \"close\",\n      \"Host\": \"httpbin.org\",\n      \"Total-Route-Time\": \"0\",\n      \"User-Agent\": \"Go 1.1 package http\",\n      \"Via\": \"1.1 vegur\",\n      \"X-Request-Id\": \"6a22499a-2776-4aa1-80c0-686581a8be4d\",\n      \"X-Tyk-Test\": \"2\",\n      \"X-Tyk-Version\": \"1.2\"\n    },\n    \"origin\": \"127.0.0.1, 62.232.114.250\",\n    \"url\": \"http://httpbin.org/get\"\n  }\"\n      },\n      {\n        \"relative_url\": \"get\",\n        \"code\": 200,\n        \"headers\": {\n          \"Access-Control-Allow-Credentials\": [\n            \"true\"\n          ],\n          \"Access-Control-Allow-Origin\": [\n            \"*\"\n          ],\n          \"Content-Length\": [\n            \"497\"\n          ],\n          \"Content-Type\": [\n            \"application/json\"\n          ],\n          \"Date\": [\n            \"Wed, 12 Nov 2014 15:32:43 GMT\"\n          ],\n          \"Server\": [\n            \"gunicorn/18.0\"\n          ],\n          \"Via\": [\n            \"1.1 vegur\"\n          ]\n        },\n        \"body\": \"{\n    \"args\": {},\n    \"headers\": {\n      \"Accept-Encoding\": \"gzip\",\n      \"Authorization\": \"1dbc83b9c431649d7698faa9797e2900f\",\n      \"Connect-Time\": \"7\",\n      \"Connection\": \"close\",\n      \"Host\": \"httpbin.org\",\n      \"Total-Route-Time\": \"0\",\n      \"User-Agent\": \"Go 1.1 package http\",\n      \"Via\": \"1.1 vegur\",\n      \"X-Request-Id\": \"1ab61f50-51ff-4828-a7e2-17240385a6d2\",\n      \"X-Tyk-Test\": \"1\",\n      \"X-Tyk-Version\": \"1.2\"\n    },\n    \"origin\": \"127.0.0.1, 62.232.114.250\",\n    \"url\": \"http://httpbin.org/get\"\n  }\"\n      }\n  ]\n  ```\nWith the body for each request string encoded in the `body` field.\n\n* `expire_analytics_after`: If you are running a busy API, you may want to ensure that your MongoDB database does not overflow with old data. Set the `expire_analytics_after` value to the number of seconds you would like the data to last for. Setting this flag to anything above `0` will set an `expireAt` field for each record that is written to the database.\n\n**Important:** Tyk will not create the expiry index for you. In order to implement data expiry for your analytics data, ensure that the index is created This is easily achieved using the [MongoDB command line interface](https://docs.mongodb.com/getting-started/shell/client/).\n\n* `dont_set_quota_on_create`: This setting defaults to `false`, but if set to `true`, when the API is used to edit, create or add keys, the quota cache in Redis will not be re-set. By default, all updates or creates to Keys that have Quotas set will re-set the quota (This has been the default behaviour since 1.0).\n\n  This behaviour can be bypassed on a case-by-case basis by using the `suppress_reset` parameter when making a REST API request. This is the advised mode of operation as it allows for manual, granular\ncontrol over key quotas and reset timings.\n* `cache_options`: This section enables you to configure the caching behaviour of Tyk and to enable or disable the caching middleware for your API.\n\n* `cache_options.enable_cache`: Set this value to `true` if the cache should be enabled for this endpoint, setting it to false will stop all caching behaviour.\n\n* `cache_options.cache_timeout`: The amount of time, in seconds, to keep cached objects, defaults to `60` seconds.\n\n* `cache_options.cache_all_safe_requests`: Set this to `true` if you want all *safe* requests (GET, HEAD, OPTIONS) to be cached. This is a blanket setting for APIs where caching is required but you don't want to set individual paths up in the definition.\n\n* `cache_options.enable_upstream_cache_control`: Set this to `true` if you want your application to control the cache options for Tyk (TTL and whether to cache or not). See [Caching](/docs/basic-config-and-security/reduce-latency/caching/) for more details.\n\n* `response_processors`: Response processors need to be specifically defined so they are loaded on API creation, otherwise the middleware will not fire. In order to have the two main response middleware components fire, the following configuration object should be supplied.\n\n```{json}\n  \"response_processors\": [\n    {\n        \"name\": \"header_injector\",\n        \"options\": {\n            \"add_headers\": {\"name\": \"value\"},\n            \"remove_headers\": [\"name\"]\n        }\n    },\n    {\n      \"name\": \"response_body_transform\",\n      \"options\": {}\n    }\n  ]\n```\n\nThe options for the `header_injector` are global, and will apply to all outbound requests.\n"
  name: Batch Requests
paths:
  /{listen_path}/tyk/batch:
    post:
      description: Endpoint to run batch request.
      operationId: batch
      parameters:
      - description: API listen path
        example: get
        in: path
        name: listen_path
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/json:
            example:
              requests:
              - body: ''
                headers:
                  authorization: 1dbc83b9c431649d7698faa9797e2900f
                  x-tyk-test: '1'
                  x-tyk-version: '1.2'
                method: GET
                relative_url: get
              - body: ''
                headers:
                  authorization: 1dbc83b9c431649d7698faa9797e2900f
                  x-tyk-test: '2'
                  x-tyk-version: '1.2'
                method: GET
                relative_url: get
              suppress_parallel_execution: false
            schema:
              $ref: '#/components/schemas/BatchRequestStructure'
      responses:
        '200':
          content:
            application/json:
              example:
              - body: '{"message": "success"}'
                code: 200
                headers:
                  Access-Control-Allow-Credentials:
                  - 'true'
                  Content-Type:
                  - application/json
                relative_url: get
              schema:
                items:
                  $ref: '#/components/schemas/BatchReplyUnit'
                type: array
          description: Success.
        '400':
          content:
            application/json:
              example:
                message: Batch request malformed
                status: error
              schema:
                $ref: '#/components/schemas/ApiStatusMessage'
          description: Bad Request
        '403':
          content:
            application/json:
              example:
                message: Attempted administrative access with invalid or missing key!
                status: error
              schema:
                $ref: '#/components/schemas/ApiStatusMessage'
          description: Forbidden
      summary: Tyk Run Batch Request.
      tags:
      - Batch Requests
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
components:
  schemas:
    BatchRequestStructure:
      properties:
        requests:
          items:
            $ref: '#/components/schemas/RequestDefinition'
          type:
          - array
          - 'null'
          example: []
        suppress_parallel_execution:
          type: boolean
          example: true
      type: object
    RequestDefinition:
      properties:
        body:
          type: string
          example: example_value
        headers:
          additionalProperties:
            type: string
          type:
          - object
          - 'null'
          example: example_value
        method:
          type: string
          example: example_value
        relative_url:
          type: string
          example: https://www.example.com
      type: object
    HttpHeader:
      additionalProperties:
        items:
          type: string
        type: array
      type: object
    BatchReplyUnit:
      properties:
        body:
          type: string
          example: example_value
        code:
          type: integer
          example: 10
        headers:
          $ref: '#/components/schemas/HttpHeader'
        relative_url:
          type: string
          example: https://www.example.com
      type: object
    ApiStatusMessage:
      properties:
        message:
          type: string
          example: example_value
        status:
          type: string
          example: example_value
      type: object
  securitySchemes:
    api_key:
      description: Api key
      in: header
      name: X-Tyk-Authorization
      type: apiKey