---
title: Axios reference
description: Reference documentation for Allure Axios | HttpExchange attachment schema | RedactionMatcher type | RedactionContext type
---

# Allure Axios reference

## Attachment schema

Each HTTP exchange is recorded as a JSON attachment with content type `application/vnd.allure.http+json` and file extension `.httpexchange`. The root object has the following shape:

| Field           | Type     | Description                                                                                   |
| --------------- | -------- | --------------------------------------------------------------------------------------------- |
| `schemaVersion` | `1`      | Schema version. Always `1`.                                                                   |
| `start`         | `number` | Unix timestamp in milliseconds when the request started.                                      |
| `stop`          | `number` | Unix timestamp in milliseconds, recorded when the response or error was received.             |
| `request`       | object   | Captured request data. See [Request](#request).                                               |
| `response`      | object   | Captured response data. Present only when a response was received. See [Response](#response). |
| `error`         | object   | Error information. Present only when the request failed. See [Error](#error).                 |

For HTTP error responses (4xx and 5xx status codes), both `response` and `error` are present simultaneously: `response` contains the status, headers, and body of the error response, while `error` contains the `AxiosError` details.

### Request

| Field     | Type              | Description                                                                                                                 |
| --------- | ----------------- | --------------------------------------------------------------------------------------------------------------------------- |
| `method`  | `string`          | HTTP method in uppercase, e.g. `"GET"`.                                                                                     |
| `url`     | `string`          | Resolved request URL, including query parameters in their original unredacted form.                                         |
| `headers` | `{name, value}[]` | Request headers after redaction. Omitted when there are no headers.                                                         |
| `query`   | `{name, value}[]` | Query parameters parsed from the URL, after redaction. Omitted when there are no query parameters.                          |
| `cookies` | `Cookie[]`        | Cookies parsed from the `Cookie` request header, after redaction. Omitted when there are no cookies. See [Cookie](#cookie). |
| `body`    | object            | Request body. Present only when `captureRequestBody` is `true` and a body was sent. See [Body](#body).                      |

### Response

| Field        | Type              | Description                                                                                                                                |
| ------------ | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `status`     | `number`          | HTTP status code.                                                                                                                          |
| `statusText` | `string`          | HTTP status text.                                                                                                                          |
| `headers`    | `{name, value}[]` | Response headers after redaction. Omitted when there are no headers.                                                                       |
| `cookies`    | `Cookie[]`        | Cookies parsed from `Set-Cookie` response headers, after redaction. Omitted when there are no `Set-Cookie` headers. See [Cookie](#cookie). |
| `body`       | object            | Response body. Present only when `captureResponseBody` is `true` and a body was received. See [Body](#body).                               |

Response bodies are captured from `response.data` — the value after Axios applies its response transforms. When `responseType` is `'json'` (the default), Axios parses the response as JSON before Allure Axios sees it, so the captured `value` is the parsed object re-serialized with `JSON.stringify`. This produces compact JSON regardless of how the server formatted the original response. To capture the unmodified response bytes, set `responseType: 'arraybuffer'` or `responseType: 'text'` on the Axios request.

### Body

| Field         | Type                 | Description                                                                                                                                                                            |
| ------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `contentType` | `string`             | Value of the `Content-Type` header. Absent when no `Content-Type` header is present.                                                                                                   |
| `encoding`    | `"utf8" \| "base64"` | Encoding used for `value`. Present only for non-stream bodies. See [Body encoding](#body-encoding).                                                                                    |
| `value`       | `string`             | The captured body content, encoded per `encoding`. Absent for stream and multipart bodies.                                                                                             |
| `size`        | `number`             | Body size in bytes. For non-stream bodies, always present. For stream bodies, present only when a `Content-Length` header is available; absent otherwise. See [Body size](#body-size). |
| `truncated`   | `boolean`            | `true` when the body exceeded `maxBodySize` and was cut off. Always `false` for stream bodies.                                                                                         |
| `form`        | `{name, value}[]`    | Structured fields parsed from a `application/x-www-form-urlencoded` body, after redaction. See [URL-encoded form bodies](#url-encoded-form-bodies).                                    |
| `stream`      | `{type: string}`     | Present instead of `value` and `encoding` for stream and multipart bodies. See [Stream bodies](#stream-bodies).                                                                        |

#### Body encoding

`encoding` depends on the JavaScript type of the body data, not primarily on the `Content-Type` header:

- **`string`**, **`URLSearchParams`**, **plain objects** (JSON-serialized), and any other non-binary value → `"utf8"`.
- **`ArrayBuffer`** and **typed arrays** → `"base64"`.
- **`Blob`** → determined by `Blob.type`: `"utf8"` when `Blob.type` is `text/*`, `application/json`, `application/javascript`, `application/x-www-form-urlencoded`, `application/xml`, or ends in `+json` or `+xml`; `"base64"` for all other types. A missing or empty `Blob.type` is treated as text.

#### URL-encoded form bodies

When the content type is `application/x-www-form-urlencoded`, the body contains two representations of the same data:

- `value`: the re-serialized URL-encoded string, with sensitive fields replaced by the redaction placeholder.
- `form`: a structured `{name, value}[]` array with the same redaction applied.

#### Stream bodies

Bodies that cannot be read without consuming them are not captured. The `stream` field is present instead of `value`. The following are treated as streams:

- **Node.js readable streams and async iterables** — objects with a `pipe`, `read`, or `Symbol.asyncIterator` property, excluding `URLSearchParams`, `ArrayBuffer`, and typed arrays.
- **Objects from the `form-data` npm package**.
- **Any body whose `Content-Type` is `multipart/form-data`**.

`Blob` bodies are **captured**, not treated as streams — Allure Axios reads them via `arrayBuffer()`. Encoding is determined by `Blob.type`, not the request `Content-Type` header.

```json
{ "stream": { "type": "chunked" } }
```

The `type` is derived from the content type: `text/event-stream` → `"server-sent-events"`, `application/grpc` → `"grpc"`, all others → `"chunked"`.

#### Body size

The `size` field uses the `Content-Length` header when present. If `Content-Length` is absent, `size` is the actual byte count of the captured data. For truncated bodies, `size` may therefore be larger than the length of the stored `value`.

### Cookie

Request cookies are parsed from the `Cookie` header. Response cookies are parsed from `Set-Cookie` headers.

| Field      | Type      | Description                                                             |
| ---------- | --------- | ----------------------------------------------------------------------- |
| `name`     | `string`  | Cookie name.                                                            |
| `value`    | `string`  | Cookie value, after redaction.                                          |
| `path`     | `string`  | `Path` attribute. Response cookies only.                                |
| `domain`   | `string`  | `Domain` attribute. Response cookies only.                              |
| `expires`  | `string`  | `Expires` attribute. Response cookies only.                             |
| `httpOnly` | `boolean` | `true` when the `HttpOnly` attribute is present. Response cookies only. |
| `secure`   | `boolean` | `true` when the `Secure` attribute is present. Response cookies only.   |
| `sameSite` | `string`  | `SameSite` attribute value. Response cookies only.                      |

### Error

Present when the request failed — whether due to a transport error, cancellation, or an HTTP error response.

| Field     | Type     | Description                                                                                               |
| --------- | -------- | --------------------------------------------------------------------------------------------------------- |
| `name`    | `string` | The error's `name` property.                                                                              |
| `message` | `string` | The error message.                                                                                        |
| `stack`   | `string` | Stack trace. Present only when `includeErrorStack` is `true` and the thrown value is an `Error` instance. |

## Redaction types

### `RedactionMatcher`

A `RedactionMatcher` controls whether a specific field value should be redacted. It can be any of the following:

- A **string**: redacts any field whose name equals the string, case-insensitively.
- A **`RegExp`**: redacts any field whose name matches the pattern.
- A **function** `(name: string, value: string, context: RedactionContext) => boolean`: redacts based on any logic, with access to the field name, value, and surrounding context.

```ts
instrumentAxios(client, {
  redactHeaders: [
    "x-api-key", // exact name, case-insensitive
    /^x-internal-/i, // regex on the header name
    (name, value) => value.startsWith("sk-"), // match on the value itself
  ],
});
```

### `RedactionContext`

The `context` argument passed to a function `RedactionMatcher`:

| Property   | Type                                        | Description                                                                                                  |
| ---------- | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| `kind`     | `"header" \| "query" \| "cookie" \| "form"` | Which category is being evaluated.                                                                           |
| `name`     | `string`                                    | The field name.                                                                                              |
| `value`    | `string`                                    | The field value.                                                                                             |
| `url`      | `string \| undefined`                       | The resolved request URL.                                                                                    |
| `request`  | `InternalAxiosRequestConfig \| undefined`   | The Axios request config.                                                                                    |
| `response` | `AxiosResponse \| undefined`                | The Axios response. Present only when evaluating response-phase fields (response headers, response cookies). |
