# Wire Reference

The Twisp wire processor sends and receives Fedwire Funds Service wires in ISO 20022.

## Wire Resources

See each of the sub-pages in this reference for details about the corresponding wire resource. Each resource is accessible via the [GraphQL API](https://www.twisp.com/docs/reference/graphql.md).

- [Configuration](https://www.twisp.com/docs/reference/wire/configuration.md): Wire configuration defines accounts, the Fedwire endpoint, IMAD sequence and decisioning.
- [File Operations](https://www.twisp.com/docs/reference/wire/file-operations.md): Process inbound Fedwire files and generate archives of outbound ones.
- [Outbound Wires](https://www.twisp.com/docs/reference/wire/outbound.md): Send a wire with the WIRE_OUTBOUND workflow and settle it on the Fed's reply.
- [Inbound Wires](https://www.twisp.com/docs/reference/wire/inbound.md): Decide and post wires received from the Fed, and return them.

## Key Concepts

- **One message per file.** Each Fedwire message is one ISO 20022 envelope in one file. You process inbound files one at a time. Outbound files arrive together in one tar.gz archive per generation.
- **Configuration** connects your accounts, routing number, the sponsor bank's Fedwire endpoint and the inbound decisioning mode.
- **`WIRE_OUTBOUND`** sends a wire: `CREATE` → `SUBMIT` → `SETTLE`, or `REJECT` / `CANCEL`, then optionally `RETURN`.
- **`WIRE_INBOUND`** receives a wire: `PENDING` or `SETTLE`, then optionally `RETURN`.
- **Replies settle outbound wires.** An outbound wire settles only when the Fed's pacs.002 accepts it. Until then the funds are held in the pending layer.
- **UETR** is the end-to-end id of a wire. Replies match their wire by UETR, and by message id (IMAD) when they carry no UETR.
- **IMAD** is the message id Twisp assigns to each message it sends: the Fedwire business day, the sponsor's 8-character endpoint id and a 6-digit sequence.

## Messages

| Message                                         | Direction | Twisp's action                                                          |
| ----------------------------------------------- | --------- | ----------------------------------------------------------------------- |
| pacs.008 customer credit transfer               | outbound  | Generated for each `WIRE_OUTBOUND` wire                                 |
| pacs.008 customer credit transfer               | inbound   | Decided and posted with `WIRE_INBOUND`                                  |
| pacs.009 FI credit transfer                     | inbound   | Decided and posted with `WIRE_INBOUND`                                  |
| pacs.002 payment status                         | inbound   | `ACSC`/`ACCC` settles the outbound wire; `RJCT` rejects it              |
| admi.002 message reject                         | inbound   | Rejects the outbound wire it names                                      |
| pacs.004 payment return                         | inbound   | Returns the outbound wire; with no match, credits the exception account |
| pacs.004 payment return                         | outbound  | Generated for each returned inbound wire                                |
| Other messages, such as camt.056 and broadcasts | inbound   | Recorded with no action                                                 |

## Transaction Codes

Every wire transaction code posts two entries: the customer account (`accountId`) against the settlement account.

| Code                                | Layer   | Customer account | Used by                                                   |
| ----------------------------------- | ------- | ---------------- | --------------------------------------------------------- |
| `SYS_WIRE_OUTBOUND_PENDING_DR`      | PENDING | Debit            | Outbound `CREATE`                                         |
| `SYS_WIRE_OUTBOUND_PENDING_VOID_CR` | PENDING | Credit           | Outbound `SETTLE`, `REJECT`, `CANCEL` (releases the hold) |
| `SYS_WIRE_OUTBOUND_SETTLE_DR`       | SETTLED | Debit            | Outbound `SETTLE`                                         |
| `SYS_WIRE_OUTBOUND_RETURN_CR`       | SETTLED | Credit           | Outbound `RETURN`                                         |
| `SYS_WIRE_INBOUND_PENDING_CR`       | PENDING | Credit           | Inbound `PENDING`                                         |
| `SYS_WIRE_INBOUND_PENDING_VOID_DR`  | PENDING | Debit            | Inbound `SETTLE` or `RETURN` from `PENDING`               |
| `SYS_WIRE_INBOUND_SETTLE_CR`        | SETTLED | Credit           | Inbound `SETTLE`                                          |
| `SYS_WIRE_INBOUND_RETURN_DR`        | SETTLED | Debit            | Inbound `RETURN` from `SETTLE`                            |

These are system transaction codes. The wire workflows post them; you do not post them directly.
