DocuTray

Document Type Types

Type definitions for Document Type in the DocuTray Node.js SDK — request and response models, fields, and enums.

DocumentType

A document type definition from the API. dslRules, conversionSpec and the prompt hints are absent from list() responses; they are returned only by the single-document-type endpoints.

Prop

Type

DocumentTypeCreateParams

Parameters for documentTypes.create().

Prop

Type

DocumentTypeUpdateParams

Parameters for documentTypes.update(). Omitted fields keep their stored value.

Prop

Type

DocumentTypeValidateParams

Options for documentTypes.validate().

Prop

Type

ValidationResult

Result of validating a document against a document type with documentTypes.validate(). issues lists the structured errors followed by the warnings; see ValidationIssue.

Prop

Type

The errors and warnings summaries are ValidationErrorInfo and ValidationWarningInfo.

DocumentTypesListParams

Parameters for listing document types.

Prop

Type

ConversionMode

Conversion mode used when extracting from a document type.

type ConversionMode = 'json' | 'toon' | 'multi_prompt';

ConversionSpec

Mapping from extracted JSON to CSV/Excel columns, used by tray export: either the legacy single-table format (top-level columns) or the multi-sheet format (top-level sheets).

type ConversionSpec = LegacyConversionSpec | MultiSheetConversionSpec;

Prop

Type

Prop

Type

Prop

Type

Prop

Type

Type Guards

isValidationValid(result)

Returns true if the document is valid. Uses valid when the API returns it, and falls back to errors.count === 0 otherwise.

hasValidationWarnings(result)

Returns true if the validation result has warnings.

isMultiSheetConversionSpec(spec)

Returns true if the conversion spec uses the multi-sheet format. Accepts null and undefined.

import { isValidationValid, hasValidationWarnings } from 'docutray';

const result = await client.documentTypes.validate('YOUR_DOCUMENT_TYPE_ID', extracted);

if (isValidationValid(result)) {
  console.log('Document is valid');
  if (hasValidationWarnings(result)) {
    console.log('Warnings:', result.warnings.messages);
  }
}

On this page