---
title: Batch multiple API endpoints into one request.
slug: feature-experimentation/api/batch-multiple-api-endpoints-into-one-request
docTags: 
createdAt: 2026-08-28T15:54:06.731Z
---

{
  "id": "zjllvn61Rt8KEvWeG2zZA",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "/v1/batch",
    "servers": [],
    "name": "Batch multiple API endpoints into one request.",
    "description": "You can use the Batch endpoint to do things like   \n1. Make activate decisions for a batch of users in a short timeframe for testing purposes\n2. Gather responses from a bunch of activate calls into one response for comparison or analysis\n",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [
        {
          "name": "accept",
          "type": "string",
          "kind": "optional",
          "description": "Generated from available response content types",
          "enum": [
            "application/json"
          ],
          "default": "application/json"
        }
      ],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "required",
          "name": "body",
          "type": "object",
          "description": "",
          "customType": "BatchContext",
          "schema": [
            {
              "name": "operations",
              "kind": "required",
              "type": "array",
              "description": "<p>Array of requests to Agent endpoints, batched into one request</p>",
              "modelRef": "#/components/schemas/BatchOperation",
              "customType": "BatchOperation[]",
              "schema": [
                {
                  "name": "method",
                  "kind": "optional",
                  "type": "object",
                  "description": "",
                  "complexType": "allOf",
                  "complexItems": [
                    {
                      "name": "Method",
                      "description": "",
                      "modelRef": "#/components/schemas/Method",
                      "schema": []
                    }
                  ],
                  "schema": []
                },
                {
                  "name": "url",
                  "kind": "optional",
                  "type": "string",
                  "description": "The base and endpoint components of the API request's path"
                },
                {
                  "name": "operationID",
                  "kind": "optional",
                  "type": "string",
                  "description": "Index of the request in the batch"
                },
                {
                  "name": "body",
                  "kind": "optional",
                  "type": "object",
                  "description": "The body for the request as JSON",
                  "example": "",
                  "schema": []
                },
                {
                  "name": "parameters",
                  "kind": "optional",
                  "type": "object",
                  "description": "The parameters for the request as JSON",
                  "example": "",
                  "schema": []
                },
                {
                  "name": "headers",
                  "kind": "optional",
                  "type": "object",
                  "description": "The headers for the request as JSON",
                  "example": "",
                  "schema": []
                }
              ]
            }
          ],
          "modelRef": "#/components/schemas/BatchContext",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "SdkKeyAuth",
          "name": "X-Optimizely-SDK-Key",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        },
        {
          "id": "TokenAuth",
          "name": "TokenAuth",
          "kind": "optional",
          "type": "http",
          "scheme": "bearer"
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "responses for each endpoint called in the batch request",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "BatchResponse",
            "schema": [
              {
                "name": "startedAt",
                "kind": "optional",
                "type": "string",
                "description": ""
              },
              {
                "name": "endedAt",
                "kind": "optional",
                "type": "string",
                "description": ""
              },
              {
                "name": "errorCount",
                "kind": "optional",
                "type": "integer",
                "description": ""
              },
              {
                "name": "response",
                "kind": "optional",
                "type": "array",
                "description": "",
                "modelRef": "#/components/schemas/BatchResponseItem",
                "customType": "BatchResponseItem[]",
                "schema": [
                  {
                    "name": "status",
                    "kind": "optional",
                    "type": "integer",
                    "description": "",
                    "modelRef": "#/components/schemas/Status",
                    "customType": "Status",
                    "schema": []
                  },
                  {
                    "name": "requestID",
                    "kind": "optional",
                    "type": "string",
                    "description": ""
                  },
                  {
                    "name": "operationID",
                    "kind": "optional",
                    "type": "string",
                    "description": ""
                  },
                  {
                    "name": "method",
                    "kind": "optional",
                    "type": "string",
                    "description": "",
                    "modelRef": "#/components/schemas/Method1",
                    "customType": "Method1",
                    "schema": []
                  },
                  {
                    "name": "url",
                    "kind": "optional",
                    "type": "string",
                    "description": ""
                  },
                  {
                    "name": "body",
                    "kind": "optional",
                    "type": "object",
                    "description": "",
                    "complexType": "oneOf",
                    "complexItems": [],
                    "schema": []
                  },
                  {
                    "name": "startedAt",
                    "kind": "optional",
                    "type": "string",
                    "description": ""
                  },
                  {
                    "name": "endedAt",
                    "kind": "optional",
                    "type": "string",
                    "description": ""
                  }
                ]
              }
            ],
            "modelRef": "#/components/schemas/BatchResponse",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "400",
        "description": "<p>Bad request, invalid parameters.</p>",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "422",
        "description": "<p>Unprocessable Entity, too many operations</p>",
        "jsonExample": "",
        "isExpanded": true
      }
    ],
    "hasXCodeSamples": false,
    "deprecated": false,
    "examples": {
      "languages": [
        {
          "id": "ektJHe0IPzHpnJox4ojeR",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url /v1/batch \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"operations\": [\n     {\n     \"method\": {}\n     }\n     ]\n     }'"
        },
        {
          "id": "-E9WtlKiGkDhotutX-Gl_",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar raw = JSON.stringify({\n   \"operations\": [\n      {\n         \"method\": {}\n      }\n   ]\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"/v1/batch\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "rQ8SE64TmmDIJVJrVbseS",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"/v1/batch\")\n\nhttp = Net::HTTP.new(url.host, url.port);\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\nrequest.body = JSON.dump({\n   \"operations\": [\n      {\n         \"method\": {}\n      }\n   ]\n})\n\nresponse = http.request(request)\nputs response.read_body\n"
        },
        {
          "id": "Sys4vqJS1TBkx6Ke-9gGo",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"/v1/batch\"\n\npayload = json.dumps({\n   \"operations\": [\n      {\n         \"method\": {}\n      }\n   ]\n})\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "ektJHe0IPzHpnJox4ojeR"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// responses for each endpoint called in the batch request\n{\n  \"startedAt\": \"\",\n  \"endedAt\": \"\",\n  \"errorCount\": 0,\n  \"response\": [\n    {\n      \"status\": 0,\n      \"requestID\": \"\",\n      \"operationID\": \"\",\n      \"method\": \"\",\n      \"url\": \"\",\n      \"body\": {},\n      \"startedAt\": \"\",\n      \"endedAt\": \"\"\n    }\n  ]\n}"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// Bad request, invalid parameters.\n"
        },
        {
          "id": "response-2-422",
          "language": "422",
          "code": "// Unprocessable Entity, too many operations\n"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}