# Connections

Connections define how Tediware communicates with your trading partners. Each connection specifies a protocol (SFTP, hosted SFTP, AS2, or API) and the credentials or configuration needed to exchange files. A single connection can serve one partner directly, or be shared across multiple partners using VAN routing.

## Connection Types

### SFTP

SFTP connections use SSH-based file transfer. You provide a host, port, username, and either a password or SSH key. Tediware connects to the remote server to upload or download files as part of your flow processing.

If your trading partner firewalls their SFTP server, they will need to whitelist Tediware's outgoing IP addresses: `16.54.110.1` and `99.79.30.151`.

#### Authentication

In the connection's **Authentication** section, choose **Password**, **SSH key**, or **Password and SSH key** if your partner's server requires both.

A saved password, private key or passphrase can't be viewed again. When you edit the connection, leave a field empty to keep the saved value. To stop using a password, choose **SSH key** and click **Remove password**.

If you change the host or port of a connection that has a saved password, enter the password again in the same save. Tediware doesn't send a saved password to a different server.

If your trading partner asks for your SSH public key, choose **SSH key** and click **Generate key pair**. Tediware creates the key pair and keeps the private key. Save the connection within the hour, then copy or download the public key and send it to your partner, who adds it to the account for the username they gave you. The public key stays on the connection's page, and the private key can't be viewed or downloaded. To replace the key, edit the connection and generate a new key pair, then send your partner the new public key. To stop using a key, edit the connection and click **Remove key**. The connection then needs a password.

To use a key pair of your own instead, choose **I already have a private key**:

1. Generate a key pair on your computer. Use one key pair for each partner so you can revoke it without affecting other connections:

   ```
   ssh-keygen -t ed25519 -f tediware_partnername
   ```

   If your partner requires RSA, use `ssh-keygen -t rsa -b 4096 -f tediware_partnername` instead.
2. Send your partner the public key, the file ending in `.pub`.
3. Paste the private key, the file without the `.pub` extension, into the **Private key** field. It starts with `-----BEGIN OPENSSH PRIVATE KEY-----`. If you set a passphrase when generating the key, enter it in **Passphrase**. To remove a pasted key, edit the connection and click **Remove key**.

Once the connection test passes, delete the key files from your computer. Never send the private key to your partner or anyone else.

### Hosted SFTP

A hosted SFTP connection runs on Tediware's SFTP infrastructure and is used for partners who need to connect to a server you provide. Your partner logs in and uploads files to `toTediware`, and downloads the files Tediware writes for them from `fromTediware`. (Those folder names are the defaults and can be changed.) It is included in the Growth plan and higher. See Hosted SFTP Connections below.

### AS2

AS2 (Applicability Statement 2) is a secure, HTTP-based protocol designed for EDI document exchange. AS2 connections use digital certificates for encryption and signing, providing non-repudiation via MDN (Message Disposition Notification) receipts.

### API

API connections allow Tediware to send processed data to HTTP endpoints via webhooks or REST calls.

## VAN Routing

A Value Added Network (VAN) is a third-party service that acts as a central hub for EDI file exchange. Instead of maintaining a separate connection to each trading partner, you connect to the VAN, and the VAN routes files between you and your partners.

When you enable **VAN Routing** on a connection, Tediware automatically routes each inbound file to the correct partner by inspecting the ISA header in the EDI document. Specifically, it matches the sender and receiver identifiers (and their qualifiers) against the envelopes configured on your partners. This means multiple partners can share the same connection, because Tediware determines which partner each file belongs to based on the EDI content itself.

To use VAN routing:

1. Create a single connection pointing to your VAN
2. Enable the **VAN Routing** checkbox on the connection
3. Assign that connection to each partner that communicates through the VAN
4. Ensure each partner has its **Internal Envelope** and **External Envelope** configured with the correct ISA identifiers and qualifiers

Your internal envelope can be shared by every partner on the connection. Only the external envelopes need to differ.

VAN Routing also applies when a single partner sends under more than one sender ID over one connection, such as drop-ship orders from one ID and ship-to-store orders from another. Enable it, even though there is only one real-world partner, and set up one partner per sender ID. See Partners with Multiple ISA Identifiers in the [Partners](partners.md) documentation.

