DocuTray
CLICommands

Types

Reference for the `docutray types` command in the DocuTray CLI — usage, flags, arguments, and examples.

Manage document types (extraction schemas). Document types define the fields and structure that DocuTray extracts from documents during conversion.

docutray types create

Create a new document type. Defines an extraction schema that DocuTray uses when converting documents. Requires a name, code, description, and JSON schema. The schema can be provided as a file path or inline JSON string. Files exported via "types export" are also accepted: the inner jsonSchema is extracted automatically.

USAGE
  $ docutray types:create --code <value> --description <value> --name <value> --schema <value> [--conversion-mode
    json|toon|multi_prompt] [--conversion-spec <value>] [--identify-hints <value>] [--json] [--keep-ordering]
    [--prompt-hints <value>] [--publish | --draft]

FLAGS
  --code=<value>              (required) Unique code identifier (lowercase, numbers, underscores)
  --conversion-mode=<option>  Conversion mode
                              <options: json|toon|multi_prompt>
  --conversion-spec=<value>   Export spec (JSON → CSV/Excel column mapping): file path or inline JSON. Accepts a bare
                              spec ({"columns":[...]} or {"sheets":[...]}) or a full "types export" payload. Takes
                              precedence over a spec embedded in --schema.
  --description=<value>       (required) Description of the document type
  --[no-]draft                Create as draft (default: true)
  --identify-hints=<value>    Hints for automatic document identification
  --json                      Output as JSON (default when piped)
  --keep-ordering             Preserve property ordering in extraction output
  --name=<value>              (required) Document type name
  --prompt-hints=<value>      General extraction prompt hints
  --publish                   Publish immediately (equivalent to --no-draft)
  --schema=<value>            (required) JSON schema: file path or inline JSON string. When given a full "types export"
                              payload, its conversionSpec is carried over too.

DESCRIPTION
  Create a new document type. Defines an extraction schema that DocuTray uses when converting documents. Requires a
  name, code, description, and JSON schema. The schema can be provided as a file path or inline JSON string. Files
  exported via "types export" are also accepted: the inner jsonSchema is extracted automatically.

EXAMPLES
  Create from a schema file

    $ docutray types create --name "Invoice" --code invoice --description "Standard invoice" --schema schema.json

  Create with inline JSON schema

    $ docutray types create --name "Invoice" --code invoice --description "Standard invoice" --schema \
      '{"type":"object","properties":{"total":{"type":"number"}}}'

  Round-trip: export an existing type and re-create it (schema and export spec are carried over)

    $ docutray types export factura -o factura.json && docutray types create --name "Factura Copy" --code \
      factura_copy --description "Copy of factura" --schema factura.json

  Create and publish immediately

    $ docutray types create --name "Invoice" --code invoice --description "Standard invoice" --schema schema.json \
      --publish

  Create with a specific conversion mode

    $ docutray types create --name "Invoice" --code invoice --description "Standard invoice" --schema schema.json \
      --conversion-mode toon

  Create with an export spec (JSON → CSV/Excel column mapping)

    $ docutray types create --name "Invoice" --code invoice --description "Standard invoice" --schema schema.json \
      --conversion-spec spec.json

DOCUMENTATION
  Learn more: https://docs.docutray.com/cli/types/create

See code: src/commands/types/create.ts

docutray types export CODE

Export a document type definition to JSON format. By default, writes to stdout for piping or redirection. Use --output to write directly to a file. Useful for backing up type definitions, version-controlling them in Git, or migrating types between environments.

USAGE
  $ docutray types:export CODE [--force] [--json] [-o <value>]

ARGUMENTS
  CODE  Document type code

FLAGS
  -o, --output=<value>  Output file path. If omitted, writes to stdout.
      --force           Overwrite existing file
      --json            Output as JSON (default when piped)

DESCRIPTION
  Export a document type definition to JSON format. By default, writes to stdout for piping or redirection. Use --output
  to write directly to a file. Useful for backing up type definitions, version-controlling them in Git, or migrating
  types between environments.

EXAMPLES
  Export a document type to stdout

    $ docutray types export electronic-invoice

  Export directly to a file

    $ docutray types export electronic-invoice -o invoice-type.json

  Export using shell redirection

    $ docutray types export electronic-invoice > backup.json

  Export and pretty-print with jq

    $ docutray types export electronic-invoice | jq .

