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

# OFTP2 trading partner

> Exchange OFTP2 virtual files and retain matched signed EERP and NERP receipts.

The OFTP2 app opens bounded sessions to a fixed TLS endpoint. It checks
the partner's Odette identity and the pinned partner certificate's CMS
signature on each EERP or NERP. To settle an outgoing exchange, the
receipt must match the original agreement, virtual file identity, and
SHA-256 digest. The app retains the signed command as a File under the
mount's `data` label.

## Mount and bind

`oftp2({ data, partner })` returns the app to place at a path of your tree.
Bind the partner with `oftp2Partner(endpoint, agreement, label)`.

```ts app.ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { app, label, secret } from "@bijectionhq/bijection";
import oftp2, { oftp2Partner } from "@bijectionhq/app-oftp2";

const edi = label();
const agreement = secret();
const partner = oftp2Partner("edi.example.com:6619", agreement, edi);

export default app({ edi, agreement, partner, oftp2: oftp2({ data: edi, partner }) });
```

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
bijection secret set agreement --from-file agreement.json
```

`oftp2.operator` is granted from code: `ctx.grant(oftp2.operator, { to, under })` in one of your
mutations ([Grants](https://docs.bijection.com/access/grants.md)).

The mount places the partner subtree at `oftp2.partner`: `partner.send`,
`partner.get`, `partner.list` and `partner.status`, with its `outgoing`,
`incoming` and `connection` tables. Its `operator` role clears `data`, is the
only role those functions allow, and runs the session clock.

Use the same label for the receiver and the mount.

Set the agreement to JSON. Include
`odette_id`, `password`, `partner_odette_id`, `partner_password`,
`partner_host`, `partner_port`, `partner_certificate`, `our_certificate`,
and `our_key`. Use PEM certificates and a PKCS #8 PEM private key. The
host and port must match the receiver. TLS uses platform trust or the
installed `partner_tls_ca` PEM bundle. Supply `client_tls_identity` for
partners that require client TLS authentication. Agree on suite 04 and
signed SHA-256 replies. Keep the original signing principals available
while receipts remain outstanding.

## Sending and later receipts

Send canonical base64 data for one unstructured file of up to 24 KiB.
Supply the agreed `dataset`, a `CCYYMMDD` date, and an `HHMMSScccc` time
with a nonzero counter. Allocate the tuple once per pair of Odette
identities across installations. Repeating a send key with identical
content returns the original delivery. The mount's clock submits each
file once and continues polling after a task settles `Unknown`.

The app settles signed EERP and NERP responses in the sending session or
a later poll. Later responses can settle an `Unknown` send without
resubmitting the document. A different agreement, file identity, or digest
leaves the original exchange unsettled. A conflicting decision does not
replace the first settled result. Receipts are bounded to 16 KiB and
describe transport disposition.

## Receiving files

Configure the partner to present queued inbound files and receipts in
sessions Bijection initiates and to replay an item after a session ends
without its acknowledgement. The mounted clock alternates between
polling and queued sends, with one active session per mount and a
30-second transport deadline. This profile enables pull intake over that
socket. A partner-initiated public TCP listener is outside its scope.

The first presentation of a new file yields its bounded payload to the
root and ends the session before EFPA or EERP. The labelled continuation
stores the File, digest, and prepared EERP in one commit. On replay, the
driver compares the identity and digest against the ordered acceptance,
then returns EFPA and the retained signed EERP. A different digest for an
accepted identity is refused. A later receipt follows the same order.
The continuation commits its settlement before a replay can receive RTR.
An unmatched signed response is surfaced through session status and leaves
other exchanges unchanged. The partner can repeat it until resolved.

The app keeps incoming Files and outgoing receipts at the mounted label.
The currently approved replay is passed for five minutes, and a repeated
presentation can recover the existing acceptance. Inbox observations carry
no deletion signal. This mode transfers unstructured files up to 24 KiB
and admits signed receipts up to 16 KiB.

[OFTP2 protocol and receipt formats](https://www.rfc-editor.org/rfc/rfc5024.html)


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