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

# Document Family Commands

> Use the kdx document-family CLI to export extracted data, list and download content objects, and manage document-family labels and statuses.

# Document Family Commands

The `kdx document-family` command provides operational tools for document families that already exist in the platform. Use it to export extracted data, download the KDDB content object behind a processed document, and update labels or statuses for operational workflows.

A document family is the platform record that ties a source document, its content objects, derived data, labels, status, tasks, and processing history together.

## Available Commands

| Command            | Description                                               |
| ------------------ | --------------------------------------------------------- |
| `data`             | Export extracted JSON data from the latest content object |
| `content list`     | List content objects in a document family                 |
| `content download` | Download a content object as a `.kddb` file               |
| `add-label`        | Add a label to a document family                          |
| `remove-label`     | Remove a label from a document family                     |
| `set-status`       | Set the document-family status                            |

## Export Extracted Data

Retrieve the extracted and transformed data from a processed document family.

```bash theme={null}
kdx document-family data <document-family-id> [flags]
```

### Flags

| Flag                   | Default | Description                      |
| ---------------------- | ------- | -------------------------------- |
| `-o, --output`         | stdout  | Output file path                 |
| `--include-ids`        | `true`  | Include element IDs in output    |
| `--friendly-names`     | `false` | Use friendly names for fields    |
| `--inline-audits`      | `false` | Include inline audit information |
| `--include-exceptions` | `false` | Include exception information    |

### Examples

```bash theme={null}
# Output to terminal
kdx document-family data a700ca3e-38e7-4e63-8974-59c2e9058cf3

# Save to file
kdx document-family data a700ca3e-38e7-4e63-8974-59c2e9058cf3 -o extracted.json

# Use field display names
kdx document-family data a700ca3e-38e7-4e63-8974-59c2e9058cf3 --friendly-names

# Include traceability and exception context
kdx document-family data a700ca3e-38e7-4e63-8974-59c2e9058cf3 \
  --include-ids \
  --inline-audits \
  --include-exceptions \
  -o full-export.json
```

### Output Shape

The command exports formatted JSON from the latest content object.

```json theme={null}
{
  "Invoice": {
    "SupplierName": "Acme Supplies",
    "InvoiceNumber": "INV-10422",
    "InvoiceDate": "2026-04-30",
    "LineItems": [
      {
        "Description": "Managed services",
        "Quantity": 1,
        "Amount": 2450.0,
        "_id": 330
      }
    ]
  }
}
```

When `--include-ids` is enabled, each data element includes an `_id` field that can be used for traceability and audit review.

## Content Object Operations

Document families contain one or more content objects. A content object is the KDDB representation of a processed document at a point in time.

### List Content Objects

```bash theme={null}
kdx document-family content list <document-family-id>
```

Example output:

```text theme={null}
Content Objects in Document Family 70b894f5-8d32-4584-b780-89f89210e078:
-----------------------------------------------------------------
ID                                     CREATED                   LABELS
-----------------------------------------------------------------
abc12345-1111-2222-3333-444444444444   2026-01-26T23:18:07.454Z
def67890-5555-6666-7777-888888888888   2026-01-26T23:22:18.980Z
8efba773-6cc9-4903-95ea-2405a53df853   2026-01-26T23:31:48.777Z   (latest)
```

### Download Content

```bash theme={null}
kdx document-family content download <document-family-id> [content-object-id] [flags]
```

#### Flags

| Flag           | Description                                         |
| -------------- | --------------------------------------------------- |
| `--latest`     | Download the most recent content object             |
| `-o, --output` | Output file path, defaulting to `content-<id>.kddb` |

#### Examples

```bash theme={null}
# Download the latest content object
kdx document-family content download 70b894f5-8d32-4584-b780-89f89210e078 --latest

# Download with a custom filename
kdx document-family content download 70b894f5-8d32-4584-b780-89f89210e078 --latest -o document.kddb

# Download a specific content object by ID
kdx document-family content download 70b894f5-8d32-4584-b780-89f89210e078 8efba773-6cc9-4903-95ea-2405a53df853 -o specific-version.kddb
```

## Labels

Labels are often used for operational routing, progress tracking, and downstream filters.

### Add a Label

```bash theme={null}
kdx document-family add-label <document-family-id> <tag-id> [--path <path>]
```

| Argument or flag     | Description                                          |
| -------------------- | ---------------------------------------------------- |
| `document-family-id` | The document family to update                        |
| `tag-id`             | The label/tag UUID to apply                          |
| `--path`             | Optional path within the document to scope the label |

Examples:

```bash theme={null}
kdx document-family add-label a700ca3e-38e7-4e63-8974-59c2e9058cf3 label-uuid
kdx document-family add-label a700ca3e-38e7-4e63-8974-59c2e9058cf3 label-uuid --path /invoice/header
```

### Remove a Label

```bash theme={null}
kdx document-family remove-label <document-family-id> <label-id>
```

Example:

```bash theme={null}
kdx document-family remove-label a700ca3e-38e7-4e63-8974-59c2e9058cf3 label-uuid
```

## Status

Statuses are useful when a project models lifecycle states such as received, reviewed, approved, rejected, or archived.

```bash theme={null}
kdx document-family set-status <document-family-id> <status-id>
```

Example:

```bash theme={null}
kdx document-family set-status a700ca3e-38e7-4e63-8974-59c2e9058cf3 status-uuid
```

## When To Use Each Command

| Use case                                               | Command                                         |
| ------------------------------------------------------ | ----------------------------------------------- |
| Get structured data for an integration check           | `kdx document-family data`                      |
| Debug what the platform stored in a processed document | `kdx document-family content download --latest` |
| See whether multiple content versions exist            | `kdx document-family content list`              |
| Mark a document for an operational path                | `kdx document-family add-label`                 |
| Clear an incorrect operational label                   | `kdx document-family remove-label`              |
| Move a document to a known lifecycle state             | `kdx document-family set-status`                |

## Upload, Wait, Export

```bash theme={null}
# Upload document
kdx store upload acme/ap-processing ./invoice.pdf

# Wait for the target label
kdx store watch a700ca3e-38e7-4e63-8974-59c2e9058cf3 --timeout 900

# Export extracted data
kdx document-family data a700ca3e-38e7-4e63-8974-59c2e9058cf3 -o invoice.json
```

## Troubleshooting

| Symptom                      | What to check                                                                                                   |
| ---------------------------- | --------------------------------------------------------------------------------------------------------------- |
| `no content objects found`   | The document may not have processed yet, or processing failed before content was saved.                         |
| Empty JSON export            | Confirm the document reached the expected processing label and that the Activity Plan produced structured data. |
| `Document family not found`  | Confirm the ID, profile, URL, and permissions.                                                                  |
| Label or status update fails | Confirm you are passing the server UUID for the label or status, not the display name.                          |
