# IBAN validation

> POST /iban checks an IBAN against ISO 13616 and the SWIFT IBAN Registry: check digits, length, account format, bank and branch codes, SEPA membership.

`POST https://api.qelka.com/v1/iban`

Check an IBAN before you store it or pay to it: you learn whether it is valid, which check failed if it is not, and its country, bank code, branch code and SEPA membership. Each answer costs 1 credit, valid or not; errors and test keys are never billed.

## Request

Send the IBAN the way your user typed it. The check runs on our servers from the SWIFT IBAN Registry: the IBAN is never sent to a bank or to any other third party, the result is never cached, and the request log keeps only the first two and last two characters of the IBAN.

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `iban` | string | Yes | none | The IBAN, 1 to 64 characters, in electronic (`GB29NWBK60161331926819`) or print (`GB29 NWBK 6016 1331 9268 19`) format. Spaces, hyphens, lower case and a leading `IBAN` label are accepted. |
| `fresh` | boolean | No | `false` | Accepted so that every endpoint takes the same fields. IBAN results are never cached, so it changes nothing here. |

```bash title="cURL"
curl https://api.qelka.com/v1/iban \
  --max-time 10 \
  -H "Authorization: Bearer $QELKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"iban": "GB29 NWBK 6016 1331 9268 19"}'
```
```javascript title="Node.js"
const response = await fetch('https://api.qelka.com/v1/iban', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.QELKA_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ iban: 'GB29 NWBK 6016 1331 9268 19' }),
  signal: AbortSignal.timeout(10_000),
})
const result = await response.json()
console.log(result)
```
```python title="Python"
import os

import requests

api_key = os.environ["QELKA_API_KEY"]
response = requests.post(
    "https://api.qelka.com/v1/iban",
    headers={"Authorization": f"Bearer {api_key}"},
    json={"iban": "GB29 NWBK 6016 1331 9268 19"},
    timeout=10,
)
result = response.json()
print(result)
```
```php title="PHP"
<?php
$ch = curl_init('https://api.qelka.com/v1/iban');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('QELKA_API_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode(['iban' => 'GB29 NWBK 6016 1331 9268 19']),
    CURLOPT_TIMEOUT => 10,
]);
$result = json_decode(curl_exec($ch), true);
print_r($result);
```
```go title="Go"
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
	"os"
	"time"
)

func main() {
	payload, _ := json.Marshal(map[string]any{"iban": "GB29 NWBK 6016 1331 9268 19"})
	request, _ := http.NewRequest(http.MethodPost, "https://api.qelka.com/v1/iban", bytes.NewReader(payload))
	request.Header.Set("Authorization", "Bearer "+os.Getenv("QELKA_API_KEY"))
	request.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: 10 * time.Second}
	response, err := client.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	var result map[string]any
	if err := json.NewDecoder(response.Body).Decode(&result); err != nil {
		panic(err)
	}
	fmt.Println(result)
}
```
```ruby title="Ruby"
require 'json'
require 'net/http'

uri = URI('https://api.qelka.com/v1/iban')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = "Bearer #{ENV.fetch('QELKA_API_KEY')}"
request['Content-Type'] = 'application/json'
request.body = JSON.generate({ iban: 'GB29 NWBK 6016 1331 9268 19' })

response = Net::HTTP.start(uri.host, uri.port, use_ssl: true, read_timeout: 10) do |http|
  http.request(request)
end
result = JSON.parse(response.body)
puts result
```

## Response

Every IBAN gets a `200`, valid or not. Read `valid` first, then `reason` when it is `false`.

