Skip to main content

Dynamic API Operations

The kdx run command allows you to discover and execute API operations that go beyond standard CRUD operations.

Overview

While kdx get, kdx create, kdx delete handle standard operations, many resources have additional specialized operations. The kdx run command provides access to these.
kdx run <resource-type> [operation] [flags]

Discovering Operations

To see available operations for a resource type:
kdx run <resource-type>

Example: Document Families Operations

kdx run document-families
Output:
Available operations for resource 'document-families':

NAME                      METHOD  PATH                                    PARAMETERS
add-knowledge-feature     POST    /api/document-families/{id}/add...      path: id*; body: required
applied-knowledge-sets    GET     /api/document-families/{id}/app...      path: id*
assess                    POST    /api/document-families/{id}/assess      path: id*
data                      GET     /api/document-families/{id}/data        path: id*; query: format, ...
export                    GET     /api/document-families/{id}/export      path: id*
external-data-get         GET     /api/document-families/{id}/ext...      path: id*; query: key
external-data-keys        GET     /api/document-families/{id}/ext...      path: id*
reprocess                 PUT     /api/document-families/{id}/rep...      path: id*; query: assistantId*
steps                     GET     /api/document-families/{id}/steps       path: id*
touch                     GET     /api/document-families/{id}/touch       path: id*

Executing Operations

Basic Syntax

kdx run <resource-type> <operation> [--param value] [flags]

Path Parameters

Path parameters (marked with *) are required and passed as flags:
kdx run document-families get-document-families --id abc123

Query Parameters

Query parameters are optional and passed as flags:
kdx run document-families data --id abc123 --format json --includeIds true

Request Body

For POST/PUT operations, use --body with JSON:
kdx run document-families status --id abc123 --body '{"status": "APPROVED"}'

Common Operations

Document Families

# Get document family details
kdx run document-families get-document-families --id <doc-family-id>

# Get external data keys
kdx run document-families external-data-keys --id <doc-family-id>

# Get external data by key
kdx run document-families external-data-get --id <doc-family-id> --key transformed_objects

# Get processing steps
kdx run document-families steps --id <doc-family-id>

# Reprocess document
kdx run document-families reprocess --id <doc-family-id> --assistantId <assistant-id>

# Touch document (trigger event without changes)
kdx run document-families touch --id <doc-family-id>

Projects

# List available operations
kdx run projects

# Get project assistants
kdx run projects get-apiprojects-assistants --id <project-id>

# Get project resources
kdx run projects get-apiprojects-resources --id <project-id>

# Get project data forms
kdx run projects get-apiprojects-dataforms --id <project-id>

Stores

# List store operations
kdx run stores

# Get store contents
kdx run stores list-store-contents --ref <store-ref>

Taxonomies

# Export taxonomy
kdx run taxonomies get-apitaxonomies--export --ref <taxonomy-ref>

# Get taxonomy sequence
kdx run taxonomies get-apitaxonomies--sequence --ref <taxonomy-ref>

Output Formats

Control output format with the -o flag:
# JSON output (default for run)
kdx run document-families get-document-families --id abc123 -o json

# Table output
kdx run document-families external-data-keys --id abc123 -o table

# YAML output
kdx run document-families get-document-families --id abc123 -o yaml

Piping and Processing

Combine with standard tools for data processing:
# Get document family and extract labels
kdx run document-families get-document-families --id abc123 -o json | \
  jq '.labels[].label'

# Get all external data keys
kdx run document-families external-data-keys --id abc123 -o json | \
  jq -r '.[]'

# Export and save to file
kdx run document-families external-data-get --id abc123 --key transformed_objects -o json > data.json

Available Resources

To see all resources that support dynamic operations:
kdx api-resources
Common resources with extended operations:
ResourceDescription
document-familiesDocument processing and data
projectsProject management
storesDocument and data stores
taxonomiesData definitions
assistantsProcessing pipelines
executionsPipeline executions
tasksUser tasks

Examples

Get Document Processing Status

# Get full document family with all metadata
kdx run document-families get-document-families --id abc123 -o json | \
  jq '{
    id: .id,
    labels: [.labels[].label],
    pending: .pendingProcessing,
    contentObjects: .contentObjects | length
  }'
Output:
{
  "id": "abc123",
  "labels": ["FIRST-PASS", "LABELED", "PROCESSED"],
  "pending": false,
  "contentObjects": 6
}

Get External Data

# List available data keys
kdx run document-families external-data-keys --id abc123

# Get transformed output
kdx run document-families external-data-get --id abc123 --key transformed_objects -o json

Bulk Operations

# Reprocess all documents in a project
for id in $(kdx get document-families --filter "store.project.id:$PROJECT_ID" -o json | jq -r '.[].id'); do
  echo "Reprocessing $id"
  kdx run document-families reprocess --id $id --assistantId $ASSISTANT_ID
done

Troubleshooting

Operation Not Found

Error: operation 'xyz' not found for resource 'document-families'
Solution: List available operations with kdx run document-families

Missing Required Parameter

Error: missing required parameter: id
Solution: Add the required flag, e.g., --id <value>

Invalid JSON Body

Error: invalid JSON in --body
Solution: Ensure JSON is properly formatted and quoted:
--body '{"key": "value"}'

Resource Not Found

Error: resource type 'xyz' not found
Solution: List available resources with kdx api-resources