---
openapi: 3.1.0
components:
  schemas:
    ApiResponse:
      type: object
      properties:
        message:
          type: string
        response: {}
    CallbackResult:
      type: object
      properties:
        reference:
          type: string
        signingStatus:
          $ref: "#/components/schemas/EsignSigningStatus"
        signer:
          $ref: "#/components/schemas/SignerResult"
        documents:
          type: array
          items:
            $ref: "#/components/schemas/SignedDocument"
        extensions:
          type: object
          additionalProperties: {}
    ContractBundleCreateRequest:
      type: object
      required:
      - applicationId
      - templateIds
      properties:
        applicationId:
          type: string
          pattern: \S
        templateIds:
          type: array
          minItems: 1
          items:
            type: string
            format: uuid
            pattern: "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}"
        name:
          type: string
        attemptCount:
          type: integer
          format: int32
    ContractBundleUser:
      type: string
      enum:
      - ADMIN
      - SALES
    ContractCategory:
      type: string
      enum:
      - MAIN
      - INSURANCE
      - OTHER
    ContractChangeFlowRequest:
      type: object
      properties:
        applicationId:
          type: string
        role:
          $ref: "#/components/schemas/ContractBundleUser"
    ContractDownInput:
      type: object
      properties:
        bundleId:
          $ref: "#/components/schemas/UUID"
        typeId:
          $ref: "#/components/schemas/UUID"
        errorMessage:
          type: string
    ContractFromApplicationRequest:
      type: object
      properties:
        applicationId:
          type: string
    ContractRegenerateInput:
      type: object
      properties:
        bundleId:
          $ref: "#/components/schemas/UUID"
        typeId:
          $ref: "#/components/schemas/UUID"
    ContractSignInput:
      type: object
      required:
      - fileUrl
      description: "Provide either contractId alone, or both bundleId and typeId together"
      properties:
        contractId:
          type: string
          description: Direct contract ID. Takes priority over bundleId + typeId if
            provided.
        bundleId:
          $ref: "#/components/schemas/UUID"
          type: string
          description: Bundle ID. Required when contractId is not provided.
        typeId:
          $ref: "#/components/schemas/UUID"
          type: string
          description: Contract type ID. Required when contractId is not provided.
        fileUrl:
          type: string
          pattern: \S
          description: DMS file URL of the signed document.
    ContractSigningMethod:
      type: string
      enum:
      - ESIGN
      - MANUAL
    ContractStatus:
      type: string
      enum:
      - COMPLETED
      - PENDING
      - FAILED
      - ARCHIVED
      - SIGNED
      - UNKNOWN
    ContractTemplateCreateRequest:
      type: object
      required:
      - name
      - templateTypeId
      - status
      properties:
        name:
          type: string
          pattern: \S
        templateTypeId:
          $ref: "#/components/schemas/UUID"
        header:
          type: string
        content:
          type: string
        footer:
          type: string
        status:
          $ref: "#/components/schemas/ContractTemplateStatus"
        projectData:
          type: object
          additionalProperties: {}
    ContractTemplateDuplicateRequest:
      type: object
      properties:
        contractTemplateId:
          $ref: "#/components/schemas/UUID"
        name:
          type: string
    ContractTemplateStatus:
      type: string
      enum:
      - ACTIVE
      - INACTIVE
      - DRAFT
      - ARCHIVED
    ContractTemplateUpdateRequest:
      type: object
      properties:
        id:
          $ref: "#/components/schemas/UUID"
        header:
          type: string
        content:
          type: string
        footer:
          type: string
        name:
          type: string
        typeId:
          $ref: "#/components/schemas/UUID"
        projectData:
          type: object
          additionalProperties: {}
    ContractTemplateUpdateStatusRequest:
      type: object
      properties:
        id:
          $ref: "#/components/schemas/UUID"
        status:
          $ref: "#/components/schemas/ContractTemplateStatus"
    ContractTypeCreateRequest:
      type: object
      required:
      - name
      - signingMethod
      - category
      properties:
        name:
          type: string
          minLength: 3
          maxLength: 50
          pattern: \S
        signingMethod:
          $ref: "#/components/schemas/ContractSigningMethod"
        category:
          $ref: "#/components/schemas/ContractCategory"
        isRequired:
          type: boolean
    ContractTypeUpdateRequest:
      type: object
      properties:
        id:
          $ref: "#/components/schemas/UUID"
        name:
          type: string
        signingMethod:
          $ref: "#/components/schemas/ContractSigningMethod"
        category:
          $ref: "#/components/schemas/ContractCategory"
        isRequired:
          type: boolean
    EsignSigningStatus:
      type: string
      enum:
      - NOT_SIGNED
      - SIGNED_BY_CUSTOMER
      - SIGNED_BY_INSURER
      - COMPLETED
      - PENDING
      - CANCELLED
    PagedResponse:
      type: object
      properties:
        list:
          type: array
          items: {}
        totalCount:
          type: integer
          format: int64
        totalPages:
          type: integer
          format: int32
        currentPage:
          type: integer
          format: int32
    SignedDocument:
      type: object
      properties:
        type:
          type: string
        content:
          type: string
        signingStatus:
          type: string
        completedAt:
          type: string
        fileName:
          type: string
    SignerResult:
      type: object
      properties:
        fullName:
          type: string
        email:
          type: string
        phoneNumber:
          type: string
        idDocumentNumber:
          type: string
        dateOfBirth:
          type: string
        hometown:
          type: string
        idIssuedBy:
          type: string
        permanentAddress:
          type: string
        region:
          type: string
        customerSignedAt:
          type: string
        insurerSignedAt:
          type: string
        disbursementAmount:
          type: integer
          format: int64
    UUID:
      type: string
      format: uuid
      pattern: "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}"
  securitySchemes:
    orgId:
      type: apiKey
      name: x-api-gw-organization-uuid
      in: header
    userId:
      type: apiKey
      name: x-api-gw-user-uuid
      in: header
