SWIFT Country Codes API

Country code lookup and validation

OpenAPI Specification

swift-country-codes-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: SWIFT SwiftRef Account Numbers Country Codes API
  description: The SWIFT SwiftRef API provides automated real-time lookup and validation of payments reference data. Supports validation and retrieval of BICs, IBANs, LEIs, National IDs, country codes, currency codes, and account numbers. Enables financial institutions, corporates, and PSPs to achieve greater straight-through processing rates by validating identifiers before payment execution. Data is updated daily from authoritative sources.
  version: 2.0.0
  contact:
    name: SWIFT Developer Support
    email: developer-support@swift.com
    url: https://developer.swift.com
  termsOfService: https://developer.swift.com/terms
servers:
- url: https://api.swift.com/swiftrefdata
  description: SWIFT SwiftRef Production API
- url: https://sandbox.swift.com/swiftrefdata
  description: SWIFT SwiftRef Sandbox
security:
- OAuth2: []
tags:
- name: Country Codes
  description: Country code lookup and validation
paths:
  /v2/country_codes/{country_code}:
    get:
      operationId: getCountryCode
      summary: Get Country Code Details
      description: Returns details for an ISO 3166-1 alpha-2 country code including country name and IBAN structure.
      tags:
      - Country Codes
      parameters:
      - $ref: '#/components/parameters/countryCode'
      responses:
        '200':
          description: Country code details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CountryCodeDetails'
        '404':
          $ref: '#/components/responses/NotFound'
  /v2/country_codes/{country_code}/validity:
    get:
      operationId: validateCountryCode
      summary: Validate Country Code
      description: Checks whether a country code is a valid ISO 3166-1 alpha-2 code.
      tags:
      - Country Codes
      parameters:
      - $ref: '#/components/parameters/countryCode'
      responses:
        '200':
          description: Country code validity result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidityResult'
components:
  responses:
    NotFound:
      description: Identifier not found in reference data
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
              message:
                type: string
  schemas:
    CountryCodeDetails:
      type: object
      properties:
        countryCode:
          type: string
          description: ISO 3166-1 alpha-2 country code
        countryName:
          type: string
          description: Country name
        ibanLength:
          type: integer
          description: IBAN length for this country
        ibanStructure:
          type: string
          description: IBAN structure definition
    ValidityResult:
      type: object
      properties:
        valid:
          type: boolean
          description: Whether the identifier is valid
        errorCode:
          type: string
          description: Error code if invalid
        errorDescription:
          type: string
          description: Human-readable description of validation failure
  parameters:
    countryCode:
      name: country_code
      in: path
      required: true
      schema:
        type: string
        pattern: ^[A-Z]{2}$
      description: ISO 3166-1 alpha-2 country code
      example: DE
  securitySchemes:
    OAuth2:
      type: oauth2
      flows:
        password:
          tokenUrl: https://api.swift.com/oauth2/v1/token
          scopes:
            urn:swiftref:external: External customer access to SwiftRef data
            urn:swiftref:internal: Internal payment validation access
externalDocs:
  description: SWIFT SwiftRef API Documentation
  url: https://developer.swift.com/apis/swiftref-api