When a file arrives, Tediware reads the ISA header and matches it against partner envelopes. If a match is found, the file is processed through that partner's inbound flow. If no match is found (for example, because the sender ID does not correspond to any configured partner), the file is logged as a routing error and skipped.

VAN routing is available on SFTP, hosted SFTP, AS2, and Sandbox connections.

### VAN routing is not the VAN add-on

These are two different things with similar names, and neither requires the other.

**VAN Routing**, the checkbox described above, is a free technical feature. It tells Tediware how to sort inbound files on a shared connection, whoever operates the other end. If you already hold an account with a VAN such as ECGrid, you connect to it with an ordinary SFTP connection and tick VAN Routing; there is no charge from Tediware beyond your plan's usual per-transaction pricing.

**The VAN add-on** is a paid subscription for a connection to a value-added network, provisioned through Tediware. You need it when you want to reach partners over a VAN but do not have your own VAN account. It is billed separately from your plan; see the Billing page for pricing.

After you subscribe, Tediware sets the connection up on the network and creates it in your account for you: an SFTP connection with VAN Routing enabled. We email you when it is ready. You can rename and tag that connection and assign partners to it; the host, credentials, and directories are managed by Tediware, and it cannot be deleted from your account. To remove it, use **Request removal** on the Billing page, and we decommission the connection on the network before removing it and the add-on.

With the add-on active, you do not build SFTP or AS2 connections to your trading partners. Assign each partner to your VAN connection and set its interchange IDs. Sandbox, API, and webhook connections are unaffected. If a partner is not yet reachable on the network, open the partner and click **Request connection**.

You do not create connections to the network yourself. If you hold your own contract with the network provider and want to connect to that account, create the connection as usual and tick the box declaring your own contract; without it, the connection form refuses the provider's host.

## Creating a Connection

1. Navigate to **Partners** and select a partner, or go to **Connections** directly
2. Click **New Connection**
3. Select the connection type (SFTP, hosted SFTP, AS2, or API)
4. Fill in the required fields for your chosen type
5. Optionally enable **VAN Routing** if this connection is shared across multiple partners
6. Save the connection

## Deleting a Connection

A connection assigned to a partner, or used by a node in a flow, cannot be deleted. Free it first: reassign the partner, and change the node's connection or rebuild the flow.

## AS2 Connections

AS2 connections require additional setup beyond basic connection details.

### Certificates

AS2 uses four certificates organized into two pairs:

- **Local signing certificate**: used by Tediware to sign outbound messages
- **Local encryption certificate**: used by trading partners to encrypt messages they send to you
- **Partner signing certificate**: used to verify signatures on messages received from the partner
- **Partner encryption certificate**: used by Tediware to encrypt outbound messages to the partner

All four certificate slots must be assigned before you can activate an AS2 connection. Upload certificates from the connection detail page using the **Certificates** tab.

Certificates come in two types, and each carries a usage:

- **Local certificates** are your own and must include a private key. **Partner certificates** belong to your trading partner and do not include a private key.
- A certificate's usage is **Signing**, **Encryption**, or **Both**. A single certificate set to **Both** can fill both the signing and encryption slots for its type (local or partner).

#### Replacing a Certificate on an Active Connection

Certificates expire, and partners rotate theirs. You can replace a certificate on an active connection without interrupting traffic. Click **Schedule replacement** on a slot, choose an existing certificate or import a new one, and set:

- **Takeover date**: the date you and your partner agreed on.
- **Keep accepting the old certificate for**: a grace period after the takeover date, 14 days by default. Until it ends, both certificates are in place.

What happens on the takeover date depends on the slot:

- **Local signing**: your messages are signed with the new certificate. Send your partner the public certificate (**Download public certificate**) before the takeover date, or they will not be able to verify your messages.
- **Local encryption**: the new certificate is accepted as soon as you schedule it, so your partner can switch whenever they are ready. Messages encrypted to the old certificate are rejected once the grace period ends.
- **Partner signing**: signatures from either certificate are accepted until the grace period ends.
- **Partner encryption**: your messages are encrypted to the partner's new certificate.

