# Envelopes

Envelopes define the routing and identification settings that wrap EDI transmissions. They populate the ISA and GS headers: the "from" and "to" addresses on every EDI interchange. You need at least one internal envelope (your own settings) and one external envelope for each trading partner.

## Internal vs External

There are two types of envelopes:

- **Internal**: represents your organization's EDI identity. You typically need just one internal envelope, shared across all your trading partners.
- **External**: represents a trading partner's EDI identity. You need one external envelope for each partner you exchange EDI with.

When Tediware generates an EDI transmission, it combines the internal envelope (sender settings) with the external envelope (receiver settings) to build the ISA and GS headers.

Your partner saves the same two identifiers on their side. Your internal envelope must match what the partner has configured as *you*, and your external envelope must match what the partner calls *themselves*. If either pair differs from what the partner has on file, the partner will not recognize your interchanges, and on a connection with VAN Routing enabled their files will not route to the right partner.

## Envelope Fields

### Name

A label for your own reference. This is never visible to trading partners and can be changed at any time.

### Interchange ID

The routing identifier placed in the ISA header. Think of the interchange ID and its qualifier together as an email address: they tell the receiving system who the transmission is from (or who it is addressed to).

- For **external envelopes**, your trading partner provides their interchange ID during onboarding.
- For **internal envelopes**, see Choosing your identifiers below.

### Interchange ID Qualifier

A two-character code that says what kind of identifier the interchange ID is. It always travels with the ID: `12` with a phone number, `01` with a DUNS number, and so on. Your trading partner specifies the qualifier alongside their interchange ID.

### Application Code

Used in the GS (group) header. This is typically the same as the interchange ID. If you leave it blank, Tediware sets it to the interchange ID automatically.

## Choosing your identifiers

Who sets your internal interchange ID and qualifier depends on your situation.

- **The partner assigned you an ID.** Use it exactly as given, qualifier included.
- **The partner asked for yours.** You choose one and send the partner both the qualifier and the ID. Use one of these:
  - `12` with your phone number: 10 digits, no spaces or punctuation.
  - `01` with your DUNS number, if your company has one.
  - `ZZ` with an ID you make up. There is no central registry for `ZZ` IDs, so pick something unlikely to be used by anyone else: your company name or a variant of it, not a generic word. Searching the web for the value before you use it is a reasonable check.
- **You connect through a VAN.** Your VAN mailbox identifier is usually your ISA ID. Use the qualifier and ID the VAN gave you.
- **You already trade with other partners.** Reuse your existing internal envelope. One internal envelope normally serves all of your partners.

### Common qualifiers

```
Qualifier  Identifier type
---------  --------------------------------------------
01         DUNS number
08         UCC EDI Communications ID
12         Phone number
14         DUNS number with a four-character suffix
ZZ         Mutually defined (any ID agreed with the partner)
```

### How identifiers are written

Partners and VANs usually write an identifier as `QUAL:ID`, for example `12:7724687008`. In Tediware the qualifier and the ID are separate fields: `12` goes in the qualifier and `7724687008` in the ID. Below those fields, the envelope form shows the **Full identifier** in this `QUAL:ID` form as you type, so you can compare it directly against what your partner sent you.

## EDI Separators

External envelopes include separator settings that control how the EDI output is delimited. The defaults are standard X12 separators:

- **Segment separator**: `~`
- **Element separator**: `*`
- **Component separator**: `:`

Use the defaults unless your trading partner specifies otherwise. Each separator must be a single non-alphanumeric character, and all three must be different from each other.

Separators are only configurable on external envelopes. Internal envelopes do not need them.

## Assigning Envelopes to Partners

Each partner requires one internal envelope and one external envelope. Assign them from the partner detail page:

1. Navigate to **Partners** and select the partner
2. Choose an **Internal Envelope** and an **External Envelope** from the dropdowns
3. Click **Save Envelopes**

You can reuse the same internal envelope across multiple partners. Each partner should have its own external envelope.

## Troubleshooting identifiers

- **Inbound files are skipped with a routing error.** The file's ISA sender does not match the partner's external envelope, or its ISA receiver does not match your internal envelope. Open the file and compare the ISA header (qualifier and ID in ISA05 and ISA06 for the sender, ISA07 and ISA08 for the receiver) against the two envelopes. See Troubleshooting VAN Routing in the [Connections](connections.md) documentation.
- **An inbound document has a sender mismatch warning.** The file's ISA sender is not the ID on the partner's external envelope. The document was still processed. See Warnings in the [EDI Transactions](edi-transactions.md) documentation.
- **The partner rejects or does not recognize your outbound interchanges.** Your internal envelope does not match what the partner set up for you, or the external envelope has their ID wrong. Ask the partner what qualifier and ID they have on file for you and for themselves.
- **The ID contains a colon, such as `12:7724687008`.** That is the combined `QUAL:ID` form. Split it: `12` in the qualifier and `7724687008` in the ID.
