There are two types of application headers: Input and Output (from the network perspective). Both are fixed-length and continuous with no field delimiters.
Input
Used in outgoing messages, when a message is input to the SWIFT network.
It includes the following fields:
- I = Input
- Message type
- Receiver's address with X in position 9/ It is padded with Xs if no branch is required. Example: BANKDEFFXXXX
- The message priority (S = System, N = Normal, U = Urgent)
- Delivery monitoring (1 = Non delivery warning, 2 = Delivery notification, 3 = Both valid
- Obsolescence period. It specifies when a non-delivery notification (003 - 15 minutes, 020 - 100 minutes)
Output
Used in incoming messages, when a message is output from the SWIFT network.
It includes the following fields:
- O = Output
- Message type
- Input time with respect to the sender
- The Message Input Reference (MIR), including input date, with Sender's address. This is sometimes confusing because it is an output block with an input reference. The important thing to understand here is that the MIR information is related to the original sender of the message that has been received.
- Output date and time with respect to Receiver
- Message priority
You can find more information regarding the MT structure here:
https://www.prowidesoftware.com/resources/SWIFT
BTW, I'm one of the authors of the Prowide open source library for SWIFT. You might consider using this library instead of writing your own parser from scratch.