> ## Documentation Index
> Fetch the complete documentation index at: https://docs.enfuce.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create an instalment

> This operation will create an instalment plan



## OpenAPI

````yaml instalment post /v1
openapi: 3.0.3
info:
  description: Endpoint for manipulating instalments
  version: '1'
  title: Instalment API
  contact:
    name: Enfuce Financial Services
    url: https://enfuce.com
    email: info@enfuce.com
  x-logo:
    url: https://developer.enfuce.com/images/enfuce.svg
    altText: Enfuce logo
servers:
  - url: >-
      https://integration-api-cat2.{{environment}}.ext.{{realm}}.cia.enfuce.com/instalment
  - url: https://integration-api-cat2.live.ext.prod.cia.enfuce.com/instalment
    description: Live environment
security:
  - basicAuth: []
paths:
  /v1:
    post:
      tags:
        - Instalment Operations
      summary: Create an instalment
      description: This operation will create an instalment plan
      operationId: createInstalment
      parameters:
        - $ref: '#/components/parameters/AuditUser'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/createInstalmentRequest'
            examples:
              BUY_NOW_PAY_LATER:
                $ref: '#/components/examples/TransactionBNPLExample'
              INTEREST_FREE:
                $ref: '#/components/examples/TransactionInterestFreeExample'
              FIXED_INTEREST:
                $ref: '#/components/examples/TransactionFixedInterestExample'
      responses:
        '201':
          description: Successful creation of an instalment
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/resourceResponse'
        '400':
          $ref: '#/components/responses/error400'
        '401':
          $ref: '#/components/responses/error401'
        '403':
          $ref: '#/components/responses/error403'
        '404':
          $ref: '#/components/responses/InstalmentNotFoundError'
        '409':
          $ref: '#/components/responses/InstalmentAlreadyExistsError'
        '500':
          $ref: '#/components/responses/error500'
      deprecated: false
