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

# Create repayment plan

> Adds a new repayment plan and its commission rates in one operation.

* The bank account's `AccountType` must be 3 (POS account), otherwise the request is rejected.
* `Name` is required and must be unique within the bank account.
* `DayCount` cannot be negative.
* `CommissionRates` is optional; each entry requires `Name` (unique within the plan), `Rate` (percentage, 0-100) and `ExpenseCode` (the code of a product with ProductType 6/Expense). Commission rates are written in the same transaction as the plan.

## Error codes

Codes this endpoint can return. The [general errors](/en/v1/guides/result-codes) that apply to every endpoint (authentication, permissions, request headers, daily limit) are not repeated here.

| Code   | HTTP | Meaning                                                                                                                                                               |
| ------ | ---- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `0002` | 400  | Request body could not be read (malformed JSON, wrong field type)                                                                                                     |
| `0003` | 400  | A field exceeds its maximum length (the message names the field and the limit)                                                                                        |
| `0580` | 400  | A value given as text (a code or a name) matches more than one record; add the detail that tells them apart (for example `City` for a district, `Country` for a city) |
| `8010` | 404  | Bank account not found                                                                                                                                                |
| `8021` | 400  | Repayment plan `Name` is required                                                                                                                                     |
| `8022` | 400  | The repayment plan name is already used in this bank account                                                                                                          |
| `8023` | 400  | `DayCount` cannot be negative                                                                                                                                         |
| `8024` | 400  | A repayment plan can only be added to a POS account (AccountType 3)                                                                                                   |
| `8031` | 400  | Commission rate `Name` is required                                                                                                                                    |
| `8032` | 400  | The commission rate name is used more than once in the same repayment plan                                                                                            |
| `8033` | 400  | `Rate` must be between 0 and 100                                                                                                                                      |
| `8034` | 400  | `ExpenseCode` is required                                                                                                                                             |
| `8035` | 400  | `ExpenseCode` was not found                                                                                                                                           |


## OpenAPI

````yaml api-reference/openapi.json POST /api/v1/finance/bank-accounts/{bankAccountId}/repayment-plans
openapi: 3.1.1
info:
  title: Noyax API
  description: Server-to-server API for integrations to access Noyax data.
  version: '1.0'
servers:
  - url: https://dev.noyax.com/services/noyax_api
security:
  - Bearer: []
tags:
  - name: Sections
  - name: Warehouses
  - name: Quotes
  - name: Product Critical Stock
  - name: Product groups
  - name: Product Parameter Definitions
  - name: Product Parameters
  - name: Product Prices
  - name: Products
  - name: Orders
  - name: Bank Accounts
  - name: Bank Internal Transfers
  - name: Bank Openings
  - name: Banks
  - name: Bank Transfers
  - name: Credit Card Collections
  - name: Repayment Plans
  - name: Despatches
  - name: Cities
  - name: Countries
  - name: Currencies
  - name: Districts
  - name: Line Groups
  - name: Shipment Definitions
  - name: Units
  - name: VAT rates
  - name: Customer Addresses
  - name: Customer Bank Accounts
  - name: Customer Definitions
  - name: Customer Group Members
  - name: Customer Links
  - name: Customer Parameters
  - name: Customer Representatives
  - name: Customers
  - name: Customer Statement
  - name: Customer Telephones
