> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stateset.com/llms.txt
> Use this file to discover all available pages before exploring further.

# EDI CLI and JavaScript SDK

> Use the terminal workbench, JSON command discovery, portable reviews, and scoped JavaScript integrations.

The source launcher `./stateset-edi` opens the terminal console; arguments select JSON
commands for agents. CLI **0.10.2** requires Python 3.8+ with curses for the interactive
view. Run `./stateset-edi --demo` for an offline simulation.

## Discover before acting

```bash theme={null}
export EDI_API_URL=https://api.edi.stateset.com
# Load EDI_API_TOKEN from your secret store.
./stateset-edi version
./stateset-edi commands
./stateset-edi explain -- order acme PO-2026-4411
./stateset-edi api operations
./stateset-edi order acme PO-2026-4411
```

`commands` exposes versioned effect and argument metadata, including nested paths, arity,
repeatable flags, and global-option placement. `explain -- ...` classifies concrete arguments
locally without reading credentials/payloads or contacting the API. Neither grants authority.
Use `api describe` for contract schemas and `api call` or `api request` for other routes.

| Exit | Meaning |
| - | - |
| 0 | Request succeeded; inspect the business verdict and capability fields |
| 1 | Request error, failed validation/preflight, or result requiring attention |
| 2 | Invalid arguments; one JSON error and no execution attempt |
| 130 | Interrupted |

## Terminal workbench

Tables retain focus and filter cursors across tabs. Filters and captured pickers operate
on loaded/captured rows; they do not establish complete server coverage. `id-exact:` and
`ref-exact:` compare case-sensitive literal identities; ordinary `id:`/`ref:` are substring
filters. Use partner scope where references repeat.

Below 60 columns or 18 rows, input pauses; queued keys are discarded when visible again.
Requests already started continue, and their results remain available. Local searching,
resizing, and exporting do not repeat a request or authorize recovery.

Use [portable order reviews](/stateset-edi/orders-and-recovery) for outbound fulfillment.
`review-inspect` checks captured facts locally. `order-send` submits the retained request
without another noninteractive confirmation prompt. Changed connection or credential
context can invalidate prepared observations; do not substitute new evidence for the
original operation after response loss.

## Read delivery evidence

```bash theme={null}
./stateset-edi evidence delivery DELIVERY_ID --assess
```

The client checks requested identity and compares reported current receipt/message/MIC
metadata. `metadata_consistent` is a client assessment, not independent S/MIME verification.
Missing metadata remains unknown. Preserve HTTP/correlation IDs and original response data;
a successful read does not prove transport or business completion.

Build a portable archive from source with
`python3 tui/package.py --output /tmp/stateset-edi-0.10.2.pyz`. Its `version` reports a
reproducible build identity. Treat exported reviews and artifacts according to their content.

## JavaScript SDK

The source package `@stateset/edi-client` **0.1.3** requires Node 20+ or a compatible Fetch
runtime. Use it in a trusted server integration. Build/install a local tarball from `sdk/`;
package qualification does not establish public registry publication.

```bash theme={null}
cd sdk
npm pack
# In your integration, install the resulting local tarball.
```

The example runs from a directory containing your `stateset-edi` source checkout:

```js theme={null}
import { EdiClient } from './stateset-edi/sdk/index.js';

const edi = new EdiClient({
  baseUrl: process.env.EDI_API_BASE ?? 'https://api.edi.stateset.com',
  token: process.env.EDI_API_TOKEN,
});
const orders = await edi.operationOrders();
const mail = await edi.mailDeliveries();
console.log({ orders, mail });
```

`previewOrder()` and `sendReviewedOrder()` support frozen overrides, original key, and
order revision. `outbound()` requires `idempotencyKey` and supports ten X12 types plus
EDIFACT INVOIC/DESADV. Its reviewed allowlist does not include REST 753/INVRPT; use those
REST routes directly. `request()` is a generic API helper, not the CLI's complete response
assessment layer.

The client refuses redirects and bounds response size/time. `EdiError` reports `code`,
`status`, `retryAfterSeconds`, and `outcomeUnknown`. It does not automatically retry writes.
Persist original requests durably and verify the returned artifact and business outcome.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.