Anatomy of a SWIFT message

SWIFT, standing for Society for Worldwide Interbank Financial Telecommunications, is a society founded by major financial institutions to establish a common system for "telecommunication, transmission and routing of private, confidential and proprietary financial messages" between banks. SWIFT is a registration authority for several ISO standards including BIC codes, MIC codes, IBAN and schemes for messages — the text based ISO 15022 and the newer XML based ISO 20022.

This article shows how an ISO 15022 message looks like and decomposes it to its particular parts. The description of the structure should be sufficient for building a SWIFT message parser. Links to the full specification are provided if available. Some parts that are harder to find online are described in more detail.

An example of a SWIFT message:

{1:F01TESTBIC12XXX0360105154}{2:O5641057130214TESTBIC34XXX26264938281302141757N}{3:{103:CAD}{108:2RDRQDHM3WO}}{4:
:16R:GENL
:20C::CORP//1234567890123456
:20C::SEME//9876543210987654
:23G:NEWM
:22F::CAEV//INTR
:22F::CAMV//MAND
:98C::PREP//20220202105733
:25D::PROC//ENTL
:16S:GENL
:16R:USECU
:35B:ISIN CH0101010101
/XS/232323232
FINANCIAL INSTRUMENT ACME
:16R:FIA
:22F::MICO//A007
:16S:FIA
:16R:ACCTINFO
:97A::SAFE//99999
:94F::SAFE//NCSD/TESTBIC0ABC
:93B::ELIG//FAMT/500000,
:93B::SETT//FAMT/500000,
:16S:ACCTINFO
:16S:USECU
:16R:CADETL
:98A::ANOU//20220113
:98A::RDTE//20220113
:69A::INPE//20220214/20220214
:99A::DAAC//360
:92K::INTR//UKWN
:22F::ADDB//CAPA
:16S:CADETL
:16R:CAOPTN
:13A::CAON//001
:22F::CAOP//CASH
:11A::OPTN//USD
:17B::DFLT//Y
:16R:CASHMOVE
:22H::CRDB//CRED
:22H::CONT//ACTU
:97A::CASH//89898
:19B::ENTL//USD3333,
:19B::TXFR//USD3333,
:19B::NETT//USD3333,
:98A::PAYD//20220214
:98A::VALU//20220214
:98A::EARL//20220214
:92A::INTP//0,75
:92A::TAXR//0,
:16S:CASHMOVE
:16S:CAOPTN
:16R:ADDINFO
:70E::ADTX//PAYMENT UPON RECEIPT OF FUNDS - 
TIMELY PAYMENT EXPECTED
:16S:ADDINFO
-}{5:{CHK:C77F8E009597}}

Message blocks

A message consists of blocks enclosed in curly braces. The first colon separates the block name and content. The block content can consist of sub-blocks.

Detailed specification of the structure and content of SWIFT message blocks can be found in the SWIFT User Handbook, chapter FIN Service Description (accessible only to SWIFT subscribers). Publicly accessible documentation can be found at IBM Knowledge Center and MSDN.

  1. Basic header block containing information about the message source.
    The Basic header block {1:F01TESTBIC12XXX0360105154} contains five fixed-length fields:
    • F — Application ID
    • 01 — Service ID
    • TESTBIC12XXX — Logical terminal address of the message source
    • 0360 — Session number
    • 105154 — Sequence number
  2. Application header block with information about message type and destination of the message.
    The application header block can be either of type Input or Output. The output block {2:O5641057130214TESTBIC34XXX26264938281302141757N} contains a set of fixed-length fields:

    • O — Direction
    • 564 — Message type
    • 1057 — Input time
    • 130214 — Input date
    • TESTBIC34XXX — Logical terminal address of the message destination
    • 2626 — Session number
    • 493828 — Sequence number
    • 130214 — Output date
    • 1757 — Output time
    • N — Priority

    An input block has a different structure and consists of six fixed-length fields.

  3. Optional User header block contains sub-blocks with optional processing instructions.
    In {3:{103:CAD}{108:2RDRQDHM3WO}} the sub-block 103 specifies a Service identifier and 108 a Message user reference.
  4. Text block with the actual content of the message.
    The format of the text block is described below.
  5. User trailer block. The trailer consists of sub-blocks. In the example {5:{CHK:C77F8E009597}} it contains a Checksum.
  6. SWIFT network can append an additional System trailer block 'S'. For example {S:{SAC:}{COP:P}}.

MT message

The content of block 4 (Text block) is sometimes referred as MT Message. MT stands for message type — a three digit number found in block 2. The message type specifies the purpose and structure of the message. The specification of MT message from the category 5xx (Securities Markets) can be found on the ISO 15022 homepage. The complete set of MT types in form of XSD schemas is available for SWIFT subscribers in the MyStandards Base Libraries or as a free message pack for Microsoft BizTalk A4SWIFT accelerator.