components:
  parameters:
    AuditUser:
      name: auditUser
      in: query
      description: The audit user to log the request
      required: true
      schema:
        type: string
  schemas:
    createInstalmentRequest:
      type: object
      required:
        - from
        - transactionId
        - planOptions
      properties:
        from:
          type: string
          example: TRANSACTION
          enum:
            - TRANSACTION
          description: The source type for the instalment.
        description:
          $ref: '#/components/schemas/description'
        transactionId:
          $ref: '#/components/schemas/transactionId'
          description: Transaction that will be converted into instalments
        planOptions:
          $ref: '#/components/schemas/planOptions'
    resourceResponse:
      type: object
      properties:
        description:
          type: string
          description: Short description of the result of the action
        id:
          type: string
          description: Will contain the ID of the resource that has been created or updated
      title: resourceResponse
    description:
      type: string
      maxLength: 255
      description: Optional text describing the instalment request
      example: 'Instalment for product #4567'
    transactionId:
      type: string
      format: biginteger
      example: '8767653'
    planOptions:
      type: object
      required:
        - type
      properties:
        type:
          $ref: '#/components/schemas/InstalmentPlanType'
      discriminator:
        propertyName: type
        mapping:
          BUY_NOW_PAY_LATER:
            $ref: '#/components/schemas/BNPLOptions'
          INTEREST_FREE:
            $ref: '#/components/schemas/InterestFreeOptions'
          FIXED_INTEREST:
            $ref: '#/components/schemas/FixedInterestOptions'
      oneOf:
        - $ref: '#/components/schemas/BNPLOptions'
        - $ref: '#/components/schemas/InterestFreeOptions'
        - $ref: '#/components/schemas/FixedInterestOptions'
    errorResponse-2:
      type: object
      properties:
        code:
          type: string
          description: An error code indicating what kind of error. I.e. HTTP error code
        message:
          type: string
          description: Error message in human-readable format
        id:
          type: string
          format: uuid
          description: Unique error identifier
        errorCode:
          type: string
          description: Enfuce code for a specific error type
        errorType:
          type: string
          description: Error type
          enum:
            - STATIC_VALIDATION_ERROR
            - DYNAMIC_VALIDATION_ERROR
            - INTEGRATION_ERROR
            - SECURITY_ERROR
            - UNEXPECTED_ERROR
        errorReason:
          type: string
          description: Free-form text explaining the error reason
        timestamp:
          type: string
          format: date-time
          description: Datetime when error occurred
    errorResponse:
      type: object
      properties:
        code:
          type: string
          description: An error code indicating what kind of error. I.e. HTTP error code
        message:
          type: string
          description: Error message in human-readable format
        id:
          type: string
          format: uuid
          description: Unique error identifier
        errorCode:
          type: string
          description: Enfuce code for a specific error type
          enum:
            - INSTALMENT_API_ERROR
            - INSTALMENT_API-ACCOUNT_NOT_FOUND
            - INSTALMENT_API-TRANSACTION_NOT_FOUND
            - INSTALMENT_API-ALREADY_EXIST
            - INSTALMENT_API-INSTALMENT_NOT_FOUND
            - INSTALMENT_API-INVALID_TENOR
            - INSTALMENT_API-INSTALMENT_CANNOT_BE_CLOSED
            - INSTALMENT_API-ALREADY_CLOSED
            - INSTALMENT_API-REVISED_INSTALMENT_CANNOT_BE_CLOSED
            - INSTALMENT_API-TRANSACTION_TYPE_NOT_ALLOWED
            - INSTALMENT_API-INVALID_VALUE
            - INSTALMENT_API-INVALID_ENUM_VALUE
            - INSTALMENT_API-INVALID_TYPE
            - INSTALMENT_API-VALUE_OUT_OF_RANGE
        errorType:
          type: string
          description: Error type
          enum:
            - STATIC_VALIDATION_ERROR
            - DYNAMIC_VALIDATION_ERROR
            - INTEGRATION_ERROR
            - SECURITY_ERROR
            - UNEXPECTED_ERROR
        errorReason:
          type: string
          description: Free-form text explaining the error reason
        timestamp:
          type: string
          format: date-time
          description: Datetime when error occurred
    InstalmentPlanType:
      type: string
      enum:
        - BUY_NOW_PAY_LATER
        - INTEREST_FREE
        - FIXED_INTEREST
      description: The type of instalment plan.
    BNPLOptions:
      title: BUY_NOW_PAY_LATER
      description: The `paymentPlan.type` field should be BUY_NOW_PAY_LATER.
      type: object
      required:
        - shift
      properties:
        shift:
          type: integer
          example: 2
          description: >-
            The number of months for which the plan is shifted. Must be in range
            [0..24]
    InterestFreeOptions:
      allOf:
        - $ref: '#/components/schemas/BaseInterestOptions'
      title: INTEREST_FREE
      description: The `paymentPlan.type` field should be INTEREST_FREE.
    FixedInterestOptions:
      required:
        - interest
      allOf:
        - $ref: '#/components/schemas/BaseInterestOptions'
      title: FIXED_INTEREST
      description: The `paymentPlan.type` field should be FIXED_INTEREST.
      properties:
        interest:
          type: number
          description: The interest rate
    BaseInterestOptions:
      required:
        - paymentPlan
      properties:
        paymentPlan:
          type: object
          required:
            - type
            - value
          properties:
            type:
              $ref: '#/components/schemas/PaymentType'
            value:
              type: number
              format: big-decimal
              minimum: 0
              exclusiveMinimum: true
              description: >-
                The actual plan value, format depends on the type. Must be in
                range for TENOR: [2..180], and PORTION: [0.01..100 000]
    PaymentType:
      type: string
      enum:
        - TENOR
        - PORTION
      description: Type of payment plan.
  examples:
    TransactionBNPLExample:
      summary: Instalment from transaction - BNPL
      value:
        from: TRANSACTION
        transactionId: '12345678'
        description: Buy now, pay in 2 months
        planOptions:
          type: BUY_NOW_PAY_LATER
          shift: 2
    TransactionInterestFreeExample:
      summary: Instalment from transaction - Interest Free
      value:
        from: TRANSACTION
        transactionId: '12345678'
        description: Interest Free with 3 payments
        planOptions:
          type: INTEREST_FREE
          paymentPlan:
            type: TENOR
            value: 3
    TransactionFixedInterestExample:
      summary: Instalment from transaction - Fixed interest
      value:
        from: TRANSACTION
        transactionId: '12345678'
        description: Fixed interest
        planOptions:
          type: FIXED_INTEREST
          interest: 9.9
          paymentPlan:
            type: PORTION
            value: 12.2
  responses:
    error400:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/errorResponse-2'
    error401:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/errorResponse'
    error403:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/errorResponse'
    InstalmentNotFoundError:
      description: Instalment not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/errorResponse'
    InstalmentAlreadyExistsError:
      description: Instalment already exists for given transaction
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/errorResponse'
    error500:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/errorResponse'
  securitySchemes:
    basicAuth:
      type: http
      description: >-
        Basic authentication is used to authenticate towards Enfuce API. It is
        described in more detail in RFC 7617.
      scheme: basic

````