DOCUMENTATION
  Learn more: https://docs.docutray.com/cli/types/export

See code: src/commands/types/export.ts

docutray types get CODE

Get the full details of a document type by its code. Returns the type name, description, field schema, and configuration. Use this to inspect a document type before converting documents or to verify type settings.

USAGE
  $ docutray types:get CODE [--json]

ARGUMENTS
  CODE  Document type code

FLAGS
  --json  Output as JSON (default when piped)

DESCRIPTION
  Get the full details of a document type by its code. Returns the type name, description, field schema, and
  configuration. Use this to inspect a document type before converting documents or to verify type settings.

EXAMPLES
  Get full details of a document type

    $ docutray types get electronic-invoice

  Output full JSON (includes JSON Schema)

    $ docutray types get electronic-invoice --json

  Extract just the JSON Schema (useful for scripts)

    $ docutray types get electronic-invoice | jq .jsonSchema

DOCUMENTATION
  Learn more: https://docs.docutray.com/cli/types/get

See code: src/commands/types/get.ts

docutray types list

List available document types with pagination and search. Document types define the extraction schema used when converting documents. Results are paginated — use --page and --limit to navigate through large result sets. Use --search to filter by name.

USAGE
  $ docutray types:list [--json] [--limit <value>] [--page <value>] [--search <value>]

FLAGS
  --json            Output as JSON (default when piped)
  --limit=<value>   [default: 20] Number of results per page
  --page=<value>    [default: 1] Page number for pagination
  --search=<value>  Filter document types by name (case-insensitive substring match)

DESCRIPTION
  List available document types with pagination and search. Document types define the extraction schema used when
  converting documents. Results are paginated — use --page and --limit to navigate through large result sets. Use
  --search to filter by name.

EXAMPLES
  List all document types (first page, default 20 results)

    $ docutray types list

  Search for document types by name

    $ docutray types list --search invoice

  Paginate through results

    $ docutray types list --limit 50 --page 2

  Force JSON output

    $ docutray types list --json

  Extract just the type codes (useful for scripting)

    $ docutray types list | jq ".data[].codeType"

DOCUMENTATION
  Learn more: https://docs.docutray.com/cli/types/list

See code: src/commands/types/list.ts

docutray types rules get CODE

Get the DSL business rules of a document type. Rules are validated against the data extracted from each document, after the JSON Schema. Use --raw to print only the rules text, e.g. to save it to a file, edit it and upload it again with "types rules set".

USAGE
  $ docutray types:rules:get CODE [--json | --raw]

ARGUMENTS
  CODE  Document type code

FLAGS
  --json  Output as JSON (default when piped)
  --raw   Print only the rules text (empty when the type has no rules)

DESCRIPTION
  Get the DSL business rules of a document type. Rules are validated against the data extracted from each document,
  after the JSON Schema. Use --raw to print only the rules text, e.g. to save it to a file, edit it and upload it again
  with "types rules set".

EXAMPLES
  Show the rules of a document type

    $ docutray types rules get invoice

  Save the rules to a file

    $ docutray types rules get invoice --raw > rules.dsl

  Output as JSON ({codeType, dslRules})

    $ docutray types rules get invoice --json

DOCUMENTATION
  Learn more: https://docs.docutray.com/cli/types/rules/get

See code: src/commands/types/rules/get.ts

docutray types rules set CODE [RULES]

Save the DSL business rules of a document type of your organization, replacing the stored ones. Public platform types cannot be modified. Rules that fail to compile are rejected with their line and column, and nothing is saved. Use "types rules test" first to try rules against sample data without saving them, and --clear to remove all rules.

USAGE
  $ docutray types:rules:set CODE [RULES] [--clear] [--json]

ARGUMENTS
  CODE     Document type code
  [RULES]  DSL rules: file path, "-" to read from stdin, or inline text. A value that looks like a path (no spaces, with
           / or a .dsl/.txt extension) must exist

FLAGS
  --clear  Remove all DSL rules from the document type
  --json   Output as JSON (default when piped)

DESCRIPTION
  Save the DSL business rules of a document type of your organization, replacing the stored ones. Public platform types
  cannot be modified. Rules that fail to compile are rejected with their line and column, and nothing is saved. Use
  "types rules test" first to try rules against sample data without saving them, and --clear to remove all rules.

