<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>k6/http on Grafana Labs</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/</link><description>Recent content in k6/http on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/k6/v2.3.x/javascript-api/k6-http/index.xml" rel="self" type="application/rss+xml"/><item><title>asyncRequest( method, url, [body], [params] )</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/asyncrequest/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/asyncrequest/</guid><content><![CDATA[&lt;h1 id=&#34;asyncrequest-method-url-body-params-&#34;&gt;asyncRequest( method, url, [body], [params] )&lt;/h1&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Parameter&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;method&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Request method (e.g. &lt;code&gt;&#39;POST&#39;&lt;/code&gt;). Must be uppercase.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;url&lt;/td&gt;
              &lt;td&gt;string /
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/url/#returns&#34;&gt;HTTP URL&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Request URL (e.g. &lt;code&gt;&#39;http://example.com&#39;&lt;/code&gt;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;body (optional)&lt;/td&gt;
              &lt;td&gt;string / object / ArrayBuffer&lt;/td&gt;
              &lt;td&gt;Request body. Objects will be &lt;code&gt;x-www-form-urlencoded&lt;/code&gt; encoded.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;params (optional)&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/params/&#34;&gt;Params&lt;/a&gt; object containing additional request parameters.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;returns&#34;&gt;Returns&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Promise with Response&lt;/td&gt;
              &lt;td&gt;HTTP 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/response/&#34;&gt;Response&lt;/a&gt; object.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;

&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;When you enable the experimental 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/feature-flags/&#34;&gt;&lt;code&gt;async-metric-context&lt;/code&gt; feature flag&lt;/a&gt;, Promise reactions created by &lt;code&gt;await&lt;/code&gt; or &lt;code&gt;.then()&lt;/code&gt; keep the metric context active when you register them. If you call &lt;code&gt;asyncRequest()&lt;/code&gt; from an async group, its HTTP metrics and metrics emitted after &lt;code&gt;await&lt;/code&gt; keep the group&amp;rsquo;s tags and metadata.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h3 id=&#34;examples&#34;&gt;Examples&lt;/h3&gt;
&lt;p&gt;Using http.asyncRequest() to issue a POST request:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;

const url = &amp;#39;https://quickpizza.grafana.com/api/post&amp;#39;;