When the grace period ends, Tediware removes the old certificate from the connection. You can also retire it early with **Retire now** once the new certificate has taken over, or cancel a scheduled replacement before then. When the same certificate fills both slots of a pair, the sheet offers to use the new certificate for both, and schedules them together.

A local certificate that you use for signing with several partners takes over on one date for all of them. Schedule the replacement on every connection that uses it before that date. If you schedule it on another connection after the date has passed, it takes over there immediately, so that partner must already have it.

To change AS2 IDs, the partner URL or algorithms, duplicate the connection and activate the copy as a replacement.

#### Importing a Certificate

Import certificates from the **Certificates** tab. Each certificate has:

- **Name**: a descriptive label, for example "Acme Corp Signing Certificate".
- **Certificate Type**: Local or Partner.
- **Usage**: Signing, Encryption, or Both.
- **Certificate PEM**: the certificate content in PEM format.
- **Private Key PEM**: required for local certificates only.
- **Certificate Chain PEM**: optional; include intermediate certificates if needed.

Tediware reads the certificate and displays its subject, issuer, expiration date, and SHA-256 fingerprint.

#### Certificate Expiration

Each certificate shows its expiration date. Tediware warns you when a certificate is within 30 days of expiring and marks certificates that have already expired. Replace certificates before they expire to avoid transmission failures.

When a certificate on an active connection has no replacement scheduled, Tediware emails everyone in your organization who receives error notifications 30, 7 and 1 days before it expires, and again when it expires. The emails stop once every connection using the certificate has a replacement scheduled. To schedule one, see Replacing a Certificate on an Active Connection above.

### AS2 Identifiers

Each party in an AS2 exchange has a unique AS2 ID. You will set:

- **Your AS2 ID**: identifies Tediware in the exchange (often your company name or a code agreed with the partner)
- **Partner AS2 ID**: identifies the trading partner

These identifiers must match exactly what each party expects.

### Encryption, Signing, and MDN Settings

When you create an AS2 connection you also set how messages are secured and acknowledged. Coordinate these with your trading partner so both sides match:

- **Encryption Algorithm**: AES128_CBC (default), AES192_CBC, AES256_CBC, AES128_GCM, or AES256_GCM.
- **Signing Algorithm**: SHA256 (default), SHA1, SHA384, or SHA512.
- **MDN Response**: how your partner acknowledges receipt: SYNC (default, immediate), ASYNC (deferred), or NONE.
- **Compression**: ZLIB compression on outbound messages, disabled by default.

These fields are locked while the connection is active. Change them with the duplicate-and-replace flow under **Replacing an Active Connection**.

### Activation

Once certificates and identifiers are configured:

1. Click **Activate** on the connection detail page
2. Tediware provisions the necessary infrastructure (this takes a few seconds)
3. The status changes from **Inactive** to **Active**

While active, certain fields are locked and cannot be modified (AS2 IDs, partner URL, encryption/signing algorithms). To change these, duplicate the connection, configure the copy, then activate it as a replacement.

### Replacing an Active Connection

If you need to update locked fields on an active AS2 connection:

1. **Duplicate** the existing connection
2. Modify the settings on the new copy
3. **Activate** the new connection: you will be prompted to replace the old one
4. Tediware automatically migrates flow references from the old connection to the new one

### Deactivation

Click **Deactivate** to tear down the AS2 infrastructure for a connection. This returns it to an inactive state where all fields can be edited again.

### Troubleshooting AS2

- **Activation fails**: Ensure all four certificate slots are filled and your organization has the AS2 add-on enabled
- **Messages not arriving**: Verify that the partner is sending to the correct AS2 URL and using the correct AS2 IDs
- **Signature or encryption errors**: Confirm that the partner's certificates match what you have uploaded, and vice versa

## Hosted SFTP Connections

Tediware runs the SFTP server and each hosted connection is one login on it for one partner. Your partner only needs the login details. Logins use a username and password; SSH keys and FTPS are not currently supported (contact us if you require these options).

Hosted SFTP is included in the Growth, Scale, Platform and Enterprise plans (see Hosted SFTP in the [Administration](administration.md) documentation). On Developer and Dev+, or while a subscription is suspended, Hosted SFTP appears in the connection form's Kind list but cannot be chosen.

