openapi: 3.0.1
info:
  license:
    name: Khipu Open Data API
    url: https://khipu.com
  title: Consorcio
  description: ''
  version: v1.0
servers:
  - url: https://api.khipu.com
    description: Production
security:
  - JWT: []
  - Api-Key: []
paths:
  /v1/cl/banking/business/consorcio.cl/token:
    post:
      summary: Account Link
      description: >-
        This method connects to the user's account in **Banco Consorcio -
        Empresas** and returns a token  linked to that account that can be used
        in further operations, avoiding the need to send your  credentials in
        plain text when calling the banking services.
      operationId: AccountLink
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AuthCredential'
        required: true
      responses:
        '200':
          description: >-
            Successful operation. Returns a JSON object with the token for the
            account in the `Data` field.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenResponseOk'
        '400':
          description: Bad Request
        '401':
          description: Unauthorized - Invalid or missing credentials
        '404':
          description: Not found - Resource not available
        '500':
          description: Remote service error :(
components:
  securitySchemes:
    JWT:
      type: http
      scheme: bearer
      bearerFormat: JWT
    Api-Key:
      type: apiKey
      in: header
      name: x-api-key
  schemas:
    AuthCredential:
      description: Values needed to authenticate the user in the bank's website.
      properties:
        Username:
          description: User identification with access to the bank's account (RUN, DNI).
          example: 11.111.111-1
          type: string
          maxLength: 12
          minLength: 1
        Password:
          description: Account password for the website.
          example: wxyz1234!@#$
          type: string
          maxLength: 24
          minLength: 1
        EnterpriseIdentity:
          description: Enterprise identification (RUT).
          example: 99.999.999-9
          type: string
          maxLength: 12
          minLength: 1
      required:
        - Username
        - Password
      type: object
    TokenResponseOk:
      additionalProperties: false
      description: >-
        Object with the response from OpenData service for the Transactions
        operations, in synchronous mode, when `Status` is "OK"
      properties:
        OperationId:
          description: Unique identifier of the operation.
          example: 6baf6c19-e485-463b-ae24-a821b025c8a4
          type: string
          maxLength: 36
        Status:
          description: >-
            Operation status. `OK` means that the service was executed
            successfully even if it does not return Data. `ERROR` indicates that
            something happened that prevented the successful completion of the
            process.
          example: OK
          type: string
          enum:
            - OK
            - ERROR
        Data:
          description: >-
            If the authentication challenge was successful, it includes the link
            for the account.
          properties:
            AccountLink:
              description: Token generated to access the bank account.
              example: >-
                dFyRCVYNM0aGb1LSR/0B8e+eSVr1Zf1xj9YHmMVoiZWk28XtWEyIxEbGXnr1EdvS+QBPzjweau7tbf5QlDv97IQ2jwfUB==
              type: string
          required:
            - AccountLink
          type: object
          nullable: true
        AdditionalInformation:
          description: >-
            This field can be used to display relevant information specific to
            the response, for instance indicating that the `Data` field is
            incomplete.
          example: null
          type: string
          nullable: true
        Error:
          description: >-
            Object with the error details, used when `Status=ERROR`. If
            `Status=OK` this field will be null. You can read a complete
            explanation of this object visiting [this
            link](https://docs.khipu.com/portal/en/errors/)
          example: null
          properties:
            Code:
              description: Internal system code that identifies the error.
              example: E201
              type: string
            Type:
              description: >-
                Indicates how to treat this specific error code, based on the
                type of error.
              example: RETRY_IMMEDIATELY
              type: string
              enum:
                - RETRY_IMMEDIATELY
                - DO_NOT_RETRY
                - WAIT_4_HOURS_BEFORE_RETRY
                - RETRY_AFTER_NOTIFICATION
            Description:
              description: Description associated with the error code.
              example: >-
                El servicio destino utilizado para la extracción de datos no se
                encuentra disponible.
              type: string
          required: []
          type: object
          nullable: true
        LifeSpan:
          description: '`null` in sync requests.'
          example: null
          type: string
          nullable: true
      required:
        - OperationId
        - Status
        - Data
        - AdditionalInformation
        - Error
        - LifeSpan
      type: object