| Field | Type | Description |
|---|---|---|
| `id` | string | Identifier of this lookup: `lkp_` followed by 26 characters. |
| `object` | string | Always `iban`. |
| `input` | string | The `iban` you sent, without surrounding spaces. |
| `valid` | boolean | `true` when every check passed. |
| `status` | string | `valid` or `invalid`. |
| `reason` | string or null | The first check that failed: `invalid_characters`, `invalid_format`, `unsupported_country`, `invalid_length`, `invalid_bban` or `invalid_checksum`. `null` when the IBAN is valid. |
| `iban` | string or null | The IBAN in electronic format. `null` when the input holds characters an IBAN cannot have. |
| `formats` | object or null | The two ways to write the IBAN. `null` when `iban` is. |
| `formats.electronic` | string | Upper case, no spaces: the form to store and to send to payment systems. |
| `formats.print` | string | Groups of four characters separated by spaces: the form to show people. |
| `country` | object or null | The country of the IBAN. `null` when the IBAN does not start with a country of the registry. |
| `country.code` | string | ISO 3166-1 alpha-2 code, such as `GB`. |
| `country.name` | string | English short name, such as `United Kingdom`. |
| `check_digits` | string or null | The two digits after the country code. |
| `bban` | string or null | The Basic Bank Account Number: the national account identifier that follows the check digits. |
| `bank_code` | string or null | Bank identifier, read from the BBAN at the position the registry defines for the country. `null` when the length is wrong. |
| `branch_code` | string or null | Branch identifier, for countries whose BBAN has one: the sort code in the United Kingdom and Ireland, the code guichet in France, the CAB in Italy. `null` elsewhere. |
| `sepa` | boolean or null | `true` when the country is in the geographical scope of the SEPA (Single Euro Payments Area) payment schemes. |
| `expected_length` | integer or null | The IBAN length the registry defines for the country. |
| `credits_used` | integer | Credits debited for this call: 1 with a live key, `0` with a test key. |
| `cached` | boolean | Always `false`: IBAN results are computed on every call. |

```json title="Response"
{
  "id": "lkp_01M85QF1P2X7R07K1R4CBTZ68G",
  "object": "iban",
  "input": "GB29 NWBK 6016 1331 9268 19",
  "valid": true,
  "status": "valid",
  "reason": null,
  "iban": "GB29NWBK60161331926819",
  "formats": {
    "electronic": "GB29NWBK60161331926819",
    "print": "GB29 NWBK 6016 1331 9268 19"
  },
  "country": { "code": "GB", "name": "United Kingdom" },
  "check_digits": "29",
  "bban": "NWBK60161331926819",
  "bank_code": "NWBK",
  "branch_code": "601613",
  "sepa": true,
  "expected_length": 22,
  "credits_used": 1,
  "cached": false
}
```

## Act on the reason

| `reason` | What it means | What to do |
|---|---|---|
| `null` | Every check passed. | Store `iban` and show `formats.print` to people. |
| `invalid_characters` | The input holds characters other than letters, digits, spaces and hyphens, such as dots or slashes. | Ask for the IBAN again. |
| `invalid_format` | It does not start with a two-letter country code and two check digits. | Ask for the IBAN again: it may be a national account number. |
| `unsupported_country` | The two letters are not a country of the IBAN Registry. The United States, Canada and Australia, for example, do not use IBANs. | Ask for the account details that country uses instead. |
| `invalid_length` | The length differs from the one registered for the country. | Show `expected_length`: a character is missing or extra. |
| `invalid_bban` | The account part does not follow the country's structure, such as a letter where a digit belongs. | Ask the user to check the account part. |
| `invalid_checksum` | The check digits do not match the rest of the IBAN. | Ask the user to check each character: it is usually a typo. |

A valid IBAN is well formed and its check digits are right. That does not prove the account exists, is open or belongs to the person who gave it: only the bank can confirm that, for instance through a first payment.

## How the IBAN is checked

The checks run in this order, and the first one that fails gives the `reason`:

1. Spaces, hyphens and a leading `IBAN` label are removed, and only letters and digits may remain.
2. The IBAN starts with two letters and two digits.
3. The two letters are a country of the IBAN Registry.
4. The length is the one registered for that country, from 15 characters in Norway to 33 in Russia.
5. The BBAN follows the country's structure, such as `4!a6!n8!n` in the United Kingdom: four letters, then six digits, then eight digits.
6. The check digits are between 02 and 98, and the whole IBAN passes ISO 7064 MOD 97-10: with the first four characters moved to the end and letters turned into numbers (A = 10 to Z = 35), it leaves a remainder of 1 when divided by 97.

The check digits catch any single mistyped character and any swap of two adjacent characters.

## Where the formats come from

