# Configuration

Reference for wire configuration within the Twisp wire processor

## The Basics

A wire configuration holds everything the wire processor needs to send and receive wires: the accounts it posts to, the identifiers it writes into Fedwire messages, and how inbound wires are decided. Every file and workflow execution names the configuration it uses.

Create one with [`Mutation.wire.createConfiguration()`](https://www.twisp.com/docs/reference/graphql/mutations.md#wire.create-configuration):

```graphql
mutation CreateWireConfiguration {
  wire {
    createConfiguration(
      input: {
        configId: "5d1c6a0e-8b7f-4e2a-9c3d-2e1f0a9b8c7d"
        endpointId: "9a4f0f1e-2f5c-4a2b-8d3e-1b2c3d4e5f63"
        journalId: "00000000-0000-0000-0000-000000000000"
        settlementAccountId: "9a4f0f1e-2f5c-4a2b-8d3e-1b2c3d4e5f60"
        suspenseAccountId: "9a4f0f1e-2f5c-4a2b-8d3e-1b2c3d4e5f61"
        exceptionAccountId: "9a4f0f1e-2f5c-4a2b-8d3e-1b2c3d4e5f62"
        routingNumber: "231380104"
        fedwireEndpointId: "B1QDRCQR"
        msgIdSequence: { minSequence: 500000, maxSequence: 599999 }
        businessService: TEST
        institutionName: "Sponsor Bank"
        chargeBearer: SHAR
      }
    ) {
      configId
      decisioning {
        mode
      }
      version
    }
  }
}
```

Read it with [`Query.wire.configuration()`](https://www.twisp.com/docs/reference/graphql/queries.md#wire.configuration), list all with [`Query.wire.configurations()`](https://www.twisp.com/docs/reference/graphql/queries.md#wire.configurations), and change it with [`Mutation.wire.updateConfiguration()`](https://www.twisp.com/docs/reference/graphql/mutations.md#wire.update-configuration). Fields left out of an update keep their value.

## Fields

| Field                 | Required       | Description                                                                                                                                                              |
| --------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `configId`            | Yes            | Unique identifier of the configuration.                                                                                                                                  |
| `journalId`           | Yes            | Journal that wire transactions post to.                                                                                                                                  |
| `settlementAccountId` | Yes            | The wire settlement account: the other side of every wire posting.                                                                                                       |
| `suspenseAccountId`   | Yes            | Account an inbound wire is credited to before it is returned.                                                                                                            |
| `exceptionAccountId`  | Yes            | Account a returned wire that matches no outbound wire is credited to.                                                                                                    |
| `routingNumber`       | Yes            | Your ABA routing number: the debtor agent of wires you send. It must pass the ABA check digit.                                                                           |
| `fedwireEndpointId`   | Yes            | The sponsor bank's 8-character Fedwire endpoint id, uppercase letters and digits. It is the input source of every IMAD Twisp assigns.                                    |
| `businessService`     | Yes            | `TEST` or `PROD`, written into every message Twisp builds.                                                                                                               |
| `msgIdSequence`       | No             | IMAD sequence numbers reserved for Twisp, within 1–999999. Defaults to the full range.                                                                                   |
| `senderId`            | No             | Connection party id written as the sender (`AppHdr/Fr`) of every message Twisp builds, 9 uppercase letters or digits. Defaults to `routingNumber`.                       |
| `institutionName`     | No             | Name of the institution at `routingNumber`, written on the debtor agent of outbound wires. Up to 140 characters.                                                         |
| `institutionAddress`  | No             | Address of the institution at `routingNumber`, written on the debtor agent of outbound wires.                                                                            |
| `chargeBearer`        | No             | `SLEV`, `SHAR`, `CRED` or `DEBT`: who bears the charges of outbound wires. Defaults to `SLEV`.                                                                           |
| `accountScheme`       | No             | Scheme name written on the debtor and creditor account numbers of outbound wires (`SchmeNm/Prtry`), such as `USACCOUNT`. Up to 35 characters. Left out, none is written. |
| `decisioning`         | No             | How inbound wires are decided. Defaults to `WEBHOOK`.                                                                                                                    |
| `endpointId`          | With `WEBHOOK` | Endpoint for wire webhooks. It must be an `ACH_PROCESSOR` endpoint.                                                                                                      |
| `pendingAccountId`    | With `PENDING` | Account inbound wires are credited to as `PENDING`. It must differ from the settlement, suspense and exception accounts.                                                 |
| `description`         | No             | Free text.                                                                                                                                                               |

## Outbound Message Fields

Every outbound wire takes these elements from the configuration:

| Element                                        | From                                       |
| ---------------------------------------------- | ------------------------------------------ |
| `AppHdr/Fr`                                    | `senderId`, or `routingNumber` without one |
| `AppHdr/BizSvc`                                | `businessService`                          |
| `InstgAgt`, `DbtrAgt` routing number           | `routingNumber`                            |
| `DbtrAgt/Nm`, `DbtrAgt/PstlAdr`                | `institutionName`, `institutionAddress`    |
| `ChrgBr`                                       | `chargeBearer`                             |
| `DbtrAcct/.../SchmeNm`, `CdtrAcct/.../SchmeNm` | `accountScheme`                            |

Set `senderId` when the sponsor bank sends under a connection party id other than your routing number. Set the institution, charge bearer and account scheme to match the messages your sponsor bank expects.

## Message Ids (IMAD)

Every message Twisp sends gets an IMAD as its `MsgId`:

```
20261009  B1QDRCQR  500001
└ cycle   └ endpoint └ sequence
```

- The **cycle date** is the Fedwire business day. A business day opens at 9:00 p.m. ET on the previous calendar day, so a message generated at 10:00 p.m. ET on October 9 carries October 10.
- The **endpoint** is `fedwireEndpointId`.
- The **sequence** starts at `msgIdSequence.minSequence` on each business day and increases by one per message. `generateFile` fails if a generation would pass `maxSequence`.

Reserve a range with `msgIdSequence` when other systems send messages under the same endpoint, so the sequences never collide.

## Decisioning

The `decisioning` field is the same as on ACH configurations. It sets how an inbound wire is decided:

| Mode             | How a wire is decided                                                                        | Requires           |
| ---------------- | -------------------------------------------------------------------------------------------- | ------------------ |
| `WEBHOOK`        | Your endpoint answers the wire's create webhook                                              | `endpointId`       |
| `PENDING`        | The wire is credited to the pending account as `PENDING`, awaiting your `SETTLE` or `RETURN` | `pendingAccountId` |
| `ACCOUNT_LOOKUP` | Twisp finds the account by `externalId` and settles the wire to it                           | `accountLookup`    |

In `ACCOUNT_LOOKUP` mode, the `src` expression reads the inbound wire as `creditTransfer`, for example:

```graphql
decisioning: {
  mode: ACCOUNT_LOOKUP
  accountLookup: {
    externalId: { runtime: CEL, src: "'dda:' + creditTransfer.creditor.account" }
  }
}
```

See [Inbound Wires](https://www.twisp.com/docs/reference/wire/inbound.md#decisioning) for the `creditTransfer` fields and what each mode does.

## Validation

Creating or updating a configuration fails with `BAD_REQUEST` when:

- `routingNumber` is not a valid ABA routing number
- `fedwireEndpointId` is not 8 uppercase letters or digits
- `msgIdSequence` lies outside 1–999999, or its minimum is above its maximum
- `businessService` is missing
- `senderId` is set and is not 9 uppercase letters or digits
- `institutionName` is over 140 characters, or `institutionAddress` does not fit a Fedwire postal address
- `accountScheme` is over 35 characters
- the decisioning mode lacks what it requires, or `accountLookup` is set in another mode
- an account lookup `src` does not compile
- the pending account is the settlement, suspense or exception account

It fails with `NOT_FOUND` when a referenced endpoint, account or journal does not exist.
