# Redact PII with Node.js

> Call the Redactly redaction API from Node.js with the built-in fetch, no dependency required.

Canonical: https://bitbanger.in/integrations/node
Last updated: 2026-10-27

Node 18 and later ship fetch, so this integration needs no packages. The example shows a small wrapper plus how to read the redacted string and the entity spans.

## Code

```
const res = await fetch("https://api.bitbanger.in/v1/redact", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.REDACTLY_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    text: "Invoice for Jane Doe, jane.doe@example.com",
    style: "replace",
  }),
});

if (!res.ok) throw new Error(`Redactly ${res.status}`);
const { redacted, entities, entity_count } = await res.json();
console.log(entity_count, redacted);
```

## Notes

- Keep the key in an environment variable; never ship it to the browser.
- The demo endpoint /v1/redact/demo is keyless and rate-limited, which is what the playground on this site uses.
- Errors come back as JSON with a detail field, so check res.ok before parsing.

## Related

- [API reference](https://bitbanger.in/docs)
- [Playground](https://bitbanger.in/redact)
- [All 40 entity types](https://bitbanger.in/entities/)