### Creating a Hosted Connection

Choose **Hosted SFTP** as the kind. Apart from the name, every field is optional:

- **Username**: leave it blank and Tediware generates one. A username of your own is 3 to 100 letters, digits, or the characters `_ @ . -`, starts with a letter, digit or `_`, and does not start with `dev-` or `stg-`. Usernames are unique across every Tediware account, so one that is already in use is refused as not available. A partner moving from another provider can keep the username they already have, if it is free. After 10 usernames are refused within an hour, new ones are refused until that hour is up.
- **Password**: generated (32 characters), or one you supply, of at least 16 characters and at most 72 bytes.
- **Folders and allowed addresses**: the folder your partner uploads to (`toTediware` by default) and the folder they download from (`fromTediware` by default), and the addresses your partner may log in from.

When you submit, Tediware shows the details to give your partner, including the password. **The password is only shown once.** Copy it, or use **Copy all as text**, and tick **I have saved the password** to continue. Setup starts at the same time and takes a few seconds.

### What to Give Your Partner

The connection page lists everything your partner needs except the password. Once the connection is active and has files, these details are tucked behind **Connection details**, above the list of files.

- Host `sftp.tediware.com`, port 22
- The username
- The server's host key fingerprints (Ed25519 and RSA), so your partner can confirm they reached Tediware's server
- The server's addresses, `3.99.82.227` and `3.99.4.98`, for a partner whose firewall only lets them connect to listed addresses
- The two folders

### Password

Tediware keeps only a hash of the password, so it cannot show it again. If your partner loses it, click **Regenerate** on the connection page. The old password stops working immediately, and the new one is shown once, just like during creation. To set a password of your own instead, edit the connection and choose **Use an existing password**.

### Allowed Addresses

Under **Folders and allowed addresses**, list the IP addresses or CIDR ranges your partner logs in from, one per line, up to 20. A login from any other address is refused, and your partner sees it as a wrong password. Leave the list empty to allow any address.

### Receiving Files

A file your partner uploads to a receiving folder is received as soon as the upload finishes, usually within a minute, whatever the flow's schedule. Tediware routes it to the partner's active inbound flow, or by its ISA envelope when the connection has VAN Routing on. A client that uploads under a temporary name, such as `invoice.edi.filepart`, and renames the file when it finishes, is received under the final name.

Tediware receives only files directly in a receiving folder: `toTediware`, or a folder an inbound transaction setting names as its Remote Directory when VAN Routing is off (see the [Partners](partners.md) documentation). A file uploaded anywhere else, including a folder inside a receiving folder, is left where it is and listed on the connection's page as an error.

Once a file has reached its flow, the flow's **After fetching** setting decides whether it stays on the server. Flows on a hosted connection start with **Delete files**. Tediware never deletes a file it could not route; it stays until the 45-day removal.

### Files That Could Not Be Routed

A file in a receiving folder is not routed when it is not an X12 interchange, when no partner's envelope matches it, or when the partner has no active inbound flow. The connection's page lists it as an error with the reason, and the file stays on the server. Tediware records an error in your logs naming the connection and the most recent file, at most once a day per connection, so it reaches everyone who receives error notification emails. A file outside the receiving folders is listed there too, but raises no error.

Tediware never tries such a file again on its own. Fix the issue, then click **Try again** beside the file's error, or **Try all again** under **Errors** for all of them, up to 500 at a time, while the files are still on the server. Tediware reads each file as it is on the server now and routes it with the connection's current setup. A file your partner has since deleted or replaced drops off the list; a replacement is received as a new upload.

If your partner has already uploaded a file again, trying the old one again delivers the document to your flow a second time.

### Files for Your Partner

Outbound documents for your partner are written to `fromTediware`, or to their transaction setting's Remote Directory if it has one. 997 acknowledgments always go to the connection's download folder. If a file of the same name is still waiting there, the new one gets a number before its extension (`invoice-1.edi`), so nothing waiting is overwritten. A resend always writes a new file, even when the original is still waiting, so your partner finds the resend beside it under a numbered name.

