---
Source: https://docs.microblink.com/blinkid/redaction
Title: Use custom redaction
Description: How to extend BlinkID's built-in redaction rules with custom per-document settings
---

# Use custom redaction

Some countries and jurisdictions require that specific fields in identity documents be redacted before any data leaves the device.
BlinkID ships with several built-in redaction rules that automatically cover some of these requirements for certain document classes.

## Default redaction

Default redaction applies automatically.
When a scan completes, the SDK looks up its built-in rules for the scanned document class and applies them to the result before returning it.
For example, German ID cards have their document number redacted by default.

No action is needed to perform default redaction.

## Custom redaction

You can perform your own custom redactions.

You can either **override** the redactions if they do not apply to your legal requirements, or **add** your redactions on top of the default ones.

### Override redactions

To override default redactions, return a `RedactionSettings` object with the fields you want to resolve from your resolver.
The SDK removes the default redactions, and applies yours.

**Return `null` (web, Android) or `nil` (iOS) for all other documents to keep their defaults unchanged.**

<Tabs queryString="platform">

  <TabItem value="web" label="Web (TS)" default>

  ```typescript
  const blinkId = await createBlinkId({
    licenseKey: "...",
    redactionSettingsResolver: (classInfo) => {
      if (classInfo.country?.id === "germany" && classInfo.documentType?.id === "id") {
        return { fields: ["sex", "dateOfBirth"] };
      }
      return null; // use SDK defaults for all other documents
    },
  });
  ```

  </TabItem>
  <TabItem value="android" label="Android (Kotlin)">

  ```kotlin
  @Parcelize
  class MyRedactionResolver : RedactionSettingsResolver {
      override fun resolveRedactionSettings(classInfo: DocumentClassInfo): RedactionSettings? {
          if (classInfo.country?.id == CountryId.Germany && classInfo.documentType?.id == DocumentTypeId.Id) {
              return RedactionSettings(
                  fields = listOf(FieldType.Sex, FieldType.DateOfBirth),
                  documentNumberRedactionSettings = null
              )
          }
          return null // use SDK defaults for all other documents
      }
  }

  BlinkIdCameraScanningScreen(
      blinkIdSdk = blinkIdSdk,
      uxSettings = BlinkIdUxSettings(
          redactionSettingsResolver = MyRedactionResolver()
      ),
      onScanningSuccess = { result -> },
      onScanningCanceled = { }
  )
  ```

  </TabItem>
  <TabItem value="ios" label="iOS (Swift)">

  ```swift
  struct MyRedactionResolver: RedactionSettingsResolver {
      func resolveRedactionSettings(classInfo: DocumentClassInfo) -> RedactionSettings? {
          if classInfo.country?.countryId == .germany, classInfo.documentType?.documentTypeId == .id {
              return RedactionSettings(fields: [.sex, .dateOfBirth])
          }
          return nil // use SDK defaults for all other documents
      }
  }

  let analyzer = try await BlinkIDAnalyzer(
      sdk: sdk,
      redactionSettingsResolver: MyRedactionResolver()
  )
  ```

  </TabItem>
</Tabs>

### Add custom redactions to default ones

To extend the default redactions with additional fields, retrieve the defaults for the scanned document class inside your resolver and add your fields to the result.

