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
- Check the format of your IBAN before using the
initiateCreditTransfers
mutation. - Get the bank information with the API if your bank details PDF isn't readily available.
Guide and query​
- Call the
ibanValidation
query. - Add an IBAN. You can test IBANs from any issuer and any country Swan covers.
- Add both the
ValidIban
andInvalidIban
unions. - 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:
- The IBAN is valid (line 4).
- The issuer is Swan (line 10).
- 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.
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.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"
}
}
}