Tediware records each download. Downloading does not delete a file: your partner deletes it, or it is removed 45 days after it was written. When files have waited more than a day without being downloaded, Tediware records a warning naming the connection, then again at most once a day while any are still waiting.

### Files

A hosted connection's page lists every file your partner uploaded and every file Tediware wrote for them, newest first, with its folder and what happened to it, such as routed (with a link to its trace), waiting for pickup, picked up, or an error with its reason. Filter it to **Errors**, which includes files Tediware could not route or process, or **Waiting for pickup**. **Try again** beside an error receives the file again once you have fixed what stopped it (see Files That Could Not Be Routed, above), and the file reads **Receiving** until Tediware has finished with it. A file Tediware could not process can be tried again half an hour after it failed. When files have waited more than a day, the page says how many and when the oldest is removed from the server.

### Activating and Deactivating

**Deactivate** ends your partner's access: they can no longer log in. Files already on the server stay until they are removed 45 days after they were written. **Activate** gives the same login back, with the same password. Deleting the connection removes the login, and files left on the server are removed 45 days after they were written.

While the connection is setting up, active or shutting down, its username cannot change. Hosted connections cannot be duplicated, since duplicating is only for replacing an active AS2 connection. An existing connection cannot be changed to or from Hosted SFTP. Create a new connection instead.

If setup fails, the connection page says why. A username that turns out to be in use gets **Edit username**. Otherwise, click **Retry setup**.

If your plan stops including hosted SFTP, every hosted connection shuts down and your partners can no longer log in.

## Using Connections in Flows

Connections are referenced by **Input** and **Output** nodes in your flows:

- **Input nodes** monitor a connection for incoming files and feed them into the flow
- **Output nodes** send processed results to a connection

A single connection can be used by multiple flows simultaneously. When VAN routing is enabled, a single inbound fetch can dispatch files to different partner flows based on their ISA identifiers.

## Testing a Connection

From the connection detail page, click **Test** to verify a connection is set up correctly. The test runs in the background and the dialog shows live progress and a final success or failure verdict, with a link to the full logs.

For SFTP, the test connects, reads the inbound and outbound directories, and uploads a small test file to the outbound directory. Reading that file back and deleting it are best-effort, so a VAN mailbox that sweeps the outbound directory immediately (such as ECGrid) still passes. Because the test uploads a file, you may want to let your trading partner know before running it. An unreachable server fails the test quickly.

For AS2, the test checks that the connection is set up, that its storage is reachable, and that the assigned certificates are present and not expired. Nothing is sent to your trading partner. The connection must be activated before it can be tested.

For hosted SFTP, the test checks that the server has your partner's login as the connection describes it, and that Tediware can write and delete a file in the connection's storage. It does not log in over SFTP, and the connection must be active.

## Interrupted SFTP Downloads

Some VAN mailboxes, ECGrid among them, mark a file as downloaded the moment it is read, and the file no longer appears in the directory afterward. If the connection drops or the server stops responding while Tediware is downloading such a file, the file can be gone from the mailbox before Tediware has it.

When a fetch stops partway through, its warning in the logs names the file that was being downloaded. On the next poll, Tediware checks whether that file is still on the server. If it is, Tediware fetches it as usual. If it is not, Tediware records an error on the flow that was fetching it, naming the file and the connection. The error goes to the flow's error handler and to error notification emails like any other processing error, so you can alert on it.

The error also gives the file's size and its date on the server, when the server lists them. Use these to find the file in your mailbox provider's portal.

To get the file back, reset its download in your mailbox provider's portal so it reappears in the directory, or ask the sender to resend it.

## Troubleshooting VAN Routing

- **Files are skipped with a routing error**: The ISA sender or receiver identifiers in the file do not match any partner's envelope configuration on this connection. Verify that the partner's external envelope has the correct interchange ID and qualifier.
- **Files route to the wrong partner**: Two partners may have overlapping envelope identifiers. Each partner on a VAN-routed connection must have a unique combination of sender ID, sender qualifier, receiver ID, and receiver qualifier.
- **Non-EDI files are skipped**: VAN routing requires valid EDI files with an ISA header. Files that do not begin with "ISA" are logged as warnings and skipped.