Country lengths, BBAN structures and bank and branch positions come from release 101 of the IBAN Registry that SWIFT publishes as the registration authority of ISO 13616, 89 countries in all. SEPA membership follows the European Payments Council list of SEPA scheme countries (EPC409-09, version 8.0 of 24 December 2025). Both are listed on the [data sources page](https://qelka.com/data-sources).

## Examples

### Catch a mistyped IBAN

One wrong check digit makes the IBAN invalid, and the call is billed because the check ran.

```bash title="cURL"
curl https://api.qelka.com/v1/iban \
  --max-time 10 \
  -H "Authorization: Bearer $QELKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"iban": "GB28 NWBK 6016 1331 9268 19"}'
```
```javascript title="Node.js"
const response = await fetch('https://api.qelka.com/v1/iban', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.QELKA_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ iban: 'GB28 NWBK 6016 1331 9268 19' }),
  signal: AbortSignal.timeout(10_000),
})
const result = await response.json()
console.log(result)
```
```python title="Python"
import os

import requests

api_key = os.environ["QELKA_API_KEY"]
response = requests.post(
    "https://api.qelka.com/v1/iban",
    headers={"Authorization": f"Bearer {api_key}"},
    json={"iban": "GB28 NWBK 6016 1331 9268 19"},
    timeout=10,
)
result = response.json()
print(result)
```

```json title="Response"
{
  "id": "lkp_01M87149C0EX8KFM7FH9H0KX9M",
  "object": "iban",
  "input": "GB28 NWBK 6016 1331 9268 19",
  "valid": false,
  "status": "invalid",
  "reason": "invalid_checksum",
  "iban": "GB28NWBK60161331926819",
  "formats": {
    "electronic": "GB28NWBK60161331926819",
    "print": "GB28 NWBK 6016 1331 9268 19"
  },
  "country": { "code": "GB", "name": "United Kingdom" },
  "check_digits": "28",
  "bban": "NWBK60161331926819",
  "bank_code": "NWBK",
  "branch_code": "601613",
  "sepa": true,
  "expected_length": 22,
  "credits_used": 1,
  "cached": false
}
```

### Reject a country that does not use IBANs

The United States has no IBAN, so the country check fails: `country`, `sepa` and `expected_length` are `null`.

```bash title="cURL"
curl https://api.qelka.com/v1/iban \
  --max-time 10 \
  -H "Authorization: Bearer $QELKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"iban": "US12 3456 7890"}'
```
```javascript title="Node.js"
const response = await fetch('https://api.qelka.com/v1/iban', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.QELKA_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ iban: 'US12 3456 7890' }),
  signal: AbortSignal.timeout(10_000),
})
const result = await response.json()
console.log(result)
```
```python title="Python"
import os

import requests

api_key = os.environ["QELKA_API_KEY"]
response = requests.post(
    "https://api.qelka.com/v1/iban",
    headers={"Authorization": f"Bearer {api_key}"},
    json={"iban": "US12 3456 7890"},
    timeout=10,
)
result = response.json()
print(result)
```

```json title="Response"
{
  "id": "lkp_01M8714A99XVJM2TX9CBQDX5KV",
  "object": "iban",
  "input": "US12 3456 7890",
  "valid": false,
  "status": "invalid",
  "reason": "unsupported_country",
  "iban": "US1234567890",
  "formats": {
    "electronic": "US1234567890",
    "print": "US12 3456 7890"
  },
  "country": null,
  "check_digits": "12",
  "bban": "34567890",
  "bank_code": null,
  "branch_code": null,
  "sepa": null,
  "expected_length": null,
  "credits_used": 1,
  "cached": false
}
```

## Errors

| Status | Type | When |
|---|---|---|
| 400 | [invalid_request](https://qelka.com/docs/errors#invalid_request) | `iban` is missing, empty or longer than 64 characters, the body is not a JSON object, or it has a field the request table does not list |
| 401 | [invalid_api_key](https://qelka.com/docs/errors#invalid_api_key) | The key is missing, unknown or revoked |
| 402 | [insufficient_credits](https://qelka.com/docs/errors#insufficient_credits) | Your balance is less than 1 credit (live keys only) |
| 403 | [forbidden](https://qelka.com/docs/errors#forbidden) | The key is restricted to other endpoints |
| 405 | [invalid_request](https://qelka.com/docs/errors#invalid_request) | The method is not `POST` |
| 429 | [rate_limited](https://qelka.com/docs/errors#rate_limited) | Too many requests: wait `Retry-After` seconds |
| 500 | [internal_error](https://qelka.com/docs/errors#internal_error) | Unexpected error on our side: retry with backoff |

No error is billed. An invalid IBAN is not an error: it is a `200` with `valid: false`. Test keys run the same checks and debit nothing.

## Related

- [IBAN validation API](https://qelka.com/products/iban-validation)
- Free tool: [IBAN validator](https://qelka.com/tools/iban-validator)
- [Batch](https://qelka.com/docs/api-reference/batch): up to 100 IBANs in one call, each item with `type: "iban"`
- [Bulk](https://qelka.com/docs/api-reference/bulk): a whole file of IBANs with `type=iban`
- [Errors](https://qelka.com/docs/errors), [Credits](https://qelka.com/docs/credits), [Test mode](https://qelka.com/docs/test-mode)
