LendKey Disbursements API

Disbursement processing and cancellation

OpenAPI Specification

lendkey-disbursements-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: LendKey E-Sign API (via Kong Gateway) Application Contracts Disbursements API
  version: 0.1
  description: "# LendKey E-Sign API - Kong Gateway Documentation\n\n## Overview\n\nThe LendKey E-Sign API provides endpoints for creating and managing electronic signature contracts using DocuSign.\nThis API is accessed through Kong Gateway, which handles authentication via OAuth2.\n\n## Authentication\n\nAll requests to this API require OAuth2 authentication through Kong Gateway.\n\n### Step 1: Get OAuth2 Token\n\nBefore calling any endpoint, you must obtain an access token:\n\n**Production Environment:**\n```bash\ncurl -X POST https://api.lendkey.com/esign/oauth2/token \\\n  -d \"grant_type=client_credentials\" \\\n  -d \"client_id=YOUR_CLIENT_ID\" \\\n  -d \"client_secret=YOUR_CLIENT_SECRET\"\n```\n\n**Response:**\n```json\n{\n  \"access_token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...\",\n  \"token_type\": \"bearer\",\n  \"expires_in\": 7200\n}\n```\n\n### Step 2: Use Token in API Calls\n\nInclude the access token in the `Authorization` header:\n```\nAuthorization: Bearer YOUR_ACCESS_TOKEN\n```\n\n**Token Lifetime:** 2 hours (7200 seconds)\n\n## Base URLs (Kong Gateway)\n\n| Environment | Kong Base URL | Backend Kubernetes Service |\n|------------|---------------|---------------------------|\n| **Production** | `https://api.lendkey.com/esign` | `main-esign-kotlin.ci.lkeyprod.com` |\n\n## How Kong Routes Requests\n\nWhen you call Kong:\n```\nhttps://api.lendkey.com/esign/applications\n```\n\nKong:\n1. Validates your OAuth2 token\n2. Strips the `/esign` prefix\n3. Forwards to: `http://main-esign-kotlin.ci.lkeyprod.com/applications`\n\nYou don't need to manage any backend authentication - Kong handles everything!\n\n## Getting Started\n\n1. **Get Credentials:** Contact your Kong admin or use the Kong Developer Portal\n2. **Get Token:** Use the OAuth2 token endpoint for your environment\n3. **Call API:** Use the token in the Authorization header\n4. **Refresh:** Get a new token every 2 hours\n"
  contact:
    name: LendKey Platform Team
    url: https://lendkey.com
servers:
- url: https://api.lendkey.com/esign
  description: Production Environment
security:
- oauth2: []
tags:
- name: Disbursements
  description: Disbursement processing and cancellation
paths:
  /v1/createDisbursement:
    post:
      summary: Create Disbursement
      description: 'Processes disbursement transactions for existing loans.


        Use this endpoint to record fund disbursements to borrowers after loan creation.


        **Kong Route:** `/v1/createDisbursement`

        **Backend:** `/TreasuryManagement_API/rest/v1/createDisbursement`

        '
      tags:
      - Disbursements
      operationId: createDisbursement
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateDisbursementRequest'
            examples:
              standardDisbursement:
                summary: Standard disbursement
                value:
                  loanUUID: 550e8400-e29b-41d4-a716-446655440000
                  amount: 25000.5
                  externalID: DISB-2025-001
                  startDate: '2025-01-15'
      responses:
        '200':
          description: Disbursement successfully created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateDisbursementResponse'
        '207':
          description: Multi-status (partial success)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateDisbursementResponse'
        '400':
          description: Bad request (validation errors)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized (invalid or expired token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /v1/cancelDisbursement:
    post:
      summary: Cancel Disbursement
      description: 'Reverses a previously recorded disbursement.


        Use this endpoint to cancel/reverse a disbursement transaction.


        **Kong Route:** `/v1/cancelDisbursement`

        **Backend:** `/TreasuryManagement_API/rest/v1/cancelDisbursement`

        '
      tags:
      - Disbursements
      operationId: cancelDisbursement
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelDisbursementRequest'
            examples:
              cancelDisbursement:
                summary: Cancel a disbursement
                value:
                  subledger_Category: Disbursement Cancellation
                  external_id: DISB-2025-001
                  account_id: ACC-12345
                  entity_type: Borrower
                  amount: 25000.5
                  disbursement_uuid: 550e8400-e29b-41d4-a716-446655440000
                  created_by: system_admin
      responses:
        '200':
          description: Disbursement successfully cancelled
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CancelDisbursementResponse'
        '207':
          description: Multi-status (partial success)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CancelDisbursementResponse'
        '400':
          description: Bad request (validation errors)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized (invalid or expired token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    CreateDisbursementRequest:
      type: object
      required:
      - loanUUID
      - amount
      - externalID
      properties:
        loanUUID:
          type: string
          format: uuid
          description: UUID of the loan to disburse
          example: 550e8400-e29b-41d4-a716-446655440000
        amount:
          type: number
          format: double
          description: Disbursement amount
          example: 25000.5
        externalID:
          type: string
          description: External disbursement identifier
          example: DISB-2025-001
        startDate:
          type: string
          format: date
          description: Disbursement date (YYYY-MM-DD)
          example: '2025-01-15'
    CancelDisbursementResponse:
      type: object
      properties:
        IsSuccess:
          type: boolean
          description: Success indicator
          example: true
        statusCode:
          type: integer
          description: HTTP status code
          example: 200
        errors:
          type: array
          description: Array of error messages (if any)
          items:
            type: string
    ErrorResponse:
      type: object
      properties:
        isSuccess:
          type: boolean
          description: Success indicator (always false for errors)
          example: false
        statusCode:
          type: integer
          description: HTTP status code
          example: 400
        error:
          type: string
          description: Error message
          example: Invalid request
        errors:
          type: array
          description: Detailed error messages
          items:
            type: string
          example:
          - Field 'loanUUID' is required
          - Field 'amount' must be greater than 0
    CancelDisbursementRequest:
      type: object
      required:
      - subledger_Category
      - external_id
      - account_id
      - entity_type
      - amount
      - disbursement_uuid
      - created_by
      properties:
        subledger_Category:
          type: string
          enum:
          - Disbursement Cancellation
          description: Category (must be "Disbursement Cancellation")
          example: Disbursement Cancellation
        external_id:
          type: string
          description: External disbursement identifier
          example: DISB-2025-001
        account_id:
          type: string
          description: Account identifier
          example: ACC-12345
        entity_type:
          type: string
          description: Entity type (e.g., Borrower, Lender)
          example: Borrower
        amount:
          type: number
          format: double
          description: Disbursement amount to cancel
          example: 25000.5
        disbursement_uuid:
          type: string
          format: uuid
          description: UUID of the disbursement to cancel
          example: 550e8400-e29b-41d4-a716-446655440000
        created_by:
          type: string
          description: User or system initiating the cancellation
          example: system_admin
    CreateDisbursementResponse:
      type: object
      properties:
        isSuccess:
          type: boolean
          description: Overall success indicator
          example: true
        statusCode:
          type: integer
          description: HTTP status code
          example: 200
        responseDetails:
          type: array
          items:
            type: object
            properties:
              uuid:
                type: string
                format: uuid
                description: Generated disbursement UUID
                example: 660e8400-e29b-41d4-a716-446655440000
              errors:
                type: array
                description: Array of error messages (if any)
                items:
                  type: string
  securitySchemes:
    oauth2:
      type: oauth2
      description: OAuth2 client credentials flow via Kong Gateway
      flows:
        clientCredentials:
          tokenUrl: /oauth2/token
          scopes: {}