---
title: "Params | Grafana k6 documentation"
description: "Used for setting various WebSocket request-specific parameters such as headers, tags, etc."
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# Params

> Note
> 
> A module with a better and standard API exists.
> 
> The new [k6/websockets API](/docs/k6/next/javascript-api/k6-websockets/) partially implements the [WebSockets API living standard](https://websockets.spec.whatwg.org/).
> 
> When possible, we recommend using the new API. It uses a global event loop for consistency with other k6 APIs and better performance.

*Params* is an object used by the WebSocket methods that generate WebSocket requests. *Params* contains request-specific options like headers that should be inserted into the request.

Expand table

| Name                 | Type                                                              | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|----------------------|-------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `Params.compression` | string                                                            | Compression algorithm to be used by the WebSocket connection. The only supported algorithm currently is `deflate`. If the option is left unset or empty, it defaults to no compression.                                                                                                                                                                                                                                                                           |
| `Params.jar`         | [http.CookieJar](/docs/k6/next/javascript-api/k6-http/cookiejar/) | The cookie jar that will be used when making the initial HTTP request to establish the WebSocket connection. If empty, the [default VU cookie jar](/docs/k6/next/javascript-api/k6-http/cookiejar/) will be used.                                                                                                                                                                                                                                                 |
| `Params.headers`     | object                                                            | Custom HTTP headers in key-value pairs that will be added to the initial HTTP request to establish the WebSocket connection. Keys are header names and values are header values.                                                                                                                                                                                                                                                                                  |
| `Params.tags`        | object                                                            | [Custom metric tags](/docs/k6/next/using-k6/tags-and-groups/#user-defined-tags) in key-value pairs where the keys are names of tags and the values are tag values. The WebSocket connection will [generate metrics samples](/docs/k6/next/javascript-api/k6-ws/socket/#websocket-built-in-metrics) with these tags attached, allowing users to filter the results data or set [thresholds on sub-metrics](/docs/k6/next/using-k6/thresholds/#thresholds-on-tags). |

### Example of custom metadata headers and tags

*A k6 script that will make a WebSocket request with a custom header and tag results data with a specific tag*

JavaScript ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```javascript
import ws from 'k6/ws';

export default function () {
  const url = 'wss://echo.websocket.org';
  const params = {
    headers: { 'X-MyHeader': 'k6test' },
    tags: { k6test: 'yes' },
  };
  const res = ws.connect(url, params, function (socket) {
    socket.on('open', function () {
      console.log('WebSocket connection established!');
      socket.close();
    });
  });
}
```
