openapi: 3.0.3
info:
  title: Know Your Customer Match

  description: |

    This API provides the customer with the ability to compare the information it (Service Provider, SP) has for a particular mobile phone user with that on file (and verified) by the mobile phone user's Operator in their own KYC records, in order for the SP to confirm the accuracy of the information and provide a specific service to the mobile phone user.

    ## Relevant Definitions and concepts

    * **KYC**: stands for Know Your Customer and it is the process of a business verifying the identity of their clients and assessing their suitability, along with the potential risks of illegal intentions towards the business relationship.

    ## API Functionality

    This API allows API clients to verify the matching of a number of attributes related to a customer identity against the account data bound to their phone number.  The API is intended to be used in the following scenarios, for example:

    * To verify the user personal data during the digital registration of an account to a 3rd party service.

    * To prevent fraud, wrong or imprecise information, and/or facilitate the onboarding of a mobile phone user to a 3rd party service.

    The following figure is the generic high-level flows of this API.  

    <img width="848" alt="KYC_Match_flow" src="https://github.com/ToshiWakayama-KDDI/KnowYourCustomer-Toshi/assets/53090722/3f9acdcb-9f8d-4177-a586-7e426b8ac33d">

    Note:

    * Before calling this API, 3rd parties / enterprise customers who want to use this API should make contact with API provider/ MNO for use of this API.  As that will depend on each API provider / MNO's business process as well as GSMA Open Gateway standard process, it is out of scope of this API definition.

    * When calling this API, at the beginning, there should be required processes for Authentication / Authorisation / End User Consent capturing.  As those processes are defined as CAMARA commonality standards, they are out of scope of this API definition, however, use of the OpenID Connect (OIDC) is stated as security scheme.

    ## Resources and Operations overview

    The API provides the following endpoint:

    * An endpoint to verify the matching of a number of attributes related to a mobile phone user identity against the account data bound to their phone number.


  termsOfService: http://swagger.io/terms/
  contact:
    email: contact@spryfoxnetworks.com
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html

  version: 0.1.1


servers:
  - url: 'https://labs-api.spryfoxnetworks.com/qpcloud-monet-swagger/kyc-match/v0'
    variables:
      apiRoot:
        default: http://localhost:9091
        description: API root
      basePath:
        default: kyc-match/v0
        description: Base path for the KYC-Match API

tags:
  - name: Match

    description: Operations to match a customer identity against the account data bound to their phone number.

paths:
  /match:
    post:
      tags:
        - Match
      summary: Matching a customer identity by checking a set of attributes related against the account data bound to their phone number.

      operationId: KYC_Match

      security:
        - openId:
          - know-your-customer:match


      parameters:
        - $ref: '#/components/parameters/x-correlator'
        
      requestBody:
        required: true
        content:
          application/json:

            schema:
              $ref: '#/components/schemas/KYC_MatchRequestBody'
            examples:
              KYC_MatchRequestBodyExample:
                value:
                  phoneNumber: '+34629255833'
                  idDocument: 66666666q
                  name: Federica Sanchez Arjona
                  giventName: Federica
                  familyName: Sanchez Arjona
                  nameKanaHankaku: federica
                  nameKanaZenkaku: Ｆｅｄｅｒｉｃａ
                  middleNames: Sanchez
                  familyNameAtBirth: YYYY
                  address: Tokyo-to Chiyoda-ku Iidabashi 3-10-10
                  streetName: Nicolas Salmeron
                  streetNumber: 4
                  postalCode: 1028460
                  region: Tokyo
                  locality: ZZZZ
                  country: JP
                  houseNumberExtension: VVVV
                  birthdate: '1978-08-22'
                  email: abc@example.com
                  gender: male

      responses:
        '200':
          description: OK
          headers:
            x-correlator:
              $ref: '#/components/headers/x-correlator'

          content:
            application/json:

              schema:
                $ref: '#/components/schemas/KYC_MatchResponse'
              examples:
                KYC_Match200Example:
                  value:
                    idDocumentMatch: 'true'
                    nameMatch: 'true'
                    giventNameMatch: 'not_available'
                    familyNameMatch: 'not_available'
                    nameKanaHankakuMatch: 'true'
                    nameKanaZenkakuMatch: 'false'
                    middleNamesMatch: 'true'
                    familyNameAtBirthMatch: 'false'
                    addressMatch: 'true'
                    streetNameMatch: 'true'
                    streetNumberMatch: 'true'
                    postalCodeMatch: 'true'
                    regionMatch: 'true'
                    localityMatch: 'not_available'
                    countryMatch: 'true'
                    houseNumberExtensionMatch: 'not_available'
                    birthdateMatch: 'false'
                    emailMatch: 'false'
                    genderMatch: 'false'

        '400':
          $ref: '#/components/responses/Generic400'

        '401':
          $ref: '#/components/responses/Generic401'

        '403':
          $ref: '#/components/responses/Generic403'

        '404':
          $ref: '#/components/responses/Generic404'

        '500':
          $ref: '#/components/responses/Generic500'

        '503':
          $ref: '#/components/responses/Generic503'

        '504':
          $ref: '#/components/responses/Generic504'

