openapi: 3.0.3
info:
  title: Know Your Customer Fill-in

  description: |

    This API provides the customer with the ability request and receive the information for a particular user, which on file (and verified) by the 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 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 request for API provider / MNO to provide information related to a mobile phone user, derived from the account data bound to their phone number.  The API is intended to be used in the following scenario, for example:

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

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

    <img width="854" alt="KYC_Fill-in_flow" src="https://github.com/ToshiWakayama-KDDI/KnowYourCustomer-Toshi/assets/53090722/f23daa52-bb28-4236-b90d-0184d303f907">

    Note:

    * Before calling this API, 3rd parties / enterprise customers who want to use this API should make contract with API provider/ Operator for use of this API.  As that will depend on each API provider / MNO's business processes 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 to be 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.  **As an important note**, capturing end user consent is necessary, because this API provides end user information (PII).

    * For this version of the KYC Fill-in API, the request body of the Fill-in Request does not include any parameters/attributes.  The above mentioned AuthN/AuthZ/End User consent capturing processes can give the API provider/ MNO the 3rd party identity (with the Access Token) and the end user identity (with the ID Token), so the API provider/ MNO can identify the 3rd party / enterprise customer and the end user.  Then, it is up to API provider/ MNO to decide which information the 3rd party will receive by calling the API, and also the API provider / MNO is responsible for security and privacy issues.

    * For example, below is a potential operation:
      * when making contract with API provider/ MNO, a 3rd party / enterprise customer receives its 3rd party identity and also decide which information (attributes) it will receive for its API call
      * when calling this API, the client of a 3rd party / enterprise customer put its 3rd party identity (only) in the request body
      * then, API provider / MNO will provide information (attributes) which the 3rd party / enterprise customer is allowed to receive by the contract.


    ## Resources and Operations overview

    The API provides the following endpoint:

    * An endpoint to request information related to an end user 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-fill-in/v0'
    variables:
      apiRoot:
        default: http://localhost:9091
        description: API root
      basePath:
        default: kyc-fill-in/v0
        description: Base path for the KYC-Fill-in API

tags:
  - name: Fill-in
    description: Operations to provide information related to a customer identity stored the account data bound to the customer's phone number.

paths:
  /fill-in:
    post:
      tags:
        - Fill-in
      summary: Providing information related to a customer identity stored the account data bound to the customer's phone number.

      operationId: KYC_Fill-in

      security:
        - openId:
          - know-your-customer:fill-in

      parameters:
        - $ref: '#/components/parameters/x-correlator'

      responses:
        '200':
          description: OK

          headers:
            x-correlator:
              $ref: '#/components/headers/x-correlator'

          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KYC_FillinResponse'
              examples:
                KYC_Fillin200Example:
                  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: 36
                    birthdate: '1978-08-22'
                    email: abc@example.com
                    gender: male

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

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

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

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

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

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_FillinResponse:
      type: object
      properties:

        phoneNumber:
          type: string
          description: The phone number of the customer stored on the Operator's system.  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 id_document of the customer stored on the Operator's system.
         
        name:
          type: string
          description: Complete name of the customer stored on the Operator's system.  It is 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 on the Operator's system.
          
        familyName:
          type: string
          description: Last name, family name, or surname of the customer stored on the Operator's system.
          
        nameKanaHankaku:
          type: string
          description: Complete name of the customer in Hankaku-Kana format (reading of name) for Japan, stored on the Operator's system.

        nameKanaZenkaku:
          type: string
          description: Complete name of the customer in Zenkaku-Kana format (reading of name) for Japan, stored on the Operator's system.

        middleNames:
          type: string
          description: Middle name/s of the customer stored on the Operator's system.

        familyNameAtBirth:
          type: string
          description: Last/family/sur- name at birth of the customer stored on the Operator's system.
          
        address:
          type: string
          description: Complete address of the customer stored on the Operator's system.  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 on the Operator's system.  It should not include the type of the street.
          
        streetNumber:
          type: string
          description: The street number of the customer's address on the Operator's system.  Number identifying a specific property on the 'streetName'.
          
        postalCode:
          type: string
          description: The postal code or Zip code of the customer's address, stored on the Operator's system.
          
        region:
          type: string
          description: Region/prefecture of the customer's address, stored on the Operator's system.
          
        locality:
          type: string
          description: Locality of the customer's address, stored on the Operator's system.

        country:
          type: string
          description: Country of the customer's address stored on the Operator's system. Format ISO 3166-1 alpha-2.
          
        houseNumberExtension:
          type: string
          description: House number extension of the customer stored on the Operator's system.  Specific identifier of the house needed depending on the property type. For example, number of apartment in an apartment building.
          
        birthdate:
          type: string
          description: Birthdate of the customer, in ISO 8601 calendar date format (YYYY-MM-DD), stored on the Operator's system.
          
        email:
          type: string
          description: Email address of the customer in the RFC specified format (local-part@domain), stored on the Operator's system.
          
        gender:
          type: string
          description: Gender of the customer stored on the Operator's system (Male/Female/Other).
          
    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.
      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 para
                
    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

    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. 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