The MT message consists of a sequence of fields. The fields are generally in format :<type><option>:content<crlf>:

  • the colons enclose the field tag
  • type is a two digit number that represents the logical type (amount, rate, date, narrative etc.)
  • optional option a letter that specifies the format (e.g. rate expressed as a fraction or as a decimal number)
  • the structure of content is dependent on the type and option. The content can be a single line or multiple lines. A field begins with a colon and ends with a line break (CRLF) followed either by semicolon (beginning of the next field) or hyphen (end of the MT message).

In the example above the field :19B::NETT//USD3333, represents an Amount (type 19) expressed as currency and amount (option B) with content :NETT//USD3333,. The 35B is an example of a multi-line field:

:35B:ISIN CH0101010101
/XS/232323232
FINANCIAL INSTRUMENT ACME  

The whitespace characters and line breaks are significant in the whole SWIFT message and cannot be used arbitrarily. There must not be any line breaks between message blocks, blank lines between fields or any leading or trailing spaces in the fields (unless they are part of the data, e.g. in Narrative fields). In a multi-line field the colon : and a hyphen - must never be used as the first character of second or subsequent lines (with the exception of special field 77E, see below).

The MT message is logically divided into sequences — fields between :16R:<name> and :16S:<name>. Sequences can be repeated and nested. The order and mandatoriness of the fields and sequences is strictly defined for every MT type by its schema.

Fields

As mentioned above, a field consists of type, option and content. The format of the content is determined by the type and option and is consistent across all MT types. The specification can be found on the ISO 15022 homepage as a component sequence and a list of subfields. For Rate 92F the specification is :4!c//3!a15d (Qualifier)(Currency Code)(Amount). The first part specifies the format — colon, exactly four characters followed by two slashes, exactly three characters and up to 15 digits (including a decimal comma). In parentheses are names of the subfields — the part before the slashes is Qualifier, the three letters are Currency code and the number is the Amount.

Components

The first part of the content format breaks the text into components. Each component has a length and type.

Field Length
nnmaximum length (at least one)
nn!fixed length
nn*nnmaximum number of lines times maximum line length
Field Type
nnumeric digits 0-9
aalphabetic capital letters A-Z, upper case only
xSWIFT X set
any character of the X permitted set (General FIN application set) upper case and lower case allowed:
A-Z a-z 0-9 / - ? : ( ) . , ’ + SPACE CrLf
ySWIFT Y set
any character of the Y permitted set (EDI service specific set), upper case only:
A-Z 0-9 SPACE . , - ( ) / = ’ + : ? ! ” % & * ; < >
zSWIFT Z set
all characters included in the X and Y sets, plus a couple of special characters:
A-Z a-z 0-9 . , - ( ) / = ’ + : ? @ # Cr Lf SPACE { ! ” % & * ; < > _
calpha-numeric capital letters (upper case), and digits only
eblank or space
dnumeric digits and decimal comma ,

Components or groups of components can be optional in which case they are enclosed in brackets. Optional groups can be nested (98E: :4!c//8!n6!n[,3n][/[N]2!n[2!n]]). Any other parts of the component sequence like colons, slashes, commas, newlines or letters are literals and must be present as specified.

Subfields

The second part of the content format maps the components to subfields and gives them names:

  • Components are taken from left to right and each one is assigned a name from the subfields list.
  • Literals are skipped with the exception of 'N' if it represents a Sign. Blank characters (field type 'e') are skipped.
  • If there are more components remaining for the last name, they are grouped and the subfield consists of all of them.
  • Every line in the format string is processed separately.
  • Sometimes the subfield list is empty. In that case use an arbitrary subfield name for all components.

Examples

  • [ISIN1!e12!c] (Identification of Security)
    The 'ISIN' and following space are skipped. Identification of security is the twelve subsequent characters.
  • :4!c//[N]15d (Qualifier)(Sign)(Index Points)
    The optional literal 'N' is the subfield Sign.
  • :4!c//4!c/4!a2!a2!c[3!c] (Qualifier)(Place Code)(Identifier Code)
    Everything after the last slash belongs to Identifier Code.
  • [/1!a][/34x] (Party Identifier) 4!a2!a2!c[3!c] (Identifier Code)
    Multi-line field; the whole first line is Party Identifier, the second line is Identifier Code.
  • 16c
    There is no list of subfields; the whole content can have an arbitrary name, e.g. Value.

Exceptions

There are a few exceptions to the rules described above:

  • Field 98E has an error in its format specification :4!c//8!n6!n[,3n][/[N]2!n[2!n]] (Qualifier)(Date)(Time)(Decimals)(UTC Indicator). Between (Decimals) and (UTC Indicator), there should be an additional subfield (UTC Sign).
  • Messages MTx98 Proprietary Message use the field 77E to embed another SWIFT message. This field has a proprietary format specification [n*78x] and may contain colon or hyphen as the first character of line in its text.