Skip to main content

Validate an IBAN

Check the format of your IBAN before using it to perform operations with Swan's API.

The ibanValidation query confirms the following formatting:

  • IBAN has five or more characters
  • Third and fourth characters of the IBAN are numbers
  • Country code is valid
  • IBAN length matches the length expected for the country code
  • Checksum or check digits are correct
possible use cases
  1. Check the format of your IBAN before using the initiateCreditTransfers mutation.
  2. Get the bank information with the API if your bank details PDF isn't readily available.

Guide and query​

  1. Call the ibanValidation query.
  2. Add an IBAN. You can test IBANs from any issuer and any country Swan covers.
  3. Add both the ValidIban and InvalidIban unions.
  4. Add anything other information you'd like to review.

🔎 Open the query in API Explorer

query CheckIbanFormat {
ibanValidation(input: { iban: "FR7699999001001510219788187" }) {
... on ValidIban {
__typename
accountNumber
checksum
iban
bank {
branch
name
}
reachability {
sepaCreditTransfer
sepaCreditTransferInst
sepaDirectDebitB2b
sepaDirectDebitCore
}
}
... on InvalidIban {
__typename
message
code
iban
}
}
}

Valid IBAN example​

All of this data is from a Swan Sandbox account and can't be used in real life.

Payload responses for valid IBANs provide valuable information if included in the query. In fact, it can return everything in a valid IBAN's anatomy; you can review local IBANs supported by Swan.

This payload shows that:

  1. The IBAN is valid (line 4).
  2. The issuer is Swan (line 10).
  3. The IBAN can be used for all SEPA transactions (lines 13-16).
Valid example payload
{
"data": {
"ibanValidation": {
"__typename": "ValidIban",
"accountNumber": "1510219788187",
"checksum": "76",
"iban": "FR7699999001001510219788187",
"bank": {
"branch": "00",
"name": "Swan (FR)"
},
"reachability": {
"sepaCreditTransfer": true,
"sepaCreditTransferInst": true,
"sepaDirectDebitB2b": true,
"sepaDirectDebitCore": true
}
}
}
}

Invalid IBAN example​

There are numerous responses for invalid IBANs. Here are two examples.

  1. IBAN FR76182060016265: The payload shows that the IBAN is invalid because it's too short. Review the anatomy of each local IBAN supported by Swan.
  2. IBAN FR7817569000305414384277J07: The payload shows that the IBAN is invalid because the bank referenced in the IBAN couldn't be found.
Invalid example payload
# Response 1 for IBAN FR76182060016265
{
"data": {
"ibanValidation": {
"__typename": "InvalidIban",
"message": "IBAN is invalid",
"code": "InvalidLength"
}
}
}

# Response 2 for IBAN FR7817569000305414384277J07
{
"data": {
"ibanValidation": {
"__typename": "InvalidIban",
"message": "Bank referenced in IBAN could not be found",
"code": "InvalidBank"
}
}
}