EXAMPLES
  Save rules from a file

    $ docutray types rules set invoice rules.dsl

  Save rules from stdin

    cat rules.dsl | docutray types rules set invoice -

  Remove all rules from the document type

    $ docutray types rules set invoice --clear

DOCUMENTATION
  Learn more: https://docs.docutray.com/cli/types/rules/set

See code: src/commands/types/rules/set.ts

docutray types rules test CODE

Validate document data against a document type's JSON Schema and DSL rules without saving anything. By default the stored rules are used; pass --rules to try new rules (dry-run) before saving them with "types rules set". Exit codes: 0 when the data is valid, 1 when it is invalid, 2 on any other error (API, rules that fail to compile, invalid input), so it can gate scripts and CI.

USAGE
  $ docutray types:rules:test CODE --data <value> [--json] [--rules <value>]

ARGUMENTS
  CODE  Document type code

FLAGS
  --data=<value>   (required) Document data to validate: JSON file path, inline JSON, or "-" for stdin
  --json           Output as JSON (default when piped)
  --rules=<value>  DSL rules to test instead of the stored ones: file path, "-" for stdin, or inline text. A value that
                   looks like a path (no spaces, with / or a .dsl/.txt extension) must exist

DESCRIPTION
  Validate document data against a document type's JSON Schema and DSL rules without saving anything. By default the
  stored rules are used; pass --rules to try new rules (dry-run) before saving them with "types rules set". Exit codes:
  0 when the data is valid, 1 when it is invalid, 2 on any other error (API, rules that fail to compile, invalid input),
  so it can gate scripts and CI.

EXAMPLES
  Validate data against the stored rules

    $ docutray types rules test invoice --data extracted.json

  Try new rules without saving them

    $ docutray types rules test invoice --data extracted.json --rules rules.dsl

  Validate freshly extracted data from stdin

    $ docutray convert invoice.pdf -t invoice | jq .data | docutray types rules test invoice --data -

DOCUMENTATION
  Learn more: https://docs.docutray.com/cli/types/rules/test

See code: src/commands/types/rules/test.ts

docutray types update CODE

Update an existing document type. Allows modifying name, description, schema, prompt hints, and other settings. At least one field to update must be provided. The code identifier cannot be changed.

USAGE
  $ docutray types:update CODE [--conversion-mode json|toon|multi_prompt] [--conversion-spec <value> |
    --no-conversion-spec] [--description <value>] [--identify-hints <value>] [--json] [--keep-ordering] [--name <value>]
    [--prompt-hints <value>] [--publish | --draft] [--schema <value>]

ARGUMENTS
  CODE  Document type code to update

FLAGS
  --conversion-mode=<option>  Conversion mode
                              <options: json|toon|multi_prompt>
  --conversion-spec=<value>   Export spec (JSON → CSV/Excel column mapping): file path or inline JSON. Accepts a bare
                              spec ({"columns":[...]} or {"sheets":[...]}) or a full "types export" payload.
  --description=<value>       New description
  --[no-]draft                Set draft status
  --identify-hints=<value>    Hints for automatic document identification
  --json                      Output as JSON (default when piped)
  --[no-]keep-ordering        Preserve property ordering in extraction output
  --name=<value>              New name
  --no-conversion-spec        Remove the export spec from the document type
  --prompt-hints=<value>      General extraction prompt hints
  --publish                   Publish immediately (sets draft to false)
  --schema=<value>            New JSON schema: file path or inline JSON string. Unlike "types create", a conversionSpec
                              embedded in a "types export" payload is ignored — use --conversion-spec to change it.

DESCRIPTION
  Update an existing document type. Allows modifying name, description, schema, prompt hints, and other settings. At
  least one field to update must be provided. The code identifier cannot be changed.

EXAMPLES
  Update the name

    $ docutray types update invoice --name "Updated Invoice"

  Update the schema from a file

    $ docutray types update invoice --schema new-schema.json

  Update prompt hints

    $ docutray types update invoice --prompt-hints "Use dd/mm/yyyy for dates"

  Publish a draft type

    $ docutray types update invoice --publish

  Replace the export spec (JSON → CSV/Excel column mapping)

    $ docutray types update invoice --conversion-spec spec.json

  Remove the export spec from the type

    $ docutray types update invoice --no-conversion-spec

DOCUMENTATION
  Learn more: https://docs.docutray.com/cli/types/update

See code: src/commands/types/update.ts

On this page