openapi: 3.0.0
info:
  title: RWA.ID
  version: 1.0.0
  description: API for verifications, verification pipeline configuration, and interfacing with onchain verification records.

security:
  - bearerAuth: [] # use the same name as above
paths:
  /auth:
    post:
      summary: Get Bearer Token
      description: Verifies a wallet address and signature to generate a bearer token for authentication.
      tags:
        - Authentication
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                walletAddress:
                  type: string
                  description: The wallet address of the user.
                  example: "0x1234567890abcdef1234567890abcdef12345678"
                signature:
                  type: string
                  description: The signature generated by the user's wallet for verification.
                  example: "0xabcdef..."
              required:
                - walletAddress
                - signature
      responses:
        200:
          description: Bearer token generated successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  token:
                    type: string
                    description: The generated bearer token for authentication.
                    example: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
        400:
          description: Invalid input or verification failed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: The error message.
                    example: "Invalid signature."
        500:
          description: Internal server error.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: The error message.
                    example: "An error occurred on the server."
  /verificationPipeline:
    get:
      summary: Retrieve verification pipeline configuration
      parameters:
        - name: accountId
          in: query
          required: true
          schema:
            type: string
          description: Account ID to retrieve the verification pipeline for
      responses:
        '200':
          description: Successfully retrieved verification pipeline configuration
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VerificationPipelineConfig'
        '500':
          description: Internal server error
    post:
      summary: Add or update verification pipeline configuration
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VerificationPipelineConfig'
      responses:
        '200':
          description: Successfully added or updated verification pipeline
          content:
            text/plain:
              schema:
                type: string
                example: Success
        '500':
          description: Internal server error

  /chainIdentityInd:
    get:
      summary: Validate chain identifier for an individual
      parameters:
        - name: Id
          in: query
          required: true
          schema:
            type: string
          description: Unique identifier for the rental verification profile
        - name: FirstName
          in: query
          required: true
          schema:
            type: string
          description: First name of the individual
        - name: LastName
          in: query
          required: true
          schema:
            type: string
          description: Last name of the individual
      responses:
        '200':
          description: Successfully validated chain identifier
          content:
            text/plain:
              schema:
                type: string
                example: tokenId
        '500':
          description: Internal server error
    post:
      summary: Add chain identifier for an individual
      parameters:
        - name: caseId
          in: query
          required: true
          schema:
            type: string
          description: Case ID for the chain identifier
        - name: walletId
          in: query
          required: true
          schema:
            type: string
          description: Wallet ID for the chain identifier
      responses:
        '200':
          description: Successfully added chain identifier
          content:
            text/plain:
              schema:
                type: string
                example: tokenId
        '500':
          description: Internal server error
  /chainIdentityBiz:
    get:
      summary: Validate chain identifier for a business
      parameters:
        - name: businessName
          in: query
          required: true
          schema:
            type: string
          description: Name of the business
        - name: registration
          in: query
          required: true
          schema:
            type: string
          description: Registration identifier of the business
        - name: stateOrProv
          in: query
          required: true
          schema:
            type: string
          description: State or province of the business
        - name: country
          in: query
          required: true
          schema:
            type: string
          description: Country of the business
        - name: walletId
          in: query
          required: true
          schema:
            type: string
          description: Wallet ID associated with the business
      responses:
        '200':
          description: Successfully validated chain identifier for the business
          content:
            text/plain:
              schema:
                type: string
                example: tokenId
        '500':
          description: Internal server error
    post:
      summary: Add chain identifier for a business
      parameters:
        - name: businessName
          in: query
          required: true
          schema:
            type: string
          description: Name of the business
        - name: registration
          in: query
          required: true
          schema:
            type: string
          description: Registration identifier of the business
        - name: stateOrProv
          in: query
          required: true
          schema:
            type: string
          description: State or province of the business
        - name: country
          in: query
          required: true
          schema:
            type: string
          description: Country of the business
        - name: walletId
          in: query
          required: true
          schema:
            type: string
          description: Wallet ID associated with the business
      responses:
        '200':
          description: Successfully added chain identifier for the business
          content:
            text/plain:
              schema:
                type: string
                example: tokenId
        '500':
          description: Internal server error
          paths:
  /verifyRentalRequirements:
    post:
      summary: Run rental verification
      description: Verifies rental information using the provided profile and returns the verification results.
      parameters:
        - in: query
          name: verifiedId
          schema:
            type: string
          description: Verified ID associated with the request
        - in: query
          name: clientId
          schema:
            type: string
          description: Client ID associated with the request
        - in: query
          name: caseId
          schema:
            type: string
          description: Case ID for the verification request
        - in: query
          name: walletId
          schema:
            type: string
          description: Wallet ID associated with the user
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                FirstName:
                  type: string
                  description: First name of the applicant
                LastName:
                  type: string
                  description: Last name of the applicant
                DateOfBirth:
                  type: string
                  format: date
                  description: Date of birth of the applicant
                SSN:
                  type: string
                  description: Social Security Number of the applicant
                StreetAddress:
                  type: string
                  description: Street address of the applicant
                City:
                  type: string
                  description: City of residence of the applicant
                State:
                  type: string
                  description: State of residence of the applicant
                Email:
                  type: string
                  format: email
                  description: Email address of the applicant
                PostalCode:
                  type: string
                  description: Postal code of the applicant
                OpenBankingSubscriptionId:
                  type: string
                  description: Open banking subscription ID for income verification
                OpenBankingToken:
                  type: string
                  description: Token associated with open banking subscription
      responses:
        '200':
          description: Successful verification
          content:
            application/json:
              schema:
                type: object
                properties:
                  tokenId:
                    type: string
                    description: Token ID associated with the verification
                  verificationResults:
                    type: object
                    properties:
                      Id:
                        type: string
                        description: Verification result ID
                      IncomEstimate:
                        type: number
                        description: Estimated income based on the profile data
                      QualifiedViaCredit:
                        type: boolean
                        description: Whether the applicant is qualified based on credit report
        '500':
          description: Internal server error
    /verifyPropertyOwnership:
        post:
          summary: Run ownership verification
          description: Verifies an individual or business owns a property based on verified identity and address records.
          parameters:
            - in: query
              name: verifiedId
              schema:
                type: string
              description: Verified ID associated with the request
            - in: query
              name: walletId
              schema:
                type: string
              description: Wallet ID associated with the user
          requestBody:
            required: true
            content:
              application/json:
                schema:
                  type: object
                  properties:
                    StreetAddress:
                      type: string
                      description: Street address of the applicant
                    City:
                      type: string
                      description: City of residence of the applicant
                    State:
                      type: string
                      description: State of residence of the applicant
                    PostalCode:
                      type: string
                      description: Postal code of the applicant
                  required:
                    - StreetAddress
                    - City
                    - State
                    - PostalCode
          responses:
            '200':
              description: Successful verification
              content:
                text/plain:
                  schema:
                    type: string
                    description: Null if denied
                    example: tokenId
            '500':
              description: Internal server error
components:
  securitySchemes:
    bearerAuth: # arbitrary name for the security scheme
      type: http
      scheme: bearer
      bearerFormat: JWT # optional, arbitrary value for documentation purposes
  schemas:
    VerificationPipelineConfig:
      type: object
      properties:
        ClientId:
          type: string
          example: ""
          description: Client ID for the verification pipeline
        EvictionCheck:
          type: boolean
          example: true
          description: Indicates if eviction check is required
        IncomeCheck:
          type: boolean
          example: true
          description: Indicates if income check is required
        SoftCreditCheck:
          type: boolean
          example: true
          description: Indicates if soft credit check is required
        CriminalBackgroundCheck:
          type: boolean
          example: true
          description: Indicates if criminal background check is required
        CountryIdentifier:
          type: string
          example: "USA"
          description: Country identifier for the verification pipeline

    RentalVerificationProfile:
      type: object
      properties:
        Id:
          type: string
          example: "123"
          description: Unique identifier for the rental verification profile
        FirstName:
          type: string
          example: "John"
          description: First name of the individual
        LastName:
          type: string
          example: "Doe"
          description: Last name of the individual