---
Source: https://docs.microblink.com/blinkid/parse-document-class-info
Title: Parse document class info
Description: Read country, region, and document type from documentClassInfo, and fall back to raw string values for document classes delivered over the air.
---

# Parse document class info

`documentClassInfo` identifies the document that was scanned.
Its `country`, `region`, and `documentType` fields each carry two values:

- `id`: a strongly-typed identifier, taken from the enum the SDK was built with
- `rawValue`: the same classification as a plain string

Branch on `id` wherever you can, and reach for `rawValue` only when `id` is absent.
The examples below assume `result` is the scanning result.

## Read the ID fields

`id` is an enum, so the compiler catches typos and your editor can autocomplete the values.
Prefer it for all comparisons.

<Tabs queryString="platform">

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

  ```typescript
  const classInfo = result.documentClassInfo;

  console.log("Country:", classInfo?.country?.id);            // "croatia"
  console.log("Region:", classInfo?.region?.id);              // "california", or absent
  console.log("Document type:", classInfo?.documentType?.id); // "id"

  if (classInfo?.country?.id === "croatia" && classInfo?.documentType?.id === "id") {
    // Croatian identity card
  }
  ```

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

  ```kotlin
  val classInfo = result.documentClassInfo

  println("Country: ${classInfo?.country?.id}")            // CountryId.Croatia
  println("Region: ${classInfo?.region?.id}")              // RegionId.California, or null
  println("Document type: ${classInfo?.documentType?.id}") // DocumentTypeId.Id

  if (classInfo?.country?.id == CountryId.Croatia && classInfo.documentType?.id == DocumentTypeId.Id) {
      // Croatian identity card
  }
  ```

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

  :::note
  Note that iOS uses `countryId`, `regionId`, and `documentTypeId`, not just `id`.
  :::

  ```swift
  let classInfo = result.documentClassInfo

  print("Country:", String(describing: classInfo.country?.countryId))                 // .croatia
  print("Region:", String(describing: classInfo.region?.regionId))                    // .california, or nil
  print("Document type:", String(describing: classInfo.documentType?.documentTypeId)) // .id

  if classInfo.country?.countryId == .croatia, classInfo.documentType?.documentTypeId == .id {
      // Croatian identity card
  }
  ```

  </TabItem>
</Tabs>

## Fall back to the raw value

BlinkID receives support for new document classes over the air (OTA), after the SDK was built.
When a document matches one of those classes, the enum has no matching value, so `id` is absent while `rawValue` is still populated.

Check `id` first, and compare `rawValue` only if `id` is absent.
This keeps the enum path in place for every document the SDK already knows, and lets you ship support for a new class as a string comparison instead of an SDK upgrade.

<Tabs queryString="platform">

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

  ```typescript
  const documentType = result.documentClassInfo?.documentType;

  if (documentType?.id) {
    handleKnownDocumentType(documentType.id);
  } else if (documentType?.rawValue === "NEW VALUE AVAILABLE ONLY OTA") {
    handleSpecialCase();
  }
  ```

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

  ```kotlin
  val documentType = result.documentClassInfo?.documentType
  val documentTypeId = documentType?.id

  if (documentTypeId != null) {
      handleKnownDocumentType(documentTypeId)
  } else if (documentType?.rawValue == "NEW VALUE AVAILABLE ONLY OTA") {
      handleSpecialCase()
  }
  ```

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

  ```swift
  let documentType = result.documentClassInfo.documentType

  if let documentTypeId = documentType?.documentTypeId {
      handleKnownDocumentType(documentTypeId)
  } else if documentType?.rawValue == "NEW VALUE AVAILABLE ONLY OTA" {
      handleSpecialCase()
  }
  ```

  </TabItem>
</Tabs>

Write the fallback so an unrecognized `rawValue` is handled, not ignored.
A class delivered over the air can reach your app before you have written any code for it.

## Find the raw values

See [Supported documents](./supported-documents.mdx) for the browsable catalog.

Raw values are listed in the supported documents JSON, per document and per platform:

```
https://docs.microblink.com/blinkid/supported-docs/{version}/supported-documents.json
```

Each entry has an `sdk` object with a `web`, `android`, and `ios` key, and each of those holds the `id` and `rawValue` for `country`, `region`, and `documentType`.
For example:

```json
"sdk": {
  "web": {
    "country": { "id": "japan", "rawValue": "JAPAN" },
    "region": null,
    "documentType": { "id": null, "rawValue": "SPECIFIED RESIDENCE CARD" }
  }
}
```

## Absent values

Two kinds of absence mean different things:

- The whole component (`country`, `region`, or `documentType`) is absent: the document has no such classification.
  Most documents are not regional, so `region` is commonly absent.
- The component is present but its `id` is absent: the class exists, was delivered over the air, and is only available as `rawValue`.

When the document could not be classified at all, `documentClassInfo` is either fully absent (web, Android) or `nil`ed (iOS).

## Related articles

- [Result reference](./result-reference.md#document-class-info)
- [How to extract specific fields](./extract-fields.md)
- [How to detect whether a document is supported](./detect-supported.md)
- [How to restrict documents](./restrict-documents.md)
- [Supported documents](./supported-documents.mdx)


Last updated on Jul 28, 2026
