---
title: Axios configuration
description: Configuration for Allure Axios | Customize attachment name | Control body capture | Redact sensitive values
---

# Allure Axios configuration

This page describes the options that affect the behavior of the [Allure Axios](/docs/axios/) integration.

All options are passed as the second argument to `instrumentAxios()`:

```ts
instrumentAxios(client, {
  // options here
});
```

`instrumentAxios()` validates its first argument and throws `"allure-axios requires an Axios instance"` immediately if it is not a valid Axios instance.

## Customize the attachment name

- `attachmentName: string | ((exchange: HttpExchange) => string)`

Specify the name under which Allure Axios creates the attachment for each HTTP exchange. For the shape of the `HttpExchange` argument, see [Allure Axios reference](/docs/axios-reference/).

By default, each attachment is named after the request method and full URL — for example, `GET https://api.example.com/orders`. The URL used here is the raw, resolved URL, including any query parameters in their original (unredacted) form. Redaction only applies to the structured fields inside the attachment (`query`, `headers`, `cookies`, `form`), not to the URL string in the attachment name or in `exchange.request.url`.

To use the same static name for all attachments, pass a string:

```ts
instrumentAxios(client, {
  attachmentName: "API request",
});
```

To derive the name dynamically from the exchange data, pass a function:

```ts
instrumentAxios(client, {
  attachmentName: (exchange) =>
    `${exchange.request.method} ${new URL(exchange.request.url).pathname}`,
});
```

## Control body capture

- `captureRequestBody: boolean` (default: `true`)
- `captureResponseBody: boolean` (default: `true`)
- `maxBodySize: number` (default: `65536`)

By default, Allure Axios captures both the request and response body. Set `captureRequestBody` or `captureResponseBody` to `false` to skip one or both:

```ts
instrumentAxios(client, {
  captureRequestBody: false,
  captureResponseBody: false,
});
```

`maxBodySize` sets the maximum number of bytes to capture from any single body. Bodies that exceed this limit are captured up to the limit and flagged as truncated in the attachment. The default is 64 KiB (65 536 bytes).

```ts
instrumentAxios(client, {
  maxBodySize: 1024 * 1024, // 1 MiB
});
```

Any value less than `1` is treated as `0`, which captures body metadata but stores an empty `value`.

For details on how captured bodies are encoded and what the attachment fields contain, see [Allure Axios reference](/docs/axios-reference/).

## Redaction

Allure Axios replaces sensitive values with the sentinel string `__ALLURE_REDACTED__` before writing the attachment. The defaults are:

| Category                | Redacted by default                                                                                                                                                           |
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Headers                 | `authorization`, `cookie`, `set-cookie`, and any header whose name contains `token`, `password`, `passwd`, `secret`, `api-key`/`api_key`/`apikey` (one pattern), or `session` |
| Query parameters        | Any parameter whose name contains the same patterns listed above                                                                                                              |
| Cookies                 | All cookies                                                                                                                                                                   |
| URL-encoded form fields | Any field whose name contains the same patterns listed above                                                                                                                  |

The following options let you override the defaults for each category. Each accepts an array of `RedactionMatcher` values — strings, regular expressions, or functions. Providing an array replaces the defaults for that category entirely. See [Allure Axios reference](/docs/axios-reference/) for the full `RedactionMatcher` and `RedactionContext` type documentation.

- `redactHeaders: RedactionMatcher[]`
- `redactQueryParams: RedactionMatcher[]`
- `redactCookies: RedactionMatcher[]`
- `redactFormFields: RedactionMatcher[]`

```ts
instrumentAxios(client, {
  // Only redact headers explicitly listed, nothing else
  redactHeaders: ["authorization", "x-api-key"],
  // Allow cookies through unredacted
  redactCookies: [],
});
```

## Error options

- `includeErrorStack: boolean` (default: `false`)

When a request fails — whether due to a transport error, a cancellation, or an HTTP error response — Allure Axios records the error's name and message in the attachment. Set `includeErrorStack` to `true` to also capture the stack trace:

```ts
instrumentAxios(client, {
  includeErrorStack: true,
});
```

- `throwAttachmentErrors: boolean` (default: `false`)

By default, if writing the attachment fails — for example, because no Allure runtime is active during the request — the error is silently ignored. Set `throwAttachmentErrors` to `true` to have such errors rethrow instead. This is useful when debugging why attachments are not appearing:

```ts
instrumentAxios(client, {
  throwAttachmentErrors: true,
});
```

Info:
`throwAttachmentErrors` only takes effect when the HTTP request itself succeeds. If the request fails (due to a network error, cancellation, or HTTP error response) and writing the attachment also fails, the attachment error is still silently ignored so the original request error propagates cleanly.
