> ## Documentation Index
> Fetch the complete documentation index at: https://developer.kodexa.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Knowledge Feature Types Concept

> Knowledge Feature Types define reusable categories of metadata you capture from documents, providing the vocabulary for cross-document knowledge in Kodexa.

A **Knowledge Feature Type** is a template that defines a category of metadata you want to capture and track across documents. Once defined, you create reusable **Knowledge Features** of that type, which can be linked to multiple documents.

## When Do You Need Feature Types?

Create a Knowledge Feature Type when you want to:

* Track which vendor invoices came from
* Classify documents by type (10K, 10Q, Contract, etc.)
* Identify document language
* Group documents by customer, region, or business unit

## How Feature Types Work

```mermaid theme={null}
flowchart LR
    subgraph "Define Once"
        FT[Knowledge Feature Type<br/>"Vendor"]
    end

    subgraph "Create Features"
        F1[Feature: "Acme Corp"]
        F2[Feature: "Globex Inc"]
        F3[Feature: "Initech"]
    end

    subgraph "Link to Documents"
        D1[Invoice #1]
        D2[Invoice #2]
        D3[Invoice #3]
        D4[Invoice #4]
    end

    FT --> F1
    FT --> F2
    FT --> F3

    F1 --> D1
    F1 --> D2
    F2 --> D3
    F3 --> D4
```

1. **Define the Type** - Create a Knowledge Feature Type (e.g., "Vendor")
2. **Create Features** - Create reusable features of that type (e.g., "Acme Corp", "Globex Inc")
3. **Link to Documents** - Associate features with documents as they're processed

## Feature Type Structure

| Field             | Purpose                       | Example                               |
| ----------------- | ----------------------------- | ------------------------------------- |
| `slug`            | Unique identifier             | `vendor`                              |
| `name`            | Display name                  | `Vendor`                              |
| `description`     | What this feature represents  | `The vendor that issued this invoice` |
| `options`         | Define natural key properties | `vendorId`, `taxId`                   |
| `extendedOptions` | Define display properties     | `displayName`, `address`              |

### Options vs Extended Options

**Options** define the **natural key** - the unique identifier for each feature:

```yaml theme={null}
options:
  - name: vendorId
    type: string
    label: Vendor ID
    description: Unique identifier for this vendor
```

**Extended Options** define **presentation properties** - additional info for display:

```yaml theme={null}
extendedOptions:
  - name: displayName
    type: string
    label: Display Name
    description: Human-readable vendor name
  - name: address
    type: string
    label: Address
```

When you create a feature, the `options` values become `properties` (the key), and `extendedOptions` values become `extendedProperties` (for display).

## Creating a Feature Type

### Via YAML (GitOps)

Create a file in `kodexa-resources/knowledge-feature-types/`:

```yaml theme={null}
# kodexa-resources/knowledge-feature-types/vendor.yaml
slug: vendor
name: Vendor
description: Tracks the vendor associated with invoice documents
active: true

options:
  - name: vendorId
    type: string
    label: Vendor ID
    description: Unique identifier for this vendor
    required: true

extendedOptions:
  - name: displayName
    type: string
    label: Display Name
    description: Human-readable vendor name
  - name: website
    type: string
    label: Website
```

Add to your manifest:

```yaml theme={null}
# manifests/main.yaml
resources:
  knowledge-feature-types:
    - vendor
```

Deploy:

```bash theme={null}
kdx sync deploy
```

### Via API

```bash theme={null}
curl -X POST "https://platform.kodexa.ai/api/knowledgeFeatureTypes" \
  -H "Authorization: Bearer $KODEXA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "slug": "vendor",
    "name": "Vendor",
    "description": "Tracks the vendor associated with invoice documents",
    "active": true,
    "options": [
      {
        "name": "vendorId",
        "type": "string",
        "label": "Vendor ID",
        "required": true
      }
    ],
    "extendedOptions": [
      {
        "name": "displayName",
        "type": "string",
        "label": "Display Name"
      }
    ]
  }'
```

### Via Kodexa UI

1. Navigate to **Knowledge** in the sidebar
2. Click **Feature Types**
3. Click **Create Feature Type**
4. Fill in the form with name, slug, description
5. Add options for natural keys
6. Add extended options for display properties
7. Save

## Creating Features

Once you have a Feature Type, create features of that type:

### Via YAML

```yaml theme={null}
# Creating a feature instance
featureType: vendor
properties:
  vendorId: "V001"
extendedProperties:
  displayName: "Acme Corporation"
  website: "https://acme.com"
active: true
```

### Via API

```bash theme={null}
curl -X POST "https://platform.kodexa.ai/api/knowledgeFeatures" \
  -H "Authorization: Bearer $KODEXA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "featureTypeSlug": "vendor",
    "properties": {
      "vendorId": "V001"
    },
    "extendedProperties": {
      "displayName": "Acme Corporation",
      "website": "https://acme.com"
    },
    "active": true
  }'
```

## Linking Features to Documents

Features are linked to document families. See the [Document Families API](/api-reference/documentfamilies/get-document-families) for details on attaching features during processing.

## Common Feature Type Examples

### Document Type Classification

```yaml theme={null}
slug: document-type
name: Document Type
description: Classification of document (10K, 10Q, Contract, etc.)

options:
  - name: typeCode
    type: string
    label: Type Code
    required: true

extendedOptions:
  - name: typeName
    type: string
    label: Type Name
  - name: category
    type: string
    label: Category
```

### Language Detection

```yaml theme={null}
slug: language
name: Language
description: Primary language of the document

options:
  - name: isoCode
    type: string
    label: ISO Language Code
    required: true

extendedOptions:
  - name: languageName
    type: string
    label: Language Name
```

### Customer Identification

```yaml theme={null}
slug: customer
name: Customer
description: Customer associated with this document

options:
  - name: customerId
    type: string
    label: Customer ID
    required: true

extendedOptions:
  - name: customerName
    type: string
    label: Customer Name
  - name: region
    type: string
    label: Region
```

## Next Steps

* [Knowledge Item Types](/concepts/knowledge_item_types) - Define configurable behaviors
* [Knowledge Sets](/concepts/knowledge_system) - Connect features to actions
* [Customizing Extraction](/concepts/customizing_extraction) - Use features to customize processing
