> ## 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.

# Delta

> Use kdx document delta to decode and inspect Kodexa delta binary files, viewing the operations they contain without applying them to a document.

Decode and display the contents of a Kodexa delta binary file. Deltas are the binary change format used by the platform to represent modifications between document revisions. This command lets you inspect what operations a delta contains without applying it.

## Usage

```bash theme={null}
kdx document delta <file> [flags]
```

## Flags

| Flag          | Description                                    | Default |
| ------------- | ---------------------------------------------- | ------- |
| `--data`      | Show operation data payloads (JSON)            | false   |
| `--json`      | Output as structured JSON                      | false   |
| `--max-ops N` | Limit number of operations displayed (0 = all) | 0       |

## Examples

### Inspect a Delta File

```bash theme={null}
kdx document delta changes.bin
```

```
Delta Binary — v1
  Source Hash:    a1b2c3d4e5f6...
  Revisions:     5 → 12
  Checksum:      0x1A2B3C4D
  Operations:    47

  Summary:       +20 ADD  ~15 MOD  -12 DEL
  By Entity:
    DataObject                9
    DataAttribute             22
    ContentNode               10
    Tag                       6

  Operations:
  #     OP     ENTITY                  ID        REV       TIMESTAMP
  ────  ─────  ──────────────────────  ────────  ────────  ───────────────────
  0     ADD    DataObject              305       6         2026-03-19 14:30:22
  1     ADD    DataAttribute           1015      6         2026-03-19 14:30:22
  2     MOD    ContentNode             42        7         2026-03-19 14:30:23
  ...
```

### Show Data Payloads

```bash theme={null}
kdx document delta changes.bin --data --max-ops 3
```

Each operation's JSON data and previous data (for MOD operations) is displayed inline beneath the operation row.

### JSON Output

```bash theme={null}
kdx document delta changes.bin --json | jq '.summary'
```

```json theme={null}
{
  "add": 20,
  "modify": 15,
  "delete": 12,
  "byEntityType": {
    "DataObject": 9,
    "DataAttribute": 22,
    "ContentNode": 10,
    "Tag": 6
  }
}
```

### Filter with jq

```bash theme={null}
# Show only DataObject operations
kdx document delta changes.bin --json --data | \
  jq '.operations[] | select(.entityType == "DataObject")'

# Count operations by type
kdx document delta changes.bin --json | jq '.summary.byEntityType'
```

## Entity Types

| Entity Type          | Description                                            |
| -------------------- | ------------------------------------------------------ |
| `ContentNode`        | Document structure nodes (pages, lines, words)         |
| `ContentFeature`     | Features attached to content nodes                     |
| `ContentFeatureLink` | Links between features and nodes                       |
| `Tag`                | Extraction tags on content nodes                       |
| `ContentTagLink`     | Links between tags and nodes                           |
| `DataObject`         | Structured data objects (e.g., invoice line items)     |
| `DataAttribute`      | Attributes on data objects (e.g., amount, description) |
| `DataException`      | Validation exceptions on data objects                  |
| `Metadata`           | Document-level metadata changes                        |

## Operation Types

| Operation | Description                                       |
| --------- | ------------------------------------------------- |
| `ADD`     | New entity created                                |
| `MOD`     | Existing entity modified (includes previous data) |
| `DEL`     | Entity deleted                                    |

<Tip>
  Use `--json --data` with `jq` to build custom reports. For example, to see all modified data attributes with their before/after values:

  ```bash theme={null}
  kdx document delta changes.bin --json --data | \
    jq '.operations[] | select(.operation == "MOD" and .entityType == "DataAttribute")'
  ```
</Tip>