paths:
  /contract:
    get:
      summary: Get contract
      description: Returns contract bundle detail by application ID
      parameters:
      - example: APP-00123
        in: query
        name: applicationId
        required: true
        schema:
          type: string
      - name: status
        in: query
        schema:
          $ref: "#/components/schemas/ContractStatus"
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema: {}
      tags:
      - Contract Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
    post:
      summary: Create contract bundle
      description: Creates a new contract bundle with contracts from state machine
      requestBody:
        content:
          application/json:
            examples: {}
            schema:
              $ref: "#/components/schemas/ContractBundleCreateRequest"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema: {}
        "400":
          description: Bad Request
      tags:
      - Contract Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
  /contract-log:
    get:
      summary: Get contract logs
      description: Returns paginated contract action logs for a given contract bundle
      parameters:
      - in: query
        name: contract-bundle-id
        required: true
        schema:
          type: string
      - name: page
        in: query
        schema:
          type: integer
          format: int32
          default: 1
      - name: size
        in: query
        schema:
          type: integer
          format: int32
          default: 20
      responses:
        "200":
          description: Fetched successfully
          content:
            application/json:
              schema: {}
        "400":
          description: not found
      tags:
      - Contract Log Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
  /contract-type:
    put:
      summary: Updates contract type
      description: Updates the name or required flag of an existing contract type
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ContractTypeUpdateRequest"
        required: true
      responses:
        "200":
          description: Contract type updated successfully
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponse"
        "404":
          description: Contract type not found
        "409":
          description: Name already exists
        "400":
          description: Bad Request
      tags:
      - Contract Type Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
    get:
      summary: List all contract types
      description: Returns all contract types for the current organization
      responses:
        "200":
          description: Successfully retrieved list
          content:
            application/json: {}
      tags:
      - Contract Type Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
    post:
      summary: Creates new contract type
      description: Creates a new contract type for the organization. Returns 409 if
        the name already exists.
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ContractTypeCreateRequest"
        required: true
      responses:
        "201":
          description: Contract type created successfully
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponse"
        "400":
          description: Invalid data provided
        "409":
          description: Contract type with this name already exists
      tags:
      - Contract Type Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
  /contract/bundle/list:
    get:
      summary: Get contract bundle list
      description: Returns a paginated list of all contract bundles
      parameters:
      - name: applicationId
        in: query
        schema:
          type: string
      - name: page
        in: query
        schema:
          type: integer
          format: int32
          default: 1
      - name: size
        in: query
        schema:
          type: integer
          format: int32
          default: 20
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema: {}
      tags:
      - Contract Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
  /contract/bundle/seal:
    post:
      summary: Seal bundle
      description: Marks the bundle as complete — no more contracts will be added.
        Triggers E-Sign automatically once all PDFs finish generating.
      parameters:
      - example: APP-00123
        in: query
        name: applicationId
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema: {}
      tags:
      - Contract Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
  /contract/callback:
    post:
      summary: Contract generation callback
      description: Called by the template service when PDF generation is complete.
        Requires x-webhook-secret header.
      parameters:
      - example: contract-abc123
        in: query
        name: contractId
        required: true
        schema:
          type: string
      - in: header
        name: x-webhook-secret
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema: {}
      security: []
      tags:
      - Contract Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
  /contract/down:
    post:
      summary: Mark contract as failed
      description: Marks a specific contract and its bundle as failed with an error
        message
      requestBody:
        content:
          application/json:
            examples: {}
            schema:
              $ref: "#/components/schemas/ContractDownInput"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema: {}
        "400":
          description: Bad Request
      tags:
      - Contract Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
  /contract/esign/callback:
    post:
      summary: E-Sign callback
      description: Called by the Integration service when all documents have been
        signed. Requires x-webhook-secret header.
      parameters:
      - in: header
        name: x-webhook-secret
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/json:
            examples: {}
            schema:
              $ref: "#/components/schemas/CallbackResult"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema: {}
        "400":
          description: Bad Request
      security: []
      tags:
      - Contract Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
  /contract/esign/result:
    get:
      summary: Poll E-Sign result
      description: Manually retrieves signed documents from the E-Sign service and
        processes them. Use when the callback was not received.
      parameters:
      - example: APP-00123
        in: query
        name: applicationId
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema: {}
      tags:
      - Contract Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
  /contract/manual-sign:
    post:
      summary: Mark contract as signed
      description: "Marks a single KYC contract as signed without file upload. Accepts\
        \ either contractId alone, or both bundleId and typeId."
      requestBody:
        content:
          application/json:
            examples:
              By contractId:
                value:
                  contractId: contract-abc123
              By bundleId + typeId:
                value:
                  bundleId: a1b2c3d4-e5f6-7890-abcd-ef1234567890
                  typeId: b2c3d4e5-f6a7-8901-bcde-f12345678901
                  fileUrl: dms-node-id-or-url
            schema:
              $ref: "#/components/schemas/ContractSignInput"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema: {}
        "400":
          description: Bad Request
      tags:
      - Contract Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
  /contract/regenerate:
    post:
      summary: Regenerate contract
      description: Regenerates a specific contract within a bundle for the given type
      requestBody:
        content:
          application/json:
            examples: {}
            schema:
              $ref: "#/components/schemas/ContractRegenerateInput"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema: {}
        "400":
          description: Bad Request
      tags:
      - Contract Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
  /contract/resend-signing-link:
    post:
      summary: Resend E-Sign link
      description: Resends the electronic signing link for a contract bundle
      requestBody:
        content:
          application/json:
            examples: {}
            schema:
              $ref: "#/components/schemas/ContractFromApplicationRequest"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema: {}
        "400":
          description: Bad Request
      tags:
      - Contract Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
  /contract/sequence/current:
    get:
      summary: Get current sequence value
      description: Returns the last used sequence number from the database without
        incrementing it.
      tags:
      - Contract Numbering
      responses:
        "200":
          description: Current sequence retrieved
          content:
            application/json:
              schema: {}
      security: []
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
  /contract/sequence/generate:
    post:
      summary: Generate next AEON ID
      description: Increments the database sequence and returns a formatted AEON ID
        string.
      tags:
      - Contract Numbering
      responses:
        "200":
          description: New ID generated successfully
          content:
            application/json:
              schema: {}
      security: []
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
  /contract/set-manual-kyc:
    post:
      summary: Set manual KYC flow
      description: Switches a contract bundle to the manual KYC verification flow
      requestBody:
        content:
          application/json:
            examples: {}
            schema:
              $ref: "#/components/schemas/ContractChangeFlowRequest"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema: {}
        "400":
          description: Bad Request
      tags:
      - Contract Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Branch headers
        color: indigo
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
      x-attach-branch-headers: true
  /contract/update-status:
    put:
      summary: Update contract status to Signed
      description: Marks a contract bundle and all its contracts as signed
      requestBody:
        content:
          application/json:
            examples: {}
            schema:
              $ref: "#/components/schemas/ContractFromApplicationRequest"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema: {}
        "400":
          description: Bad Request
      tags:
      - Contract Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
  /contract/upload:
    post:
      summary: Upload signed PDF
      description: Uploads a signed PDF for KYC contract signing
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              required:
              - file
              properties:
                file:
                  type: string
                  format: binary
                bundleId:
                  $ref: "#/components/schemas/UUID"
                typeId:
                  $ref: "#/components/schemas/UUID"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema: {}
      tags:
      - Contract Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
  /contract/{bundle-id}/finalize:
    post:
      summary: Finalize KYC contract bundle
      description: Finalizes the contract bundle after all KYC documents have been
        signed
      parameters:
      - example: a1b2c3d4-e5f6-7890-abcd-ef1234567890
        in: path
        name: bundle-id
        required: true
        schema:
          $ref: "#/components/schemas/UUID"
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema: {}
      tags:
      - Contract Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
  /file/{file-id}:
    get:
      summary: Download file from DMS
      description: Downloads a file from the Document Management System by its node
        ID
      parameters:
      - name: file-id
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: File downloaded successfully
          content:
            application/octet-stream: {}
      tags:
      - File Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
  /health:
    get:
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema: {}
      security: []
      summary: Health
      tags:
      - Health Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
  /template/create:
    post:
      summary: Create contract template
      description: Creates a new contract template in both the external template service
        and local database
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ContractTemplateCreateRequest"
        required: true
      responses:
        "201":
          description: Template created successfully
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponse"
        "400":
          description: Invalid data
      tags:
      - Contract Template Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
  /template/duplicate:
    post:
      summary: Duplicate template
      description: Creates a copy of an existing contract template with a new name
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ContractTemplateDuplicateRequest"
        required: true
      responses:
        "201":
          description: Contract template duplicated successfully
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponse"
        "400":
          description: Bad Request
      tags:
      - Contract Template Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
  /template/list:
    get:
      summary: Get contract templates list
      description: "Returns a paginated list of contract templates, filtering by status,\
        \ template name, and/or contract type name if provided (otherwise excludes\
        \ archived by default)"
      parameters:
      - name: page
        in: query
        schema:
          type: integer
          format: int32
          default: 1
      - name: size
        in: query
        schema:
          type: integer
          format: int32
          default: 20
      - name: status
        in: query
        schema:
          $ref: "#/components/schemas/ContractTemplateStatus"
      - name: templateName
        in: query
        schema:
          type: string
      - name: typeName
        in: query
        schema:
          type: string
      responses:
        "200":
          description: List retrieved successfully
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PagedResponse"
      tags:
      - Contract Template Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
  /template/status:
    put:
      summary: Update contract template status
      description: "Updates the status of a contract template (e.g. ACTIVE, INACTIVE,\
        \ ARCHIVED)"
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ContractTemplateUpdateStatusRequest"
        required: true
      responses:
        "200":
          description: Status updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponse"
        "400":
          description: Bad Request
      tags:
      - Contract Template Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
  /template/update:
    put:
      summary: Update full template content
      description: "Updates the name, content, and type of a contract template"
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ContractTemplateUpdateRequest"
        required: true
      responses:
        "200":
          description: Contract template content updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponse"
        "400":
          description: Bad Request
      tags:
      - Contract Template Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
  /template/{template-id}:
    get:
      summary: Get contract template detail
      description: Returns local and external template details by ID
      parameters:
      - name: template-id
        in: path
        required: true
        schema:
          $ref: "#/components/schemas/UUID"
      responses:
        "200":
          description: Template retrieved successfully
          content:
            application/json:
              schema: {}
      tags:
      - Contract Template Resource
      x-expose-to-gateways:
      - admin-apigw
      - openapi-apigw
      - borrower-apigw
      x-zudoku-badges:
      - label: Admin
        color: gray
      - label: OpenAPI
        color: gray
      - label: Borrower
        color: gray
tags:
- name: Contract Numbering
  description: Operations related to AEON-style contract IDs
info:
  title: contract-manager API
  version: 1.0.0-SNAPSHOT
  description: |-
    # Contract Manager

    Produces and manages the **contracts and documents** generated during lending.

    ## Overview
    Generates contracts from templates, organizes them into bundles, manages contract types and numbering, coordinates e-signing, and serves the resulting documents for download. It ties together template content and stored files so a finished contract can be produced and retrieved.

    ## Why it exists
    Contracts must be produced consistently across products and kept track of from creation through signing. This service standardizes that process so document generation is repeatable, auditable, and decoupled from the systems that store files and render templates.

    ## Authentication
    Requests are authenticated by the platform gateway, which identifies the caller and their organization; contract access is scoped to that organization. Signing and external callbacks are verified with a shared secret.
security:
- userId: []
  orgId: []