paths:
  /api/v1/finance/bank-accounts/{bankAccountId}/repayment-plans:
    post:
      tags:
        - Repayment Plans
      summary: Create repayment plan
      description: >-
        Adds a repayment plan with its commission rates in one transaction. The
        bank account must be a POS account (AccountType 3).
      parameters:
        - name: bankAccountId
          in: path
          description: Bank account ID.
          required: true
          schema:
            type: string
            format: uuid
        - name: X-UserID
          in: header
          description: >-
            ID of the Noyax user the request is made on behalf of. Written to
            the audit fields of created, updated and deleted records.
          required: true
          schema:
            minimum: 1
            type: integer
            format: int32
        - name: X-CompanyID
          in: header
          description: >-
            ID of the company. The user must be assigned to this company. All
            reads and writes are limited to this company.
          required: true
          schema:
            minimum: 1
            type: integer
            format: int32
        - name: X-PeriodID
          in: header
          description: >-
            ID of the accounting period. Optional for customer endpoints; if
            sent, it is written to created records.
          schema:
            minimum: 1
            type: integer
            format: int32
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RepaymentPlanRequestDto'
          text/json:
            schema:
              $ref: '#/components/schemas/RepaymentPlanRequestDto'
          application/*+json:
            schema:
              $ref: '#/components/schemas/RepaymentPlanRequestDto'
        required: true
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataResultOfRepaymentPlanDto'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResult'
              example:
                Success: false
                ResultCode: '8024'
                Message: >-
                  Repayment plans can only be added to a POS account
                  (AccountType 3).
                Errors:
                  - Code: '8024'
                    Message: >-
                      Repayment plans can only be added to a POS account
                      (AccountType 3).
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResult'
              example:
                Success: false
                ResultCode: '0102'
                Message: Token has expired. Obtain a new token using the refresh token.
                Errors:
                  - Code: '0102'
                    Message: >-
                      Token has expired. Obtain a new token using the refresh
                      token.
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResult'
              example:
                Success: false
                ResultCode: '0110'
                Message: You do not have permission for this operation.
                Errors:
                  - Code: '0110'
                    Message: You do not have permission for this operation.
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResult'
              example:
                Success: false
                ResultCode: '0120'
                Message: Daily request limit (10000) exceeded.
                Errors:
                  - Code: '0120'
                    Message: Daily request limit (10000) exceeded.
components:
  schemas:
    RepaymentPlanRequestDto:
      type: object
      properties:
        Name:
          type:
            - 'null'
            - string
          description: Required. Unique within the bank account. At most 100 characters.
          example: 3 Taksit
        DayCount:
          type: integer
          description: Required. Number of days, cannot be negative.
          format: int32
          example: 90
        CommissionRates:
          type: array
          items:
            $ref: '#/components/schemas/CommissionRateRequestDto'
          description: >-
            Commission rates of this repayment plan. On update this list fully
            replaces the existing ones.
    DataResultOfRepaymentPlanDto:
      required:
        - Success
        - ResultCode
        - Data
      type: object
      properties:
        Success:
          type: boolean
          description: Whether the operation succeeded.
          example: true
        ResultCode:
          type: string
          description: >-
            "0000" on success. On failure, the code of the first error; all
            errors are listed in Errors.
          example: '0000'
        Message:
          type:
            - 'null'
            - string
          description: >-
            Error message when Success is false. Messages of all errors are
            joined into a single text.
        Data:
          $ref: '#/components/schemas/RepaymentPlanDto'
    ErrorResult:
      type: object
      properties:
        Success:
          type: boolean
          description: Whether the operation succeeded.
          example: false
        ResultCode:
          type:
            - 'null'
            - string
          description: >-
            "0000" on success. On failure, the code of the first error; all
            errors are listed in Errors.
        Message:
          type:
            - 'null'
            - string
          description: >-
            Error message when Success is false. Messages of all errors are
            joined into a single text.
        Errors:
          type:
            - 'null'
            - array
          items:
            $ref: '#/components/schemas/ResultError'
          description: All errors with their codes. Only present when Success is false.
    CommissionRateRequestDto:
      type: object
      properties:
        Name:
          type:
            - 'null'
            - string
          description: Required. Unique within the repayment plan. At most 100 characters.
          example: 3 Taksit
        Rate:
          type: number
          description: Required. Commission percentage, between 0 and 100.
          format: double
          example: 2.5
        ExpenseCode:
          type:
            - 'null'
            - string
          description: >-
            Required. Expense product code (a product with ProductType 6, not
            available through the product endpoints).
          example: MSR-0001
    RepaymentPlanDto:
      type: object
      properties:
        Id:
          type: string
          description: Repayment plan ID.
          format: uuid
        Name:
          type:
            - 'null'
            - string
          description: Required. Unique within the bank account. At most 100 characters.
          example: 3 Taksit
        DayCount:
          type: integer
          description: Required. Number of days, cannot be negative.
          format: int32
          example: 90
        CommissionRates:
          type: array
          items:
            $ref: '#/components/schemas/CommissionRateRequestDto'
          description: >-
            Commission rates of this repayment plan. On update this list fully
            replaces the existing ones.
    ResultError:
      required:
        - Code
        - Message
      type: object
      properties:
        Code:
          type: string
          description: Error code. See the result codes page for the full list.
        Message:
          type: string
          description: Error description.
  securitySchemes:
    Bearer:
      type: http
      description: Access token obtained from the Noyax auth service with your API key.
      scheme: bearer
      bearerFormat: JWT

````