# HAR Sanitizer & Analyzer API

> Remove cookies, auth headers, tokens, JWT signatures and passwords from a HAR file, analyze requests and timings, or turn entries into curl, k6, Postman.

- Endpoint: `POST https://apibox.io.vn/v1/har-tools`
- Category: Developer utilities
- HTML docs: https://apibox.io.vn/docs/har-tools/ (Vietnamese: https://apibox.io.vn/vi/docs/har-tools/)
- Online tool: https://apibox.io.vn/tools/har-tools/
- Authentication: `Authorization: Bearer <API key>` or `X-API-Key: <API key>` (free key: https://apibox.io.vn/dashboard/#signup)

A HAR file exported from the browser DevTools records every request of a page, including session cookies, `Authorization` headers, API keys in query strings and passwords in form posts. Support teams ask customers for HAR files all the time, and leaked HARs have been used to hijack sessions. `action=sanitize` (default) returns a cleaned HAR plus a report of what was redacted: all cookie values (`Cookie`, `Set-Cookie` and the `cookies` arrays), authentication headers (`Authorization`, `X-Api-Key`, CSRF tokens…), query and form parameters and JSON fields whose names look secret (`token`, `password`, `secret`, `session`, `api_key`, `code`, `sig`…), JWT signatures (the header and payload stay readable, like Cloudflare's HAR sanitizer), bearer tokens and well-known key formats (AWS, GitHub, Google, Stripe, Slack, OpenAI, PEM private keys) anywhere in headers, URLs and bodies. Add your own names with `keys`, keep some with `allow_keys`, or drop all bodies with `strip_bodies=1`. `action=report` only lists what would be redacted.

`action=analyze` summarizes the capture: number of requests, transfer and content bytes, total time, status classes and failed requests, bytes by type (document, script, stylesheet, image, font, XHR), first-party domain and third-party domains, the slowest and largest requests, cache hits and 304s, text responses served without compression, and DNS / connect / TLS / wait / receive times. `waterfall=1` adds a per-request timeline and `format=svg` draws it as an SVG waterfall. URLs in the report are sanitized too.

`action=convert` turns entries into ready-to-run `curl` commands, a k6 load-test script, a Postman v2.1 collection, or code in any `curl-convert` language (`python`, `fetch`, `node`, `go`, `php`…). Pick entries with `entries=0,3,5-7`, `filter` (URL substring), `methods` or `xhr_only=1`; secrets are redacted first unless `sanitize=0`. Send the HAR as a file field `file`, as `har` (JSON or string) or as the raw JSON body, up to 20 MB (and your plan's file limit). Nothing is stored or logged.

## Parameters

| Name | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
| `file` | body | file | no |  | The .har file (multipart). Alternatively send `har` or the raw JSON body. |
| `har` | body | object | no |  | HAR as a JSON object or string ({"log": {"entries": [...]}}), max 20 MB. |
| `action` | body | string | no | `sanitize` | `sanitize`, `report` (list only), `analyze` or `convert`. Alias: `mode`. |
| `keys` | body | string | no |  | Extra parameter / header / JSON field names to redact (comma-separated; also matched as substrings when longer than 2 characters). |
| `allow_keys` | body | string | no |  | Names never to redact (e.g. `code` when it is a product code). |
| `strip_bodies` | body | boolean | no |  | `1`: remove all request and response bodies (or only one side with `strip_request_bodies` / `strip_response_bodies`). |
| `placeholder` | body | string | no | `redacted` | Text written in place of secrets. |
| `format` | body | string | no |  | sanitize: `har` downloads the cleaned file; analyze: `svg` returns the waterfall chart. |
| `waterfall` | body | boolean | no |  | analyze: include the per-request timeline (`waterfall_limit`, default 100). |
| `top` | body | number | no | `10` | analyze: number of slowest / largest requests listed. |
| `to` | body | string | no | `curl` | convert: `curl`, `k6`, `postman`, or a curl-convert target (`python`, `fetch`, `node`, `go`, `php`, `java`, `csharp`, `ruby`, `rust`, `powershell`, `httpie`…; max 20 entries). |
| `entries` | body | string | no |  | convert: entry indexes, e.g. `0,3,5-7`. Also `filter` (URL substring), `methods` (GET,POST), `xhr_only=1`, `limit` (default 50). |
| `sanitize` | body | boolean | no | `true` | analyze / convert: redact secrets first (`0` to keep them, e.g. to replay your own requests). |

## Example request

```bash
curl -X POST "https://apibox.io.vn/v1/har-tools" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"action":"report","har":{"log":{"entries":["… 3 entries: a page with a session query parameter and cookies, a login POST with a Bearer JWT and a password, a third-party script …"]}}}'
```

## Example response

```json
{
  "action": "report",
  "entries": 3,
  "report": {
    "redacted": 6,
    "by_type": {
      "query": 2,
      "cookie": 2,
      "header": 1,
      "body_field": 1
    },
    "names": [
      {
        "type": "query",
        "name": "session",
        "count": 2
      },
      {
        "type": "cookie",
        "name": "sid",
        "count": 1
      },
      {
        "type": "cookie",
        "name": "theme",
        "count": 1
      },
      {
        "type": "header",
        "name": "Authorization",
        "count": 1
      },
      {
        "type": "body_field",
        "name": "password",
        "count": 1
      }
    ],
    "items": [
      {
        "entry": 0,
        "type": "query",
        "location": "request.url",
        "name": "session"
      },
      {
        "entry": 0,
        "type": "query",
        "location": "request.queryString",
        "name": "session"
      },
      {
        "entry": 0,
        "type": "cookie",
        "location": "request.headers",
        "name": "sid"
      },
      {
        "entry": 0,
        "type": "cookie",
        "location": "request.headers",
        "name": "theme"
      },
      {
        "entry": 1,
        "type": "header",
        "location": "request.headers",
        "name": "Authorization"
      },
      {
        "entry": 1,
        "type": "body_field",
        "location": "request.postData",
        "name": "password"
      }
    ],
    "items_truncated": false
  },
  "note": "Nothing was changed or stored. Call action=sanitize to get the cleaned HAR."
}
```

## Use cases

- Clean a HAR before attaching it to a support ticket or bug report
- Check which secrets a customer's HAR contains before opening it
- Find slow, failing and third-party requests in a page load
- Replay captured API calls as curl, k6 or a Postman collection

## FAQ

### Is the HAR stored anywhere?

No. It is processed in memory for this request and discarded. Still, prefer HARs from test accounts and run action=report first if you are unsure.

### Why is the JWT payload still readable?

Without the signature a JWT cannot be replayed, while the header and payload (user ID, expiry, scopes) help debugging. Use keys or strip_bodies if the payload itself is sensitive.

### Can it miss a secret?

Yes, if a secret sits under an unusual name in an unknown format. Add names with keys, review the report and the cleaned file before sharing it.
