How do I parameterize my k6 test

Hi, I’ve got a new problem to solve.

I want every VU to represent a specific person, with different login credentials.
In other words, I want my 5 VUs to authenticate as 5 different people, and run separate scenarios.
Is it possible to perform such task with k6?

Thanks in advance !

1 Like


yes, each VU can run completely separate js code. take a look at this example:

import http from "k6/http"

export function setup() {
    return {
        1: {
            token: 'value of the token for vu1',
            endpoint : '/endpoint/for/vu1'
        2: {
            token: 'value of the token for vu2',
            endpoint : '/endpoint/for/vu2'
        // ...

const baseURL = ""

export default function(data) {
  const url = baseURL + data[__VU]["endpoint"];
  const options = {
    headers: {
      "X-Token-header-name": data[__VU] ["token"]

  const response = http.get(url, options);
1 Like

2 posts were split to a new topic: How to distribute VU’s across different scenarios with k6

How would I create a variable to replace the authentication token cookie so that all the calls don’t use the same token from the browser har test, this is what the code looks like(with some confidential stuff taken out)

response = http.get(



          headers: {


              "Mozilla/5.0 (Windows NT........)

            accept: "*/*",

            "sec-fetch-site": "same-site",

            "sec-fetch-mode": "no-cors",

            "sec-fetch-dest": "script",



            "accept-encoding": "gzip, deflate, br",

            "accept-language": "en-US,en;q=0.9",



Cookies should be mostly automatically managed by k6, though you can also manage t hem manually, if you want to:
And if you need to pass things like Authorization headers between requests, you can extract data from one HTTP response, save it in a variable, and use it in the next requests. See and