<Tabs queryString="platform">

  <TabItem value="web" label="Web (TS)" default>

  ```typescript
  const blinkId = await createBlinkId({
    licenseKey: "...",
    redactionSettingsResolver: async (classInfo) => {
      const defaults = await blinkId.blinkIdCore.getDefaultRedactionSettings(classInfo);
      return {
        ...defaults,
        fields: [...defaults.fields, "sex", "dateOfBirth"],
      };
    },
  });
  ```

  </TabItem>
  <TabItem value="android" label="Android (Kotlin)">

  ```kotlin
  @Parcelize
  class MyRedactionResolver : RedactionSettingsResolver {
      override fun resolveRedactionSettings(classInfo: DocumentClassInfo): RedactionSettings? {
          val defaults = RedactionSettings.getDefaultRedactionSettings(classInfo)
          return defaults.copy(
              fields = defaults.fields + listOf(FieldType.Sex, FieldType.DateOfBirth)
          )
      }
  }
  ```

  </TabItem>
  <TabItem value="ios" label="iOS (Swift)">

  ```swift
  struct MyRedactionResolver: RedactionSettingsResolver {
      func resolveRedactionSettings(classInfo: DocumentClassInfo) -> RedactionSettings? {
          guard var settings = RedactionSettings.getDefaultRedactionSettings(for: classInfo) else {
              return nil
          }
          settings.fields += [.sex, .dateOfBirth]
          return settings
      }
  }

  let analyzer = try await BlinkIDAnalyzer(
      sdk: sdk,
      redactionSettingsResolver: MyRedactionResolver()
  )
  ```

  </TabItem>
</Tabs>

## Remove redactions

To disable redaction entirely, return a `RedactionSettings` object with `mode` set to `"none"` from your resolver for every document class.

<Tabs queryString="platform">

  <TabItem value="web" label="Web (TS)" default>

  ```typescript
  const blinkId = await createBlinkId({
    licenseKey: "...",
    redactionSettingsResolver: () => ({ mode: "none", fields: [] }),
  });
  ```

  </TabItem>
  <TabItem value="android" label="Android (Kotlin)">

  ```kotlin
  @Parcelize
  class NoRedactionResolver : RedactionSettingsResolver {
      override fun resolveRedactionSettings(classInfo: DocumentClassInfo): RedactionSettings? {
          return RedactionSettings(
              redactionMode = RedactionMode.None,
              fields = emptyList(),
              documentNumberRedactionSettings = null
          )
      }
  }
  ```

  </TabItem>
  <TabItem value="ios" label="iOS (Swift)">

  ```swift
  struct NoRedactionResolver: RedactionSettingsResolver {
      func resolveRedactionSettings(classInfo: DocumentClassInfo) -> RedactionSettings? {
          return RedactionSettings(mode: .none, fields: [])
      }
  }

  let analyzer = try await BlinkIDAnalyzer(
      sdk: sdk,
      redactionSettingsResolver: NoRedactionResolver()
  )
  ```

  </TabItem>
</Tabs>

## MRZ and barcode redactions

In addition to redactions which use `mode` and `fields`, you can also use two additional flags: `redactMrz` and `redactBarcode` (boolean).

These redact the data extracted from the MRZ or barcode.

Note that this redaction doesn't propagate to the top result.
For example, if a piece of information is present both in the visual zone and the machine-readable zone, and you redact the machine-readable zone, this information will still be present in the result (unless also covered by a field in the `fields` array).

<Tabs queryString="platform">

  <TabItem value="web" label="Web (TS)" default>

  ```typescript
  const blinkId = await createBlinkId({
    licenseKey: "...",
    redactionSettingsResolver: () => ({ fields: [], redactMrz: true, redactBarcode: true }),
  });
  ```

  </TabItem>
  <TabItem value="android" label="Android (Kotlin)">

  ```kotlin
  @Parcelize
  class MyRedactionResolver : RedactionSettingsResolver {
      override fun resolveRedactionSettings(classInfo: DocumentClassInfo): RedactionSettings? {
          return RedactionSettings(
              fields = emptyList(),
              documentNumberRedactionSettings = null,
              redactMrz = true,
              redactBarcode = true
          )
      }
  }
  ```

  </TabItem>
  <TabItem value="ios" label="iOS (Swift)">

  ```swift
  struct MyRedactionResolver: RedactionSettingsResolver {
      func resolveRedactionSettings(classInfo: DocumentClassInfo) -> RedactionSettings? {
          return RedactionSettings(fields: [], redactMrz: true, redactBarcode: true)
      }
  }

  let analyzer = try await BlinkIDAnalyzer(
      sdk: sdk,
      redactionSettingsResolver: MyRedactionResolver()
  )
  ```

  </TabItem>
</Tabs>


Last updated on Jul 24, 2026