export default async function () {
  const data = { name: &amp;#39;Bert&amp;#39; };

  // Using a JSON string as body
  const res = await http.asyncRequest(&amp;#39;POST&amp;#39;, url, JSON.stringify(data), {
    headers: { &amp;#39;Content-Type&amp;#39;: &amp;#39;application/json&amp;#39; },
  });
  console.log(res.json().name); // Bert

  // Using an object as body, the headers will automatically include
  // &amp;#39;Content-Type: application/x-www-form-urlencoded&amp;#39;.
  await http.asyncRequest(&amp;#39;POST&amp;#39;, url, data);
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Using &lt;code&gt;http.asyncRequest()&lt;/code&gt; to issue multiple requests, then &lt;a href=&#34;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Promise.race&lt;/a&gt; to determine which requests finish first:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;

export default async () =&amp;gt; {
  const urlOne = `https://quickpizza.grafana.com/api/delay/${randomInt(1, 5)}`;
  const urlTwo = `https://quickpizza.grafana.com/api/delay/${randomInt(1, 5)}`;
  const urlThree = `https://quickpizza.grafana.com/api/delay/${randomInt(1, 5)}`;

  const one = http.asyncRequest(&amp;#39;GET&amp;#39;, urlOne);
  const two = http.asyncRequest(&amp;#39;GET&amp;#39;, urlTwo);
  const three = http.asyncRequest(&amp;#39;GET&amp;#39;, urlThree);

  console.log(&amp;#39;Racing:&amp;#39;);
  console.log(urlOne);
  console.log(urlTwo);
  console.log(urlThree);

  const res = await Promise.race([one, two, three]);
  console.log(&amp;#39;winner is&amp;#39;, res.url, &amp;#39;with duration of&amp;#39;, res.timings.duration &amp;#43; &amp;#39;ms&amp;#39;);
};

function randomInt(min, max) {
  return Math.floor(Math.random() * (max - min) &amp;#43; min);
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;&lt;code&gt;http.asyncRequest&lt;/code&gt; has no current way to abort a request.&lt;/p&gt;
&lt;p&gt;In the preceding script, after &lt;code&gt;res&lt;/code&gt; gets the value from the fastest request, the other requests will continue to execute.
This might block the end of the iteration, because the iteration only stops once all async jobs finish.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

]]></content><description>&lt;h1 id="asyncrequest-method-url-body-params-">asyncRequest( method, url, [body], [params] )&lt;/h1>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Parameter&lt;/th>
&lt;th>Type&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>method&lt;/td>
&lt;td>string&lt;/td>
&lt;td>Request method (e.g. &lt;code>'POST'&lt;/code>). Must be uppercase.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>url&lt;/td>
&lt;td>string /
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/url/#returns">HTTP URL&lt;/a>&lt;/td>
&lt;td>Request URL (e.g. &lt;code>'http://example.com'&lt;/code>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>body (optional)&lt;/td>
&lt;td>string / object / ArrayBuffer&lt;/td>
&lt;td>Request body. Objects will be &lt;code>x-www-form-urlencoded&lt;/code> encoded.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>params (optional)&lt;/td>
&lt;td>object&lt;/td>
&lt;td>
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/params/">Params&lt;/a> object containing additional request parameters.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;h3 id="returns">Returns&lt;/h3>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Type&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Promise with Response&lt;/td>
&lt;td>HTTP
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/response/">Response&lt;/a> object.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>
&lt;div class="admonition admonition-note">&lt;blockquote>&lt;p class="title text-uppercase">Note&lt;/p></description></item><item><title>batch( requests )</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/batch/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/batch/</guid><content><![CDATA[&lt;h1 id=&#34;batch-requests-&#34;&gt;batch( requests )&lt;/h1&gt;
&lt;p&gt;Batch multiple HTTP requests together to issue them in parallel over multiple TCP connections.
To set batch size, use the 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/k6-options/reference/#batch-per-host&#34;&gt;batch per host&lt;/a&gt; option.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Parameter&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;requests&lt;/td&gt;
              &lt;td&gt;array | object&lt;/td&gt;
              &lt;td&gt;An array or object containing requests, in string or object form&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;request-definition&#34;&gt;Request definition&lt;/h3&gt;
&lt;p&gt;You have multiple ways to structure batch requests:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In an array of arrays&lt;/li&gt;
&lt;li&gt;As an object or array of objects&lt;/li&gt;
&lt;li&gt;As an array of URL strings&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Defining batch requests as URL strings is a shortcut for GET requests.
You can use this GET shortcut in objects—name a key and give it a URL value
(refer to subsequent sections for example syntax).&lt;/p&gt;
&lt;h4 id=&#34;array-and-object&#34;&gt;Array and Object&lt;/h4&gt;
&lt;p&gt;You can define a request specified as an array or object with the following parameters.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-caution&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Caution&lt;/p&gt;&lt;p&gt;When you define requests as an array, you must use a specific order of items.
Note the &lt;code&gt;Position&lt;/code&gt; column for the correct order.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Array position&lt;/th&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;1&lt;/td&gt;
              &lt;td&gt;method&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Mandatory. The HTTP method of the request. One of GET, POST, PUT, PATCH, DELETE, HEAD or OPTION.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;2&lt;/td&gt;
              &lt;td&gt;url&lt;/td&gt;
              &lt;td&gt;string /
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/url/#returns&#34;&gt;HTTP URL&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Mandatory. The URL to request.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;3&lt;/td&gt;
              &lt;td&gt;body (optional)&lt;/td&gt;
              &lt;td&gt;string / object / ArrayBuffer&lt;/td&gt;
              &lt;td&gt;The body of the request if relevant. Can be set to &lt;code&gt;null&lt;/code&gt; if not applicable but you want to set the last &lt;code&gt;params&lt;/code&gt; argument.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;4&lt;/td&gt;
              &lt;td&gt;params (optional)&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/params/&#34;&gt;Params&lt;/a&gt; like auth, custom headers and tags.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h4 id=&#34;string&#34;&gt;String&lt;/h4&gt;
&lt;p&gt;If you pass an array of string values, k6 automatically parses them into a batch of &lt;code&gt;GET&lt;/code&gt; requests, where the target is the value of the strings.&lt;/p&gt;
&lt;h3 id=&#34;returns&#34;&gt;Returns&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;The returned object contains 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/response/&#34;&gt;Response&lt;/a&gt; objects.&lt;br /&gt;&lt;br /&gt;It is an array when users pass an array as &lt;code&gt;requests&lt;/code&gt;, and is an ordinary object with string keys when named requests are used (see below).&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example-with-arrays&#34;&gt;Example with arrays&lt;/h3&gt;
&lt;p&gt;This example batches three URLs in arrays for parallel fetching:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;
import { check } from &amp;#39;k6&amp;#39;;

export default function () {
  const responses = http.batch([
    [&amp;#39;GET&amp;#39;, &amp;#39;https://test.k6.io&amp;#39;, null, { tags: { ctype: &amp;#39;html&amp;#39; } }],
    [&amp;#39;GET&amp;#39;, &amp;#39;https://test.k6.io/style.css&amp;#39;, null, { tags: { ctype: &amp;#39;css&amp;#39; } }],
    [&amp;#39;GET&amp;#39;, &amp;#39;https://test.k6.io/images/logo.png&amp;#39;, null, { tags: { ctype: &amp;#39;images&amp;#39; } }],
  ]);
  check(responses[0], {
    &amp;#39;main page status was 200&amp;#39;: (res) =&amp;gt; res.status === 200,
  });
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;example-with-request-objects&#34;&gt;Example with request objects&lt;/h3&gt;
&lt;p&gt;This example uses objects to define a batch of POST requests (along with custom HTTP headers in a 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/params/&#34;&gt;Params&lt;/a&gt; object to the request):&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;
import { check } from &amp;#39;k6&amp;#39;;

export default function () {
  const req1 = {
    method: &amp;#39;GET&amp;#39;,
    url: &amp;#39;https://quickpizza.grafana.com/api/get&amp;#39;,
  };
  const req2 = {
    method: &amp;#39;DELETE&amp;#39;,
    url: &amp;#39;https://quickpizza.grafana.com/api/delete&amp;#39;,
  };
  const req3 = {
    method: &amp;#39;POST&amp;#39;,
    url: &amp;#39;https://quickpizza.grafana.com/api/post&amp;#39;,
    body: JSON.stringify({ hello: &amp;#39;world!&amp;#39; }),
    params: {
      headers: { &amp;#39;Content-Type&amp;#39;: &amp;#39;application/json&amp;#39; },
    },
  };
  const responses = http.batch([req1, req2, req3]);
  // QuickPizza should return our POST data in the response body, so
  // we check the third response object to see that the POST worked.
  check(responses[2], {
    &amp;#39;form data OK&amp;#39;: (res) =&amp;gt; JSON.parse(res.body)[&amp;#39;hello&amp;#39;] == &amp;#39;world!&amp;#39;,
  });
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;In the preceding example, &lt;code&gt;req1&lt;/code&gt; can happen before &lt;code&gt;req2&lt;/code&gt; or &lt;code&gt;req3&lt;/code&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h3 id=&#34;example-with-array-of-strings&#34;&gt;Example with array of strings&lt;/h3&gt;
&lt;p&gt;This example uses an array of URL strings to send a batch of GET requests.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import { check } from &amp;#39;k6&amp;#39;;
import http from &amp;#39;k6/http&amp;#39;;

export default function () {
  const responses = http.batch([&amp;#39;http://test.k6.io&amp;#39;, &amp;#39;http://test.k6.io/pi.php&amp;#39;]);

  check(responses[0], {
    &amp;#39;main page 200&amp;#39;: (res) =&amp;gt; res.status === 200,
  });

  check(responses[1], {
    &amp;#39;pi page 200&amp;#39;: (res) =&amp;gt; res.status === 200,
    &amp;#39;pi page has right content&amp;#39;: (res) =&amp;gt; res.body === &amp;#39;3.14&amp;#39;,
  });
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;example-object-with-named-properties&#34;&gt;Example object with named properties&lt;/h3&gt;
&lt;p&gt;Finally, you can also send in named requests by using an object instead of an array as the parameter to &lt;code&gt;http.batch()&lt;/code&gt;.
This example mixes string URLs and request objects.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;
import { check } from &amp;#39;k6&amp;#39;;

export default function () {
  const requests = {
    &amp;#39;front page&amp;#39;: &amp;#39;https://k6.io&amp;#39;,
    &amp;#39;features page&amp;#39;: {
      method: &amp;#39;GET&amp;#39;,
      url: &amp;#39;https://k6.io/features&amp;#39;,
      params: { headers: { &amp;#39;User-Agent&amp;#39;: &amp;#39;k6&amp;#39; } },
    },
  };
  const responses = http.batch(requests);
  // when accessing results, we use the name of the request as index
  // in order to find the corresponding Response object
  check(responses[&amp;#39;front page&amp;#39;], {
    &amp;#39;front page status was 200&amp;#39;: (res) =&amp;gt; res.status === 200,
  });
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="batch-requests-">batch( requests )&lt;/h1>
&lt;p>Batch multiple HTTP requests together to issue them in parallel over multiple TCP connections.
To set batch size, use the
&lt;a href="/docs/k6/v2.3.x/using-k6/k6-options/reference/#batch-per-host">batch per host&lt;/a> option.&lt;/p></description></item><item><title>cookieJar()</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/cookiejar-method/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/cookiejar-method/</guid><content><![CDATA[&lt;h1 id=&#34;cookiejar&#34;&gt;cookieJar()&lt;/h1&gt;
&lt;p&gt;Get the active cookie jar.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/cookiejar/&#34;&gt;CookieJar&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;A CookieJar object.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;

export default function () {
  const jar = http.cookieJar();
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="cookiejar">cookieJar()&lt;/h1>
&lt;p>Get the active cookie jar.&lt;/p>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Type&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/cookiejar/">CookieJar&lt;/a>&lt;/td>
&lt;td>A CookieJar object.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;h3 id="example">Example&lt;/h3>
&lt;div class="code-snippet ">&lt;div class="lang-toolbar">
&lt;span class="lang-toolbar__item lang-toolbar__item-active">JavaScript&lt;/span>
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;div class="lang-toolbar__border">&lt;/div>
&lt;/div>&lt;div class="code-snippet ">
&lt;pre data-expanded="false">&lt;code class="language-javascript">import http from &amp;#39;k6/http&amp;#39;;
export default function () {
const jar = http.cookieJar();
}&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div></description></item><item><title>del( url, [body], [params] )</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/del/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/del/</guid><content><![CDATA[&lt;h1 id=&#34;del-url-body-params-&#34;&gt;del( url, [body], [params] )&lt;/h1&gt;
&lt;p&gt;Make a DELETE request.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Parameter&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;url&lt;/td&gt;
              &lt;td&gt;string /
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/url/#returns&#34;&gt;HTTP URL&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Request URL (e.g. &lt;code&gt;http://example.com&lt;/code&gt;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;body (optional, discouraged)&lt;/td&gt;
              &lt;td&gt;string / object / ArrayBuffer&lt;/td&gt;
              &lt;td&gt;Request body; objects will be &lt;code&gt;x-www-form-urlencoded&lt;/code&gt;. This is discouraged, because sending a DELETE request with a body has &lt;a href=&#34;https://tools.ietf.org/html/rfc7231#section-4.3.5&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;no defined semantics&lt;/a&gt; and may cause some servers to reject it.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;params (optional)&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/params/&#34;&gt;Params&lt;/a&gt; object containing additional request parameters.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;returns&#34;&gt;Returns&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Response&lt;/td&gt;
              &lt;td&gt;HTTP 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/response/&#34;&gt;Response&lt;/a&gt; object.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;

const url = &amp;#39;https://quickpizza.grafana.com/api/delete&amp;#39;;

export default function () {
  const params = { headers: { &amp;#39;X-MyHeader&amp;#39;: &amp;#39;k6test&amp;#39; } };
  http.del(url, null, params);
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="del-url-body-params-">del( url, [body], [params] )&lt;/h1>
&lt;p>Make a DELETE request.&lt;/p>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Parameter&lt;/th>
&lt;th>Type&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>url&lt;/td>
&lt;td>string /
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/url/#returns">HTTP URL&lt;/a>&lt;/td>
&lt;td>Request URL (e.g. &lt;code>http://example.com&lt;/code>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>body (optional, discouraged)&lt;/td>
&lt;td>string / object / ArrayBuffer&lt;/td>
&lt;td>Request body; objects will be &lt;code>x-www-form-urlencoded&lt;/code>. This is discouraged, because sending a DELETE request with a body has &lt;a href="https://tools.ietf.org/html/rfc7231#section-4.3.5" target="_blank" rel="noopener noreferrer">no defined semantics&lt;/a> and may cause some servers to reject it.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>params (optional)&lt;/td>
&lt;td>object&lt;/td>
&lt;td>
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/params/">Params&lt;/a> object containing additional request parameters.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;h3 id="returns">Returns&lt;/h3>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Type&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Response&lt;/td>
&lt;td>HTTP
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/response/">Response&lt;/a> object.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;h3 id="example">Example&lt;/h3>
&lt;div class="code-snippet ">&lt;div class="lang-toolbar">
&lt;span class="lang-toolbar__item lang-toolbar__item-active">JavaScript&lt;/span>
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;div class="lang-toolbar__border">&lt;/div>
&lt;/div>&lt;div class="code-snippet ">
&lt;pre data-expanded="false">&lt;code class="language-javascript">import http from &amp;#39;k6/http&amp;#39;;
const url = &amp;#39;https://quickpizza.grafana.com/api/delete&amp;#39;;
export default function () {
const params = { headers: { &amp;#39;X-MyHeader&amp;#39;: &amp;#39;k6test&amp;#39; } };
http.del(url, null, params);
}&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div></description></item><item><title>file( data, [filename], [contentType] )</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/file/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/file/</guid><content><![CDATA[&lt;h1 id=&#34;file-data-filename-contenttype-&#34;&gt;file( data, [filename], [contentType] )&lt;/h1&gt;
&lt;p&gt;Create a file object that is used for building 
    &lt;a href=&#34;/docs/k6/v2.3.x/examples/data-uploads/#multipart-request-uploading-a-file&#34;&gt;Multipart requests (file uploads)&lt;/a&gt;.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Parameter&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;data&lt;/td&gt;
              &lt;td&gt;string / Array / ArrayBuffer&lt;/td&gt;
              &lt;td&gt;File data as string, array of numbers, or an &lt;code&gt;ArrayBuffer&lt;/code&gt; object.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;filename&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;The filename to specify for this field (or &amp;ldquo;part&amp;rdquo;) of the multipart request.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;contentType&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;The content type to specify for this field (or &amp;ldquo;part&amp;rdquo;) of the multipart request.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;returns&#34;&gt;Returns&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/filedata/&#34;&gt;FileData&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;A FileData object.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;
&lt;!-- md-k6:skip --&gt;
&lt;!-- Requires a user-provided file at /path/to/file.bin. --&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import { sleep } from &amp;#39;k6&amp;#39;;
import { md5 } from &amp;#39;k6/crypto&amp;#39;;
import http from &amp;#39;k6/http&amp;#39;;

const binFile = open(&amp;#39;/path/to/file.bin&amp;#39;, &amp;#39;b&amp;#39;);

export default function () {
  const f = http.file(binFile, &amp;#39;test.bin&amp;#39;);
  console.log(md5(f.data, &amp;#39;hex&amp;#39;));
  console.log(f.filename);
  console.log(f.content_type);
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="file-data-filename-contenttype-">file( data, [filename], [contentType] )&lt;/h1>
&lt;p>Create a file object that is used for building
&lt;a href="/docs/k6/v2.3.x/examples/data-uploads/#multipart-request-uploading-a-file">Multipart requests (file uploads)&lt;/a>.&lt;/p>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Parameter&lt;/th>
&lt;th>Type&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>data&lt;/td>
&lt;td>string / Array / ArrayBuffer&lt;/td>
&lt;td>File data as string, array of numbers, or an &lt;code>ArrayBuffer&lt;/code> object.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>filename&lt;/td>
&lt;td>string&lt;/td>
&lt;td>The filename to specify for this field (or &amp;ldquo;part&amp;rdquo;) of the multipart request.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>contentType&lt;/td>
&lt;td>string&lt;/td>
&lt;td>The content type to specify for this field (or &amp;ldquo;part&amp;rdquo;) of the multipart request.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;h3 id="returns">Returns&lt;/h3>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Type&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/filedata/">FileData&lt;/a>&lt;/td>
&lt;td>A FileData object.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;h3 id="example">Example&lt;/h3>
&lt;!-- md-k6:skip -->
&lt;!-- Requires a user-provided file at /path/to/file.bin. -->
&lt;div class="code-snippet ">&lt;div class="lang-toolbar">
&lt;span class="lang-toolbar__item lang-toolbar__item-active">JavaScript&lt;/span>
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;div class="lang-toolbar__border">&lt;/div>
&lt;/div>&lt;div class="code-snippet ">
&lt;pre data-expanded="false">&lt;code class="language-javascript">import { sleep } from &amp;#39;k6&amp;#39;;
import { md5 } from &amp;#39;k6/crypto&amp;#39;;
import http from &amp;#39;k6/http&amp;#39;;
const binFile = open(&amp;#39;/path/to/file.bin&amp;#39;, &amp;#39;b&amp;#39;);
export default function () {
const f = http.file(binFile, &amp;#39;test.bin&amp;#39;);
console.log(md5(f.data, &amp;#39;hex&amp;#39;));
console.log(f.filename);
console.log(f.content_type);
}&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div></description></item><item><title>get( url, [params] )</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/get/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/get/</guid><content><![CDATA[&lt;h1 id=&#34;get-url-params-&#34;&gt;get( url, [params] )&lt;/h1&gt;
&lt;p&gt;Make a GET request.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Parameter&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;url&lt;/td&gt;
              &lt;td&gt;string /
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/url/#returns&#34;&gt;HTTP URL&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Request URL (e.g. &lt;code&gt;http://example.com&lt;/code&gt;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;params (optional)&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/params/&#34;&gt;Params&lt;/a&gt; object containing additional request parameters.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;returns&#34;&gt;Returns&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/response/&#34;&gt;Response&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;HTTP Response object.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example-fetching-a-url&#34;&gt;Example fetching a URL&lt;/h3&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;

export default function () {
  const res = http.get(&amp;#39;https://test.k6.io&amp;#39;);
  console.log(JSON.stringify(res.headers));
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="get-url-params-">get( url, [params] )&lt;/h1>
&lt;p>Make a GET request.&lt;/p>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Parameter&lt;/th>
&lt;th>Type&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>url&lt;/td>
&lt;td>string /
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/url/#returns">HTTP URL&lt;/a>&lt;/td>
&lt;td>Request URL (e.g. &lt;code>http://example.com&lt;/code>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>params (optional)&lt;/td>
&lt;td>object&lt;/td>
&lt;td>
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/params/">Params&lt;/a> object containing additional request parameters.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;h3 id="returns">Returns&lt;/h3>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Type&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/response/">Response&lt;/a>&lt;/td>
&lt;td>HTTP Response object.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;h3 id="example-fetching-a-url">Example fetching a URL&lt;/h3>
&lt;div class="code-snippet ">&lt;div class="lang-toolbar">
&lt;span class="lang-toolbar__item lang-toolbar__item-active">JavaScript&lt;/span>
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;div class="lang-toolbar__border">&lt;/div>
&lt;/div>&lt;div class="code-snippet ">
&lt;pre data-expanded="false">&lt;code class="language-javascript">import http from &amp;#39;k6/http&amp;#39;;
export default function () {
const res = http.get(&amp;#39;https://test.k6.io&amp;#39;);
console.log(JSON.stringify(res.headers));
}&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div></description></item><item><title>head( url, [params] )</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/head/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/head/</guid><content><![CDATA[&lt;h1 id=&#34;head-url-params-&#34;&gt;head( url, [params] )&lt;/h1&gt;
&lt;p&gt;Make a HEAD request.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Parameter&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;url&lt;/td&gt;
              &lt;td&gt;string /
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/url/#returns&#34;&gt;HTTP URL&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Request URL (e.g. &lt;code&gt;http://example.com&lt;/code&gt;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;params (optional)&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/params/&#34;&gt;Params&lt;/a&gt; object containing additional request parameters.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;returns&#34;&gt;Returns&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/response/&#34;&gt;Response&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;HTTP Response object.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example-fetching-a-url&#34;&gt;Example fetching a URL&lt;/h3&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;

export default function () {
  const res = http.head(&amp;#39;https://test.k6.io&amp;#39;);
  console.log(JSON.stringify(res.headers));
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="head-url-params-">head( url, [params] )&lt;/h1>
&lt;p>Make a HEAD request.&lt;/p>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Parameter&lt;/th>
&lt;th>Type&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>url&lt;/td>
&lt;td>string /
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/url/#returns">HTTP URL&lt;/a>&lt;/td>
&lt;td>Request URL (e.g. &lt;code>http://example.com&lt;/code>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>params (optional)&lt;/td>
&lt;td>object&lt;/td>
&lt;td>
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/params/">Params&lt;/a> object containing additional request parameters.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;h3 id="returns">Returns&lt;/h3>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Type&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/response/">Response&lt;/a>&lt;/td>
&lt;td>HTTP Response object.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;h3 id="example-fetching-a-url">Example fetching a URL&lt;/h3>
&lt;div class="code-snippet ">&lt;div class="lang-toolbar">
&lt;span class="lang-toolbar__item lang-toolbar__item-active">JavaScript&lt;/span>
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;div class="lang-toolbar__border">&lt;/div>
&lt;/div>&lt;div class="code-snippet ">
&lt;pre data-expanded="false">&lt;code class="language-javascript">import http from &amp;#39;k6/http&amp;#39;;
export default function () {
const res = http.head(&amp;#39;https://test.k6.io&amp;#39;);
console.log(JSON.stringify(res.headers));
}&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div></description></item><item><title>options( url, [body], [params] )</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/options/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/options/</guid><content><![CDATA[&lt;h1 id=&#34;options-url-body-params-&#34;&gt;options( url, [body], [params] )&lt;/h1&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Parameter&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;url&lt;/td&gt;
              &lt;td&gt;string /
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/url/#returns&#34;&gt;HTTP URL&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Request URL (e.g. &lt;code&gt;http://example.com&lt;/code&gt;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;body (optional)&lt;/td&gt;
              &lt;td&gt;string / object / ArrayBuffer&lt;/td&gt;
              &lt;td&gt;Request body; objects will be &lt;code&gt;x-www-form-urlencoded&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;params (optional)&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/params/&#34;&gt;Params&lt;/a&gt; object containing additional request parameters.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;returns&#34;&gt;Returns&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Response&lt;/td&gt;
              &lt;td&gt;HTTP 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/response/&#34;&gt;Response&lt;/a&gt; object.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;

const url = &amp;#39;https://quickpizza.grafana.com/&amp;#39;;

export default function () {
  const params = { headers: { &amp;#39;X-MyHeader&amp;#39;: &amp;#39;k6test&amp;#39; } };
  const res = http.options(url, null, params);
  console.log(res.headers[&amp;#39;Allow&amp;#39;]);
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="options-url-body-params-">options( url, [body], [params] )&lt;/h1>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Parameter&lt;/th>
&lt;th>Type&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>url&lt;/td>
&lt;td>string /
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/url/#returns">HTTP URL&lt;/a>&lt;/td>
&lt;td>Request URL (e.g. &lt;code>http://example.com&lt;/code>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>body (optional)&lt;/td>
&lt;td>string / object / ArrayBuffer&lt;/td>
&lt;td>Request body; objects will be &lt;code>x-www-form-urlencoded&lt;/code>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>params (optional)&lt;/td>
&lt;td>object&lt;/td>
&lt;td>
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/params/">Params&lt;/a> object containing additional request parameters.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;h3 id="returns">Returns&lt;/h3>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Type&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Response&lt;/td>
&lt;td>HTTP
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/response/">Response&lt;/a> object.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;h3 id="example">Example&lt;/h3>
&lt;div class="code-snippet ">&lt;div class="lang-toolbar">
&lt;span class="lang-toolbar__item lang-toolbar__item-active">JavaScript&lt;/span>
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;div class="lang-toolbar__border">&lt;/div>
&lt;/div>&lt;div class="code-snippet ">
&lt;pre data-expanded="false">&lt;code class="language-javascript">import http from &amp;#39;k6/http&amp;#39;;
const url = &amp;#39;https://quickpizza.grafana.com/&amp;#39;;
export default function () {
const params = { headers: { &amp;#39;X-MyHeader&amp;#39;: &amp;#39;k6test&amp;#39; } };
const res = http.options(url, null, params);
console.log(res.headers[&amp;#39;Allow&amp;#39;]);
}&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div></description></item><item><title>patch( url, [body], [params] )</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/patch/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/patch/</guid><content><![CDATA[&lt;h1 id=&#34;patch-url-body-params-&#34;&gt;patch( url, [body], [params] )&lt;/h1&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Parameter&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;url&lt;/td&gt;
              &lt;td&gt;string /
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/url/#returns&#34;&gt;HTTP URL&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Request URL (e.g. &lt;code&gt;http://example.com&lt;/code&gt;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;body (optional)&lt;/td&gt;
              &lt;td&gt;string / object / ArrayBuffer&lt;/td&gt;
              &lt;td&gt;Request body; objects will be &lt;code&gt;x-www-form-urlencoded&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;params (optional)&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/params/&#34;&gt;Params&lt;/a&gt; object containing additional request parameters&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;returns&#34;&gt;Returns&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/response/&#34;&gt;Response&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;HTTP Response object.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;

const url = &amp;#39;https://quickpizza.grafana.com/api/patch&amp;#39;;

export default function () {
  const headers = { &amp;#39;Content-Type&amp;#39;: &amp;#39;application/json&amp;#39; };
  const data = { name: &amp;#39;Bert&amp;#39; };

  const res = http.patch(url, JSON.stringify(data), { headers: headers });

  console.log(JSON.parse(res.body).name);
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="patch-url-body-params-">patch( url, [body], [params] )&lt;/h1>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Parameter&lt;/th>
&lt;th>Type&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>url&lt;/td>
&lt;td>string /
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/url/#returns">HTTP URL&lt;/a>&lt;/td>
&lt;td>Request URL (e.g. &lt;code>http://example.com&lt;/code>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>body (optional)&lt;/td>
&lt;td>string / object / ArrayBuffer&lt;/td>
&lt;td>Request body; objects will be &lt;code>x-www-form-urlencoded&lt;/code>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>params (optional)&lt;/td>
&lt;td>object&lt;/td>
&lt;td>
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/params/">Params&lt;/a> object containing additional request parameters&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;h3 id="returns">Returns&lt;/h3>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Type&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/response/">Response&lt;/a>&lt;/td>
&lt;td>HTTP Response object.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;h3 id="example">Example&lt;/h3>
&lt;div class="code-snippet ">&lt;div class="lang-toolbar">
&lt;span class="lang-toolbar__item lang-toolbar__item-active">JavaScript&lt;/span>
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;div class="lang-toolbar__border">&lt;/div>
&lt;/div>&lt;div class="code-snippet ">
&lt;pre data-expanded="false">&lt;code class="language-javascript">import http from &amp;#39;k6/http&amp;#39;;
const url = &amp;#39;https://quickpizza.grafana.com/api/patch&amp;#39;;
export default function () {
const headers = { &amp;#39;Content-Type&amp;#39;: &amp;#39;application/json&amp;#39; };
const data = { name: &amp;#39;Bert&amp;#39; };
const res = http.patch(url, JSON.stringify(data), { headers: headers });
console.log(JSON.parse(res.body).name);
}&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div></description></item><item><title>post( url, [body], [params] )</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/post/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/post/</guid><content><![CDATA[&lt;h1 id=&#34;post-url-body-params-&#34;&gt;post( url, [body], [params] )&lt;/h1&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Parameter&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;url&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string /
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/url/#returns&#34;&gt;HTTP URL&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Request URL (e.g. &lt;code&gt;http://example.com&lt;/code&gt;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;body&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string / object / ArrayBuffer&lt;/td&gt;
              &lt;td&gt;Request body; objects will be &lt;code&gt;x-www-form-urlencoded&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;params&lt;/code&gt; (optional)&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/params/&#34;&gt;Params&lt;/a&gt; object containing additional request parameters&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;For object bodies without file uploads, refer to the 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/request/#form-encoded-request-bodies&#34;&gt;form encoding rules&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;returns&#34;&gt;Returns&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;HTTP 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/response/&#34;&gt;Response&lt;/a&gt; object.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;
&lt;!-- md-k6:skip --&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;

const url = &amp;#39;https://quickpizza.grafana.com/api/json&amp;#39;;
const logoBin = open(&amp;#39;./logo.png&amp;#39;, &amp;#39;b&amp;#39;);

export default function () {
  let data = { name: &amp;#39;Bert&amp;#39; };

  // Using a JSON string as body
  let res = http.post(url, JSON.stringify(data), {
    headers: { &amp;#39;Content-Type&amp;#39;: &amp;#39;application/json&amp;#39; },
  });
  console.log(res.json().json.name); // Bert

  // Using an object as body, the headers will automatically include
  // &amp;#39;Content-Type: application/x-www-form-urlencoded&amp;#39;.
  res = http.post(url, data);
  console.log(res.json().form.name); // Bert

  // Using a binary array as body. Make sure to open() the file as binary
  // (with the &amp;#39;b&amp;#39; argument).
  http.post(url, logoBin, { headers: { &amp;#39;Content-Type&amp;#39;: &amp;#39;image/png&amp;#39; } });

  // Using an ArrayBuffer as body. Make sure to pass the underlying ArrayBuffer
  // instance to http.post(), and not the TypedArray view.
  data = new Uint8Array([104, 101, 108, 108, 111]);
  http.post(url, data.buffer, { headers: { &amp;#39;Content-Type&amp;#39;: &amp;#39;image/png&amp;#39; } });
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="post-url-body-params-">post( url, [body], [params] )&lt;/h1>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Parameter&lt;/th>
&lt;th>Type&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>url&lt;/code>&lt;/td>
&lt;td>string /
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/url/#returns">HTTP URL&lt;/a>&lt;/td>
&lt;td>Request URL (e.g. &lt;code>http://example.com&lt;/code>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>body&lt;/code>&lt;/td>
&lt;td>string / object / ArrayBuffer&lt;/td>
&lt;td>Request body; objects will be &lt;code>x-www-form-urlencoded&lt;/code>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>params&lt;/code> (optional)&lt;/td>
&lt;td>object&lt;/td>
&lt;td>
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/params/">Params&lt;/a> object containing additional request parameters&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;p>For object bodies without file uploads, refer to the
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/request/#form-encoded-request-bodies">form encoding rules&lt;/a>.&lt;/p></description></item><item><title>put( url, [body], [params] )</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/put/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/put/</guid><content><![CDATA[&lt;h1 id=&#34;put-url-body-params-&#34;&gt;put( url, [body], [params] )&lt;/h1&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Parameter&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;url&lt;/td&gt;
              &lt;td&gt;string /
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/url/#returns&#34;&gt;HTTP URL&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Request URL (e.g. &lt;code&gt;http://example.com&lt;/code&gt;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;body (optional)&lt;/td&gt;
              &lt;td&gt;string / object / ArrayBuffer&lt;/td&gt;
              &lt;td&gt;Request body; objects will be &lt;code&gt;x-www-form-urlencoded&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;params (optional)&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/params/&#34;&gt;Params&lt;/a&gt; object containing additional request parameters.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;returns&#34;&gt;Returns&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Response&lt;/td&gt;
              &lt;td&gt;HTTP 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/response/&#34;&gt;Response&lt;/a&gt; object.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;

const url = &amp;#39;https://quickpizza.grafana.com/api/put&amp;#39;;

export default function () {
  const headers = { &amp;#39;Content-Type&amp;#39;: &amp;#39;application/json&amp;#39; };
  const data = { name: &amp;#39;Bert&amp;#39; };

  const res = http.put(url, JSON.stringify(data), { headers: headers });

  console.log(JSON.parse(res.body).name);
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="put-url-body-params-">put( url, [body], [params] )&lt;/h1>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Parameter&lt;/th>
&lt;th>Type&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>url&lt;/td>
&lt;td>string /
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/url/#returns">HTTP URL&lt;/a>&lt;/td>
&lt;td>Request URL (e.g. &lt;code>http://example.com&lt;/code>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>body (optional)&lt;/td>
&lt;td>string / object / ArrayBuffer&lt;/td>
&lt;td>Request body; objects will be &lt;code>x-www-form-urlencoded&lt;/code>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>params (optional)&lt;/td>
&lt;td>object&lt;/td>
&lt;td>
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/params/">Params&lt;/a> object containing additional request parameters.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;h3 id="returns">Returns&lt;/h3>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Type&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Response&lt;/td>
&lt;td>HTTP
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/response/">Response&lt;/a> object.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;h3 id="example">Example&lt;/h3>
&lt;div class="code-snippet ">&lt;div class="lang-toolbar">
&lt;span class="lang-toolbar__item lang-toolbar__item-active">JavaScript&lt;/span>
&lt;span class="code-clipboard">
&lt;button x-data="app_code_snippet()" x-init="init()" @click="copy()">
&lt;img class="code-clipboard__icon" src="/media/images/icons/icon-copy-small-2.svg" alt="Copy code to clipboard" width="14" height="13">
&lt;span>Copy&lt;/span>
&lt;/button>
&lt;/span>
&lt;div class="lang-toolbar__border">&lt;/div>
&lt;/div>&lt;div class="code-snippet ">
&lt;pre data-expanded="false">&lt;code class="language-javascript">import http from &amp;#39;k6/http&amp;#39;;
const url = &amp;#39;https://quickpizza.grafana.com/api/put&amp;#39;;
export default function () {
const headers = { &amp;#39;Content-Type&amp;#39;: &amp;#39;application/json&amp;#39; };
const data = { name: &amp;#39;Bert&amp;#39; };
const res = http.put(url, JSON.stringify(data), { headers: headers });
console.log(JSON.parse(res.body).name);
}&lt;/code>&lt;/pre>
&lt;/div>
&lt;/div></description></item><item><title>request( method, url, [body], [params] )</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/request/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/request/</guid><content><![CDATA[&lt;h1 id=&#34;request-method-url-body-params-&#34;&gt;request( method, url, [body], [params] )&lt;/h1&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Parameter&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;method&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Request method (e.g. &lt;code&gt;&#39;POST&#39;&lt;/code&gt;). Must be uppercase.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;url&lt;/td&gt;
              &lt;td&gt;string /
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/url/#returns&#34;&gt;HTTP URL&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Request URL (e.g. &lt;code&gt;&#39;http://example.com&#39;&lt;/code&gt;).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;body (optional)&lt;/td&gt;
              &lt;td&gt;string / object / ArrayBuffer&lt;/td&gt;
              &lt;td&gt;Request body; Objects will be &lt;code&gt;x-www-form-urlencoded&lt;/code&gt; encoded.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;params (optional)&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/params/&#34;&gt;Params&lt;/a&gt; object containing additional request parameters.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;form-encoded-request-bodies&#34;&gt;Form-encoded request bodies&lt;/h3&gt;
&lt;p&gt;When you pass a JavaScript object as the body without file uploads, k6 encodes it as &lt;code&gt;application/x-www-form-urlencoded&lt;/code&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;null&lt;/code&gt; and &lt;code&gt;undefined&lt;/code&gt; become empty values, such as &lt;code&gt;name=&lt;/code&gt;. The field remains in the request.&lt;/li&gt;
&lt;li&gt;Arrays produce repeated keys, such as &lt;code&gt;tag=one&amp;amp;tag=two&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Nested objects and nested arrays become empty values and cause k6 to log a warning. This also applies to objects inside arrays.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For example, &lt;code&gt;{ name: null, tags: [&#39;one&#39;, null] }&lt;/code&gt; becomes &lt;code&gt;name=&amp;amp;tags=one&amp;amp;tags=&lt;/code&gt;.
To preserve nested data, serialize the body with &lt;code&gt;JSON.stringify()&lt;/code&gt; and set the &lt;code&gt;Content-Type&lt;/code&gt; header to &lt;code&gt;application/json&lt;/code&gt;. Setting the header alone does not convert an object body to JSON.&lt;/p&gt;
&lt;p&gt;These rules also apply to methods such as 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/post/&#34;&gt;post()&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;returns&#34;&gt;Returns&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Response&lt;/td&gt;
              &lt;td&gt;HTTP 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/response/&#34;&gt;Response&lt;/a&gt; object.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;
&lt;p&gt;Using http.request() to issue a POST request:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;

const url = &amp;#39;https://quickpizza.grafana.com/api/post&amp;#39;;

export default function () {
  const data = { name: &amp;#39;Bert&amp;#39; };

  // Using a JSON string as body
  let res = http.request(&amp;#39;POST&amp;#39;, url, JSON.stringify(data), {
    headers: { &amp;#39;Content-Type&amp;#39;: &amp;#39;application/json&amp;#39; },
  });
  console.log(res.json().name); // Bert

  // Using an object as body, the headers will automatically include
  // &amp;#39;Content-Type: application/x-www-form-urlencoded&amp;#39;.
  res = http.request(&amp;#39;POST&amp;#39;, url, data);
  console.log(res.body); // name=Bert
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="request-method-url-body-params-">request( method, url, [body], [params] )&lt;/h1>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Parameter&lt;/th>
&lt;th>Type&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>method&lt;/td>
&lt;td>string&lt;/td>
&lt;td>Request method (e.g. &lt;code>'POST'&lt;/code>). Must be uppercase.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>url&lt;/td>
&lt;td>string /
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/url/#returns">HTTP URL&lt;/a>&lt;/td>
&lt;td>Request URL (e.g. &lt;code>'http://example.com'&lt;/code>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>body (optional)&lt;/td>
&lt;td>string / object / ArrayBuffer&lt;/td>
&lt;td>Request body; Objects will be &lt;code>x-www-form-urlencoded&lt;/code> encoded.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>params (optional)&lt;/td>
&lt;td>object&lt;/td>
&lt;td>
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/params/">Params&lt;/a> object containing additional request parameters.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;h3 id="form-encoded-request-bodies">Form-encoded request bodies&lt;/h3>
&lt;p>When you pass a JavaScript object as the body without file uploads, k6 encodes it as &lt;code>application/x-www-form-urlencoded&lt;/code>:&lt;/p></description></item><item><title>setResponseCallback( callback )</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/set-response-callback/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/set-response-callback/</guid><content><![CDATA[&lt;h1 id=&#34;setresponsecallback-callback-&#34;&gt;setResponseCallback( callback )&lt;/h1&gt;
&lt;p&gt;Set the response callback to be called to determine if a response was expected/successful or not.&lt;/p&gt;
&lt;p&gt;The result of this is that requests will be tagged with &lt;code&gt;expected_response&lt;/code&gt; &lt;code&gt;&amp;quot;true&amp;quot;&lt;/code&gt; or &lt;code&gt;&amp;quot;false&amp;quot;&lt;/code&gt; and &lt;code&gt;http_req_failed&lt;/code&gt; will be emitted with the reverse. This does include all redirects so if for a request only 200 is the expected response and there is 301 redirect before that, the redirect will be marked as failed as only status code 200 was marked as expected.&lt;/p&gt;
&lt;h4 id=&#34;exceptions&#34;&gt;Exceptions&lt;/h4&gt;
&lt;p&gt;Due to implementation specifics:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Requests with authentication &lt;code&gt;digest&lt;/code&gt; are always expected to first get 401 and then to get whatever was specified.&lt;/li&gt;
&lt;li&gt;Requests with authentication &lt;code&gt;ntlm&lt;/code&gt; will let a 401 status code on the first request as well as anything defined by &lt;code&gt;expectedStatuses&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Parameter&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;callback&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/expected-statuses/&#34;&gt;expectedStatuses&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;an object returned from 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/expected-statuses/&#34;&gt;expectedStatuses&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Currently only the very special 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/expected-statuses/&#34;&gt;expectedStatuses&lt;/a&gt; objects are supported but in the future it is planned that a JavaScript callback will be supported as well. By default requests with status codes between 200 and 399 are considered &amp;ldquo;expected&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;Setting the callback to &lt;code&gt;null&lt;/code&gt; disables the tagging with &lt;code&gt;expected_response&lt;/code&gt; and the emitting of &lt;code&gt;http_req_failed&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;It is recommended that if a per request responseCallback is used with 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/params/&#34;&gt;Params&lt;/a&gt; it is actually defined once and used instead of creating it on each request.&lt;/p&gt;
&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;

http.setResponseCallback(http.expectedStatuses({ min: 200, max: 300 }));

const only300Callback = http.expectedStatuses(300);

export default () =&amp;gt; {
  // this will use the default response callback and be marked as successful
  http.get(&amp;#39;https://quickpizza.grafana.com/api/status/200&amp;#39;);

  // this will be marked as a failed request as it won&amp;#39;t get the expected status code of 300
  http.get(&amp;#39;https://quickpizza.grafana.com/api/status/200&amp;#39;, {
    responseCallback: only300Callback,
  });

  http.setResponseCallback(http.expectedStatuses(301));
  // from here on for this VU only the 301 status code will be successful so on the next iteration of
  // the VU the first request will be marked as failure
};&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="setresponsecallback-callback-">setResponseCallback( callback )&lt;/h1>
&lt;p>Set the response callback to be called to determine if a response was expected/successful or not.&lt;/p>
&lt;p>The result of this is that requests will be tagged with &lt;code>expected_response&lt;/code> &lt;code>&amp;quot;true&amp;quot;&lt;/code> or &lt;code>&amp;quot;false&amp;quot;&lt;/code> and &lt;code>http_req_failed&lt;/code> will be emitted with the reverse. This does include all redirects so if for a request only 200 is the expected response and there is 301 redirect before that, the redirect will be marked as failed as only status code 200 was marked as expected.&lt;/p></description></item><item><title>url\`url\`</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/url/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/url/</guid><content><![CDATA[&lt;h1 id=&#34;urlurl&#34;&gt;url`url`&lt;/h1&gt;
&lt;p&gt;URLs that contain dynamic parts can introduce a large number of unique URLs in the metrics stream. You can use &lt;code&gt;http.url&lt;/code&gt; to set a consistent name tag in your requests to remedy this issue. Read more on 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/http-requests/#url-grouping&#34;&gt;URL Grouping&lt;/a&gt;.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Parameter&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;url&lt;/td&gt;
              &lt;td&gt;template literal&lt;/td&gt;
              &lt;td&gt;Request URL (e.g. &lt;code&gt;http://example.com&lt;/code&gt;).&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;returns&#34;&gt;Returns&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;HTTP URL&lt;/td&gt;
              &lt;td&gt;HTTP URL object.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;

export default function () {
  for (let id = 1; id &amp;lt;= 100; id&amp;#43;&amp;#43;) {
    // tags.name=&amp;#34;https://test.k6.io?id=${}&amp;#34;,
    http.get(http.url`https://test.k6.io?id=${id}`);
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="urlurl">url`url`&lt;/h1>
&lt;p>URLs that contain dynamic parts can introduce a large number of unique URLs in the metrics stream. You can use &lt;code>http.url&lt;/code> to set a consistent name tag in your requests to remedy this issue. Read more on
&lt;a href="/docs/k6/v2.3.x/using-k6/http-requests/#url-grouping">URL Grouping&lt;/a>.&lt;/p></description></item><item><title>expectedStatuses( statuses )</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/expected-statuses/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/expected-statuses/</guid><content><![CDATA[&lt;h1 id=&#34;expectedstatuses-statuses-&#34;&gt;expectedStatuses( statuses )&lt;/h1&gt;
&lt;p&gt;Returns a callback to be used with 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/set-response-callback/&#34;&gt;setResponseCallback&lt;/a&gt; to mark responses as expected based only on their status codes.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Parameter&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;statuses&lt;/td&gt;
              &lt;td&gt;integer/objects&lt;/td&gt;
              &lt;td&gt;either an integer or an object like {min:100, max:300} which gives a minimum and maximum expected status codes&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;You can have as many arguments as wanted in any order.&lt;/p&gt;
&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;

// setting some pretty strange status codes as expected
http.setResponseCallback(
  http.expectedStatuses(406, 500, { min: 200, max: 204 }, 302, { min: 305, max: 405 })
);

export default () =&amp;gt; {
  // this one will actually be marked as failed as it doesn&amp;#39;t match any of the above listed status
  // codes
  http.get(&amp;#39;https://quickpizza.grafana.com/api/status/205&amp;#39;);
};&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="expectedstatuses-statuses-">expectedStatuses( statuses )&lt;/h1>
&lt;p>Returns a callback to be used with
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/set-response-callback/">setResponseCallback&lt;/a> to mark responses as expected based only on their status codes.&lt;/p>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Parameter&lt;/th>
&lt;th>Type&lt;/th>
&lt;th>Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>statuses&lt;/td>
&lt;td>integer/objects&lt;/td>
&lt;td>either an integer or an object like {min:100, max:300} which gives a minimum and maximum expected status codes&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;p>You can have as many arguments as wanted in any order.&lt;/p></description></item><item><title>CookieJar</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/cookiejar/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/cookiejar/</guid><content><![CDATA[&lt;h1 id=&#34;cookiejar&#34;&gt;CookieJar&lt;/h1&gt;
&lt;p&gt;&lt;em&gt;CookieJar&lt;/em&gt; is an object for storing cookies that are set by the server, added by the client, or both. As described in the how-to guide on using 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/cookies/&#34;&gt;Cookies&lt;/a&gt;, k6 handles cookies automatically by default. If you need more control over cookies you can however create your own cookie jar and select it as the active jar (instead of the default one created by k6) for one or more requests.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Method&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/cookiejar/cookiejar-cookiesforurl/&#34;&gt;cookiesForURL(url)&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Get Object of cookies where the key is the cookie name and the value is an array.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/cookiejar/cookiejar-set/&#34;&gt;set(url, name, value, [options])&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Set a cookie in the jar by specifying name, value and some other optional settings like domain, path etc.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/cookiejar/cookiejar-clear/&#34;&gt;clear(url)&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Delete all cookies for the given URL.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/cookiejar/cookiejar-delete/&#34;&gt;delete(url, name)&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Deletes the &lt;code&gt;name&lt;/code&gt; cookie for the given URL.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;
import { check } from &amp;#39;k6&amp;#39;;

export default function () {
  const res1 = http.post(&amp;#39;https://quickpizza.grafana.com/api/cookies?my_cookie=hello%20world&amp;#39;, {
    redirects: 0,
  });
  const jar = http.cookieJar();
  const cookies = jar.cookiesForURL(&amp;#39;https://quickpizza.grafana.com/api/cookies&amp;#39;);
  check(res1, {
    &amp;#34;has cookie &amp;#39;my_cookie&amp;#39;&amp;#34;: (r) =&amp;gt; cookies.my_cookie.length &amp;gt; 0,
    &amp;#39;cookie has correct value&amp;#39;: (r) =&amp;gt; cookies.my_cookie[0] === &amp;#39;hello world&amp;#39;,
  });

  jar.clear(&amp;#39;https://quickpizza.grafana.com/api/cookies&amp;#39;);

  const res2 = http.get(&amp;#39;https://quickpizza.grafana.com/api/cookies&amp;#39;);
  check(res2, {
    &amp;#39;has status 200&amp;#39;: (r) =&amp;gt; r.status === 200,
    &amp;#34;hasn&amp;#39;t cookie &amp;#39;my_cookie&amp;#39;&amp;#34;: (r) =&amp;gt; r.json().cookies.my_cookie == null,
  });
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="cookiejar">CookieJar&lt;/h1>
&lt;p>&lt;em>CookieJar&lt;/em> is an object for storing cookies that are set by the server, added by the client, or both. As described in the how-to guide on using
&lt;a href="/docs/k6/v2.3.x/using-k6/cookies/">Cookies&lt;/a>, k6 handles cookies automatically by default. If you need more control over cookies you can however create your own cookie jar and select it as the active jar (instead of the default one created by k6) for one or more requests.&lt;/p></description></item><item><title>FileData</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/filedata/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/filedata/</guid><content><![CDATA[&lt;h1 id=&#34;filedata&#34;&gt;FileData&lt;/h1&gt;
&lt;p&gt;&lt;em&gt;FileData&lt;/em&gt; is an object for wrapping data representing a file when doing

    &lt;a href=&#34;/docs/k6/v2.3.x/examples/data-uploads/#multipart-request-uploading-a-file&#34;&gt;multipart requests (file uploads)&lt;/a&gt;.
You create it by calling 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/file/&#34;&gt;http.file( data, [filename], [contentType] )&lt;/a&gt;.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;FileData.data&lt;/td&gt;
              &lt;td&gt;string / Array / ArrayBuffer&lt;/td&gt;
              &lt;td&gt;File data as string, array of numbers, or an &lt;code&gt;ArrayBuffer&lt;/code&gt; object.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;FileData.content_type&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;The content type that will be specified in the multipart request.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;FileData.filename&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;The filename that will be specified in the multipart request.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;
&lt;!-- md-k6:skip --&gt;
&lt;!-- Requires a user-provided file at /path/to/file.bin. --&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import { sleep } from &amp;#39;k6&amp;#39;;
import { md5 } from &amp;#39;k6/crypto&amp;#39;;
import http from &amp;#39;k6/http&amp;#39;;

const binFile = open(&amp;#39;/path/to/file.bin&amp;#39;, &amp;#39;b&amp;#39;);

export default function () {
  const f = http.file(binFile, &amp;#39;test.bin&amp;#39;);
  console.log(md5(f.data, &amp;#39;hex&amp;#39;));
  console.log(f.filename);
  console.log(f.content_type);
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="filedata">FileData&lt;/h1>
&lt;p>&lt;em>FileData&lt;/em> is an object for wrapping data representing a file when doing
&lt;a href="/docs/k6/v2.3.x/examples/data-uploads/#multipart-request-uploading-a-file">multipart requests (file uploads)&lt;/a>.
You create it by calling
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/file/">http.file( data, [filename], [contentType] )&lt;/a>.&lt;/p></description></item><item><title>Params</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/params/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/params/</guid><content><![CDATA[&lt;h1 id=&#34;params&#34;&gt;Params&lt;/h1&gt;
&lt;p&gt;&lt;em&gt;Params&lt;/em&gt; is an object used by the http.* methods that generate HTTP requests. &lt;em&gt;Params&lt;/em&gt; contains request-specific options like e.g. HTTP headers that should be inserted into the request.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Params.auth&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;The authentication method used for the request. It supports &lt;code&gt;digest&lt;/code&gt; and &lt;code&gt;ntlm&lt;/code&gt; authentication methods. Setting it to &lt;code&gt;basic&lt;/code&gt; has no effect: k6 applies basic authentication automatically when the request URL contains credentials, such as &lt;code&gt;http://user:password@example.com&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Params.cookies&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;Object with key-value pairs representing request scoped cookies (they won&amp;rsquo;t be added to VU cookie jar)&lt;br /&gt;&lt;code&gt;{cookies: { key: &amp;quot;val&amp;quot;, key2: &amp;quot;val2&amp;quot; }}&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;You also have the option to say that a request scoped cookie should override a cookie in the VU cookie jar:&lt;br /&gt;&lt;code&gt;{cookies: { key: { value: &amp;quot;val&amp;quot;, replace: true }}}&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Params.headers&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;Object with key-value pairs representing custom HTTP headers the user would like to add to the request.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Params.jar&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;http.CookieJar object to override default VU cookie jar with. Cookies added to request will be sourced from this jar and cookies set by server will be added to this jar.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Params.redirects&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;number&lt;/td&gt;
              &lt;td&gt;The number of redirects to follow for this request. Overrides the global test option 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/k6-options/reference/&#34;&gt;&lt;code&gt;maxRedirects&lt;/code&gt;&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Params.tags&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;Key-value pairs where the keys are names of tags and the values are tag values. Response time metrics generated as a result of the request will have these tags added to them, allowing the user to filter out those results specifically, when looking at results data.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Params.timeout&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string / number&lt;/td&gt;
              &lt;td&gt;Maximum time to wait for the request to complete. Default timeout is 60 seconds (&lt;code&gt;&amp;quot;60s&amp;quot;&lt;/code&gt;). &lt;br/&gt; The type can also be a number, in which case k6 interprets it as milliseconds, e.g., &lt;code&gt;60000&lt;/code&gt; is equivalent to &lt;code&gt;&amp;quot;60s&amp;quot;&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Params.compression&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Sets whether the request body should be compressed. If set to &lt;code&gt;gzip&lt;/code&gt; it will use gzip to compress the body and set the appropriate &lt;code&gt;Content-Length&lt;/code&gt; and &lt;code&gt;Content-Encoding&lt;/code&gt; headers.&lt;br /&gt;&lt;br /&gt;Possible values: &lt;code&gt;gzip&lt;/code&gt;, &lt;code&gt;deflate&lt;/code&gt;, &lt;code&gt;br&lt;/code&gt;, &lt;code&gt;zstd&lt;/code&gt;, and any comma-separated combination of them (for stacked compression). The default is no compression.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Params.responseType&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;ResponseType is used to specify how to treat the body of the response. The three options are:&lt;br /&gt;- text: k6 will return it as a string. This might not be what you want in cases of binary data as the conversation to UTF-16 will probably break it. This is also the default if&lt;br /&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/k6-options/reference/#discard-response-bodies&#34;&gt;discardResponseBodies&lt;/a&gt; is set to false or not set at all.&lt;br /&gt;- &lt;code&gt;binary&lt;/code&gt;: k6 will return an ArrayBuffer object&lt;br /&gt;- &lt;code&gt;none&lt;/code&gt;: k6 will return null as the body. The whole body will be ignored. This is the default when 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/k6-options/reference/##discard-response-bodies&#34;&gt;discardResponseBodies&lt;/a&gt; is set to true.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Params.responseCallback&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/expected-statuses/&#34;&gt;expectedStatuses&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;sets a 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/set-response-callback/&#34;&gt;responseCallback&lt;/a&gt; only for this request. For performance reasons it&amp;rsquo;s better to initialize it once and reference it for each time the same callback will need to be used.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example-of-custom-http-headers-and-tags&#34;&gt;Example of custom HTTP headers and tags&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;A k6 script that will make an HTTP request with a custom HTTP header and tag results data with a specific tag&lt;/em&gt;&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;

export default function () {
  const params = {
    cookies: { my_cookie: &amp;#39;value&amp;#39; },
    headers: { &amp;#39;X-MyHeader&amp;#39;: &amp;#39;k6test&amp;#39; },
    redirects: 5,
    tags: { k6test: &amp;#39;yes&amp;#39; },
  };
  const res = http.get(&amp;#39;https://k6.io&amp;#39;, params);
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;example-using-httpbatch-with-params&#34;&gt;Example using http.batch() with Params&lt;/h3&gt;
&lt;p&gt;Here is another example using 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/batch/&#34;&gt;http.batch()&lt;/a&gt; with a &lt;code&gt;Params&lt;/code&gt; argument:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;

const url1 = &amp;#39;https://quickpizza.grafana.com/api/get&amp;#39;;
const url2 = &amp;#39;https://quickpizza.grafana.com/api/delete&amp;#39;;
const apiToken = &amp;#39;f232831bda15dd233c53b9c548732c0197619a3d3c451134d9abded7eb5bb195&amp;#39;;
const requestHeaders = {
  &amp;#39;User-Agent&amp;#39;: &amp;#39;k6&amp;#39;,
  &amp;#39;Authorization&amp;#39;: &amp;#39;Token &amp;#39; &amp;#43; apiToken,
};

export default function () {
  const res = http.batch([
    { method: &amp;#39;GET&amp;#39;, url: url1, params: { headers: requestHeaders } },
    { method: &amp;#39;GET&amp;#39;, url: url2 },
  ]);
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;example-of-overriding-discardresponsebodies&#34;&gt;Example of overriding discardResponseBodies&lt;/h3&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;

export const options = { discardResponseBodies: true };
export default function () {}
export function setup() {
  // Get 10 random bytes as an ArrayBuffer. Without the responseType the body
  // will be null.
  const response = http.get(&amp;#39;https://quickpizza.grafana.com/api/bytes/10&amp;#39;, {
    responseType: &amp;#39;binary&amp;#39;,
  });
  // response.body is an ArrayBuffer, so wrap it in a typed array view to access
  // its elements.
  const bodyView = new Uint8Array(response.body);
  // This will output something like `176,61,15,66,233,98,223,196,43,1`
  console.log(bodyView);
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="params">Params&lt;/h1>
&lt;p>&lt;em>Params&lt;/em> is an object used by the http.* methods that generate HTTP requests. &lt;em>Params&lt;/em> contains request-specific options like e.g. HTTP headers that should be inserted into the request.&lt;/p></description></item><item><title>Response</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/response/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-http/response/</guid><content><![CDATA[&lt;h1 id=&#34;response&#34;&gt;Response&lt;/h1&gt;
&lt;p&gt;Response is used by the http.* methods that generate HTTP request. Those methods return one (or more, in the case of &lt;code&gt;http.batch()&lt;/code&gt;) Response objects that contain HTTP response contents and performance timing measurements.&lt;/p&gt;
&lt;p&gt;Note that in the case of redirects, all the information in the Response object will pertain to the last request (the one that doesn&amp;rsquo;t get redirected).&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.body&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Response body content, often used to extract dynamic data (see examples 
    &lt;a href=&#34;/docs/k6/v2.3.x/examples/correlation-and-dynamic-data/&#34;&gt;here&lt;/a&gt;) and when verifying the presence of content using 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6/check/&#34;&gt;checks&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;See 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/params/&#34;&gt;Params.responseType&lt;/a&gt; and 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/k6-options/reference/#discard-response-bodies&#34;&gt;options.discardResponseBodies&lt;/a&gt; for how to discard the body when it is not needed (and to save memory) or when handling bodies with binary data.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.cookies&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;Response cookies. The object properties are the cookie names and the value is an array of cookie objects (with &lt;code&gt;name&lt;/code&gt;, &lt;code&gt;value&lt;/code&gt;, &lt;code&gt;domain&lt;/code&gt;, &lt;code&gt;path&lt;/code&gt;, &lt;code&gt;httpOnly&lt;/code&gt;, &lt;code&gt;secure&lt;/code&gt;, &lt;code&gt;maxAge&lt;/code&gt; and &lt;code&gt;expires&lt;/code&gt; fields).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.error&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Error message if there was a non-HTTP error while trying to send the request.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.error_code&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;number&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/error-codes/&#34;&gt;Error code&lt;/a&gt; if there was a non-HTTP error or 4xx or 5xx HTTP error it will be set to a specific code that describes the error. (Added in 0.24.0)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.headers&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;Key-value pairs representing all HTTP headers sent by the server. Note that the header names are in &lt;a href=&#34;https://pkg.go.dev/net/http#CanonicalHeaderKey&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;canonical form&lt;/a&gt;; for example, if the server responds with &amp;ldquo;accept-encoding&amp;rdquo;, the key will be &amp;ldquo;Accept-Encoding&amp;rdquo;. When requesting a header by a specific name, an array of strings is returned since the header can have multiple values. You can access each value by its index - for the first value, or for single-valued header, that will be &lt;code&gt;Response.headers[&amp;quot;my_key&amp;quot;][0]&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.ocsp.produced_at&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;number&lt;/td&gt;
              &lt;td&gt;If a stapled OSCP response was provided by server, the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC, representing the time when this OCSP stapled response was signed by CA (or by CA entrusted OCSP responder)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.ocsp.this_update&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;number&lt;/td&gt;
              &lt;td&gt;If a stapled OSCP response was provided by server, the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC, representing the time at which the status being indicated was known to be correct.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.ocsp.next_update&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;number&lt;/td&gt;
              &lt;td&gt;If a stapled OSCP response was provided by server, the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC, representing the time when this OCSP stapled response will be refreshed with CA (or by CA entrusted OCSP responder).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.ocsp.revocation_reason&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;The reason for revocation of the certificate (if that is the status), one of the following constants: &lt;code&gt;http.OCSP_REASON_UNSPECIFIED&lt;/code&gt;, &lt;code&gt;http.OCSP_REASON_KEY_COMPROMISE&lt;/code&gt;, &lt;code&gt;http.OCSP_REASON_CA_COMPROMISE&lt;/code&gt;, &lt;br /&gt;&lt;code&gt;http.OCSP_REASON_AFFILIATION_CHANGED&lt;/code&gt;, &lt;br /&gt;&lt;code&gt;http.OCSP_REASON_SUPERSEDED&lt;/code&gt;, &lt;br /&gt;&lt;code&gt;http.OCSP_REASON_CESSATION_OF_OPERATION&lt;/code&gt;, &lt;br /&gt;&lt;code&gt;http.OCSP_REASON_CERTIFICATE_HOLD&lt;/code&gt;, &lt;br /&gt;&lt;code&gt;http.OCSP_REASON_REMOVE_FROM_CRL&lt;/code&gt;, &lt;br /&gt;&lt;code&gt;http.OCSP_REASON_PRIVILEGE_WITHDRAWN&lt;/code&gt; or &lt;br /&gt;&lt;code&gt;http.OCSP_REASON_AA_COMPROMISE&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.ocsp.revoked_at&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;number&lt;/td&gt;
              &lt;td&gt;If a stapled OSCP response was provided by server, the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC, representing the time when this certificate was revoked (if that is the status).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.ocsp.status&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;The status of the certificate, one of the following constants: &lt;code&gt;http.OCSP_STATUS_GOOD&lt;/code&gt;, &lt;code&gt;http.OCSP_STATUS_REVOKED&lt;/code&gt;, &lt;code&gt;http.OCSP_STATUS_UNKNOWN&lt;/code&gt; or &lt;code&gt;http.OCSP_STATUS_SERVER_FAILED&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.proto&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Protocol used to perform the transfer. Possible values are &amp;ldquo;HTTP/1.0&amp;rdquo;, &amp;ldquo;HTTP/1.1&amp;rdquo;, or &amp;ldquo;HTTP/2.0&amp;rdquo;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.remote_ip&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;The IP address of the server handling the request.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.remote_port&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;number&lt;/td&gt;
              &lt;td&gt;The port that was connected to on the server side.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.request.body&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Request body content.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.request.cookies&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;Request cookies. The object properties are the cookie names and the value is an array of cookie objects (with &lt;code&gt;name&lt;/code&gt;, &lt;code&gt;value&lt;/code&gt; and &lt;code&gt;replace&lt;/code&gt; fields).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.request.headers&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;Request headers.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.request.method&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Request HTTP method.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.request.url&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;Request URL.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.status&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;number&lt;/td&gt;
              &lt;td&gt;HTTP status code returned by the server.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.status_text&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;&lt;em&gt;(new in k6 v0.29.0)&lt;/em&gt; HTTP status text returned by the server.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.timings&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;object&lt;/td&gt;
              &lt;td&gt;Performance timing information for the HTTP request.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.timings.blocked&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;float&lt;/td&gt;
              &lt;td&gt;Containing time (ms) spent blocked before initiating request.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.timings.connecting&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;float&lt;/td&gt;
              &lt;td&gt;Containing time (ms) spent setting up TCP connection to host.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.timings.tls_handshaking&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;float&lt;/td&gt;
              &lt;td&gt;Containing time (ms) spent handshaking TLS session with host.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.timings.sending&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;float&lt;/td&gt;
              &lt;td&gt;Containing time (ms) spent sending request.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.timings.waiting&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;float&lt;/td&gt;
              &lt;td&gt;Containing time (ms) spent waiting for server response.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.timings.receiving&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;float&lt;/td&gt;
              &lt;td&gt;Containing time (ms) spent receiving response data.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.timings.duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;float&lt;/td&gt;
              &lt;td&gt;Total time for the request (ms). It&amp;rsquo;s equal to &lt;code&gt;sending &#43; waiting &#43; receiving&lt;/code&gt;, i.e. how long did the remote server take to process the request and respond, without the initial DNS lookup/connection times.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.tls_cipher_suite&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;If a TLS session was established, the cipher suite that was used.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.tls_version&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;If a TLS session was established, the version of SSL/TLS that was used.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;Response.url&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;string&lt;/td&gt;
              &lt;td&gt;The URL that was ultimately fetched (i.e. after any potential redirects).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/response/response-clicklink/&#34;&gt;Response.clickLink( [params] )&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;function&lt;/td&gt;
              &lt;td&gt;Parses response as HTML, looks for a specific link and does the request-level equivalent of a click on that link.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/response/response-html/&#34;&gt;Response.html()&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;function&lt;/td&gt;
              &lt;td&gt;Returns an object that supports 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-html/selection/selection-find/&#34;&gt;Selection.find(selector)&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/response/response-json/&#34;&gt;Response.json( [selector] )&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;function&lt;/td&gt;
              &lt;td&gt;Parses the response body data as JSON and returns a JS object or array. This call caches the deserialized JSON data, additional calls will return the cached data. An optional selector can be specified to extract a specific part of the data, see &lt;a href=&#34;https://github.com/tidwall/gjson#path-syntax&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;here for selector syntax&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/response/response-submitform/&#34;&gt;Response.submitForm( [params] )&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;function&lt;/td&gt;
              &lt;td&gt;Parses response as HTML, parses the specified form (defaults to looking for a &amp;ldquo;form&amp;rdquo; element) with option to override fields and then submits form taking form&amp;rsquo;s &lt;code&gt;method&lt;/code&gt; and &lt;code&gt;action&lt;/code&gt; into account.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import { check } from &amp;#39;k6&amp;#39;;
import http from &amp;#39;k6/http&amp;#39;;

export default function () {
  const res = http.get(&amp;#39;https://k6.io&amp;#39;);
  for (const p in res.headers) {
    if (res.headers.hasOwnProperty(p)) {
      console.log(p &amp;#43; &amp;#39; : &amp;#39; &amp;#43; res.headers[p]);
    }
  }
  check(res, {
    &amp;#39;status is 200&amp;#39;: (r) =&amp;gt; r.status === 200,
    &amp;#39;caption is correct&amp;#39;: (r) =&amp;gt; r.html(&amp;#39;h1&amp;#39;).text() == &amp;#39;Example Domain&amp;#39;,
  });
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;em&gt;A k6 script that will make an HTTP request and print all HTTP response headers&lt;/em&gt;&lt;/p&gt;
]]></content><description>&lt;h1 id="response">Response&lt;/h1>
&lt;p>Response is used by the http.* methods that generate HTTP request. Those methods return one (or more, in the case of &lt;code>http.batch()&lt;/code>) Response objects that contain HTTP response contents and performance timing measurements.&lt;/p></description></item></channel></rss>