components:
  securitySchemes:
    openId:
      type: openIdConnect
      openIdConnectUrl: https://example.com/.well-known/openid-configuration


  headers:
    x-correlator:
      description: Correlation id for the different services
      schema:
        type: string

  parameters:
    x-correlator:
      name: x-correlator
      in: header
      description: Correlation id for the different services
      schema:
        type: string
        
  schemas:
    KYC_MatchRequestBody:
      type: object
      description: Payload to validate the customer data.

      properties:
        phoneNumber:
          type: string
          description: A public identifier addressing a telephone subscription. In mobile networks it corresponds to the MSISDN (Mobile Station International Subscriber Directory Number). In order to be globally unique it has to be formatted in international format, according to E.164 standard, optionally prefixed with '+'.


        idDocument:
          type: string
          description: Id number associated to the official identity document in the country. It may contain alphanumeric characters.

        name:
          type: string
          description: Complete name of the customer, usually composed of first/given name and last/family/sur- name in a country.  Depending on the country, the order of first/give name and last/family/sur- name varies, and middle name could be included.  It can use givenName, middleNames, familyName and/or familyNameAtBirth. For example, in ESP, name+familyName; in NLD, it can be name+middleNames+familyName or name+middleNames+familyNameAtBirth, etc.

        givenName:
          type: string
          description: First/given name or compound first/given name of the customer.
          
        familyName:
          type: string
          description: Last name, family name, or surname of the customer.
          
        nameKanaHankaku:
          type: string
          description: Complete name of the customer in Hankaku-Kana format (reading of name) for Japan.

        nameKanaZenkaku:
          type: string
          description: Complete name of the customer in Zenkaku-Kana format (reading of name) for Japan.

        middleNames:
          type: string
          description: Middle name/s of the customer.

        familyNameAtBirth:
          type: string
          description: Last/family/sur- name at birth of the customer.

        address:
          type: string
          description: Complete address of the customer.  For some countries, it is built following the usual concatenation of parameters in a country, but for other countries, this is not the case.  For some countries, it can use streetName, streetNumber and/or houseNumberExtension. For example, in ESP, streetName+streetNumber; in NLD, it can be streetName+streetNumber or streetName+streetNumber+houseNumberExtension.
          
        streetName:
          type: string
          description: Name of the street of the customer's address. It should not include the type of the street.

        streetNumber:
          type: string
          description: The street number of the customer's address.  Number identifying a specific property on the 'streetName'.

        postalCode:
          type: string
          description: Zip code or postal code

        region:
          type: string
          description: Region/prefecture of the customer's address

        locality:
          type: string
          description: Locality of the customer's address

        country:
          type: string
          description: Country of the customer's address. Format ISO 3166-1 alpha-2

        houseNumberExtension:
          type: string
          description: Specific identifier of the house needed depending on the property type. For example, number of apartment in an apartment building.

        birthdate:
          type: string
          description: The birthdate of the customer, in ISO 8601 calendar date format (YYYY-MM-DD).

        email:
          type: string
          description: Email address of the customer in the RFC specified format (local-part@domain).

        gender:
          type: string
          description: Gender of the customer (Male/Female/Other).
          enum:
            - MALE
            - FEMALE
            - OTHER

    KYC_MatchResponse:
      type: object
      properties:

        idDocumentMatch:
          type: string
          description: Indicates whether Id number associated to the id_document of the customer matches with the one on the Operator's system.
          enum:
                - 'true'
                - 'false'
                - 'not_available'

        nameMatch:
          type: string
          description: Indicates whether the complete name of the customer matches with the one on the Operator's system.
          enum:
                - 'true'
                - 'false'
                - 'not_available'

        givenNameMatch:
          type: string
          description: Indicates whether First name/given name of the customer matches with the one on the Operator's system.
          enum:
                - 'true'
                - 'false'
                - 'not_available'

        familyNameMatch:
          type: string
          description: Indicates whether last name/ family name/ surname of the customer matches with the one on the Operator's system.
          enum:
                - 'true'
                - 'false'
                - 'not_available'

        nameKanaHankakuMatch:
          type: string
          description: Indicates whether complete name of the customer in Hankaku-Kana format (reading of name) for Japan matches with the one on the Operator's system.
          enum:
                - 'true'
                - 'false'
                - 'not_available'

        nameKanaZenkakuMatch:
          type: string
          description: Indicates whether complete name of the customer in Zenkaku-Kana format (reading of name) for Japan matches with the one on the Operator's system.
          enum:
                - 'true'
                - 'false'
                - 'not_available'

        middleNamesMatch:
          type: string
          description: Indicates whether the middle names of the customer matches with the one on the Operator's system.
          enum:
                - 'true'
                - 'false'
                - 'not_available'


        familyNameAtBirthMatch:
          type: string
          description: Indicates whether the Family Name At Birth of the customer matches with the one on the Operator's system.
          enum:
                - 'true'
                - 'false'
                - 'not_available'

        addressMatch:
          type: string
          description: Indicates whether complete address of the customer matches with the one on the Operator's system.
          enum:
                - 'true'
                - 'false'
                - 'not_available'

        streetNameMatch:
          type: string
          description: Indicates whether the street name of the customer matches with the one on the Operator's system.
          enum:
                - 'true'
                - 'false'
                - 'not_available'

        streetNumberMatch:
          type: string
          description: Indicates whether the street number of the customer matches with the one on the Operator's system.
          enum:
                - 'true'
                - 'false'
                - 'not_available'

        postalCodeMatch:
          type: string
          description: Indicates whether the postal code / zip code of the customer matches with the one on the Operator's system.
          enum:
                - 'true'
                - 'false'
                - 'not_available'

        regionMatch:
          type: string
          description: Indicates whether the region of the customer's address matches with the one on the Operator's system.
          enum:
                - 'true'
                - 'false'
                - 'not_available'

        localityMatch:
          type: string
          description: Indicates whether the locality of the customer's address matches with the one on the Operator's system.
          enum:
                - 'true'
                - 'false'
                - 'not_available'

        countryMatch:
          type: string
          description: Indicates whether the country of the customer's address matches with the one on the Operator's system.
          enum:
                - 'true'
                - 'false'
                - 'not_available'

        houseNumberExtensionMatch:
          type: string
          description: Indicates whether the house number extension of the customer's address with the one on the Operator's system.
          enum:
                - 'true'
                - 'false'
                - 'not_available'

        birthdateMatch:
          type: string
          description: Indicates whether the birthdate of the customer matches with the one on the Operator's system.
          enum:
                - 'true'
                - 'false'
                - 'not_available'

        emailMatch:
          type: string
          description: Indicates whether the email address of the customer matches with the one on the Operator's system.
          enum:
                - 'true'
                - 'false'
                - 'not_available'

        genderMatch:
          type: string
          description: Indicates whether the gender of the customer matches with the one on the Operator's system.
          enum:
                - 'true'
                - 'false'
                - 'not_available'

    ErrorInfo:
      type: object
      required:
        - status
        - code
        - message
      properties:
        status:
          type: integer
          description: HTTP response status code
        code:
          type: string
          description: Code given to this error
        message:
          type: string
          description: Detailed error description

  responses:
    Generic400:
      description: |-
        Problem with the client request.
        In addition to regular scenario of `INVALID_ARGUMENT`, another scenario may exist.

        - Indicated param combination is invalid (`"code": "KNOW_YOUR_CUSTOMER.INVALID_PARAM_COMBINATION","message": "Indicated parameter combination is invalid"`)
      headers:
        x-correlator:
          $ref: '#/components/headers/x-correlator'
      content:

        application/json:

          schema:
            $ref: '#/components/schemas/ErrorInfo'
          examples:
            InvalidArgument:
              value:
                status: 400
                code: INVALID_ARGUMENT
                message: Client specified an invalid argument, request body or query param
            InvalidParamCombination:
              value:
                status: 400
                code: KNOW_YOUR_CUSTOMER.INVALID_PARAM_COMBINATION
                message: Indicated parameter combination is invalid

    Generic401:
      description: Authentication problem with the client request. Unauthorized error.  Access Token related errors.
      headers:
        x-correlator:
          $ref: '#/components/headers/x-correlator'
      content:
        application/json:

          schema:
            $ref: '#/components/schemas/ErrorInfo'
          examples:
            Unauthenticated:
              value:
                status: 401
                code: UNAUTHENTICATED
                message: Request not authenticated due to missing, invalid, or expired credentials

    Generic403:
      description: |
        Client does not have sufficient permission.
        In addition to regular scenario of `PERMISSION_DENIED`, another scenarios may exist:
      
        - Phone number cannot be deducted from access token context.(`{"code": "KNOW_YOUR_CUSTOMER.INVALID_TOKEN_CONTEXT","message": "Phone number mismatch with access token context"}`)
        - The idDocument property is missing.(`{"code": "KNOW_YOUR_CUSTOMER.ID_DOCUMENT_REQUIRED","message": "The idDocument is required to perform the properties validation"}`)
        - The idDocument does not match the one associated to the provided phoneNumber in the Operator's system.(`{"code": "KNOW_YOUR_CUSTOMER.ID_DOCUMENT_MISMATCH","message": "The idDocument needs to match the one associated with the provided phoneNumber"}`)
      headers:
        x-correlator:
          $ref: '#/components/headers/x-correlator'
      content:

        application/json:

          schema:
            $ref: '#/components/schemas/ErrorInfo'
          examples:
            PermissionDenied:
              value:
                status: 403
                code: PERMISSION_DENIED
                message: Client does not have sufficient permissions to perform this action
            InvalidTokenContext:
              value:
                status: 403
                code: KNOW_YOUR_CUSTOMER.INVALID_TOKEN_CONTEXT
                message: Phone number mismatch with access token context
            IdDocumentRequired:
              value:
                status: 403
                code: KNOW_YOUR_CUSTOMER.ID_DOCUMENT_REQUIRED
                message: The idDocument is required to perform the properties validation
            IdDocumentMismatch:
              value:
                status: 403
                code: KNOW_YOUR_CUSTOMER.ID_DOCUMENT_MISMATCH
                message: The idDocument needs to match the one associated with the provided phoneNumber

    Generic404:
      description: |
        Not Found error.  Error if URL is wrong / user is not found.
      headers:
        x-correlator:
          $ref: '#/components/headers/x-correlator'
      content:
        application/json:

          schema:
            $ref: '#/components/schemas/ErrorInfo'
          examples:
            NotFound:
              value:
                status: 404

                code: NOT_FOUND
                message: not_found_contractor/not_found

    Generic500:
      description: Server error.  Problem with MNO's server side.  Some processing error within MNO's servers.
      headers:
        x-correlator:
          $ref: '#/components/headers/x-correlator'
      content:
        application/json:

          schema:
            $ref: '#/components/schemas/ErrorInfo'
          examples:
            ServerError:
              value:
                status: 500
                code: INTERNAL
                message: Server error

    Generic503:
      description: Service unavailable. Typically the server is down.  Problem with MNO's server side.  Any unexpected error within MNO's servers.
      headers:
        x-correlator:
          $ref: '#/components/headers/x-correlator'
      content:
        application/json:

          schema:
            $ref: '#/components/schemas/ErrorInfo'
          examples:
            ServiceUnavailable:
              value:
                status: 503
                code: UNAVAILABLE
                message: Service unavailable

    Generic504:
      description: Request time exceeded. If it happens repeatedly, consider reducing the request complexity
      headers:
        x-correlator:
          $ref: '#/components/headers/x-correlator'
      content:
        application/json:

          schema:
            $ref: '#/components/schemas/ErrorInfo'
          example:
            status: 504
            code: TIMEOUT
            message: Request timeout exceeded. Try later.

