# Create application

&#x20;To create an application, you must send it json to the appropriate URL. By filling in json requisite in accordance to which template the application belongs

**method:** POST

**url:** <https://ninjalender.online/client/loan/create&#x20>;

**Headers:**

| header key     | header content    |
| -------------- | ----------------- |
| Content-Type:  | application/json; |
| Authorization: | Bearer AToken;    |

\
&#x20;Where AToken is the token that was received during authorization. &#x20;

**Request body:**

| Key    | Type        | Required | Description        |
| ------ | ----------- | -------- | ------------------ |
| params | JSON.object | +        | Request parameters |

&#x20;**params:**

| Key            | Type        | Required | Description                                                                                                                                                                    |
| -------------- | ----------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| amount         | number      | +        | application amount                                                                                                                                                             |
| price\_min     | number      | +        | minimal price of application                                                                                                                                                   |
| price          | number      | +        | price                                                                                                                                                                          |
| term           | string      | +        | term of loan (in seconds)                                                                                                                                                      |
| template       | int         | +        | Loan template from the templates that owned by the organization                                                                                                                |
| requisites     | JSON.object | +        | Requisites of the application. keys are copied from the template body. As a value, an object is transmitted with the value key in which the value of the attribute is written. |
| refuse\_reason | int         | +        | Refuse reason                                                                                                                                                                  |
| purpose        | int         | +        | Loan purpose                                                                                                                                                                   |
| refuse\_date   | DateTime    | -        | Refuse date in format (Y-m-d h:i:s) converted to UTC+0 timozone for the correct calculation of the freshness of the application                                                |

&#x20;Example of filing application requisites by "Customer Loan Basic" template

| Key                               | Type   | Variants | Required | Description | Visible    |
| --------------------------------- | ------ | -------- | -------- | ----------- | ---------- |
| borrower\_personal\_code          | string |          | +        |             | only owner |
| borrower\_first\_name             | string |          | +        |             | only owner |
| borrower\_last\_name              | string |          | +        |             | only owner |
| borrower\_phone                   | string |          | +        |             | only owner |
| borrower\_email                   | string |          | +        |             | only owner |
| borrower\_address                 | string |          | +        |             | only owner |
| borrower\_monthly\_income\_amount | string |          | +        |             |            |
| borrower\_monthly\_income\_source | string |          | +        |             |            |

**response:**

| Key     | Type       | Description   |
| ------- | ---------- | ------------- |
| code    | int        | Response code |
| message | string     | Message       |
| data    | JSON.array | Response data |
| data.id | int        | id of loan    |

&#x20;**Request example:**

```
{
  "params": {
    "amount": 1000,
    "price_min": 100,
    "price": 150,
    "term": 86400,
    "template": 26,
    "refuse_reason": 12,
    "requisites": {
      "borrower_personal_code": {
        "value": "some_borrower_personal_code"
      },
      "borrower_first_name": {
        "value": "some_borrower_first_name"
      },
      "borrower_last_name": {
        "value": "some_borrower_last_name"
      },
      "borrower_phone": {
        "value": "some_borrower_phone"
      },
      "borrower_email": {
        "value": "some_borrower_email"
      },
      "borrower_address": {
        "value": "some_borrower_address"
      },
      "borrower_monthly_income_amount": {
        "value": "some_borrower_monthly_income_amount"
      },
      "borrower_monthly_income_source": {
        "value": "some_borrower_monthly_income_source"
      }
    }
  }
}
```

&#x20;**Response example:**

```
[
  {
    "code": 0,
    "message": "ok",
    "data": {
      "id": "1278"
    }
  }
]
```

&#x20;**List of errors:**

| Key      | Message                                            |
| -------- | -------------------------------------------------- |
| -99      | System error! Try again later or contact us        |
| -98      | Expired token                                      |
| -2000001 | Invalid token                                      |
| -2040601 | Params is required                                 |
| -2040602 | Refuse reason not found                            |
| -2040603 | refuse reason must not be blank                    |
| -2040604 | loan purpose must not be blank                     |
| -2040605 | loan purpose not found                             |
| -2040606 | Template must not be blank                         |
| -2040607 | Template not found                                 |
| -2040608 | Cant use inactive template                         |
| -2040609 | Cant use not moderated template                    |
| -2040610 | Cant use global template                           |
| -2040611 | Cant use template of other organization            |
| -2040612 | Refuse date expected date                          |
| -2040613 | requisite needed                                   |
| -2040614 | requisite must not be blank                        |
| -2040615 | requisite not valid. Expected date in format Y-m-d |
| -2040616 | requisite not valid. Expected number               |
| -2040617 | requisite not valid. Expected one of               |
| -2040618 | requisite not valid. Expected boolean              |
| -2040619 | Requisites not presented in template               |
| -2040620 | Need "value" param in requisite                    |
| -2040621 | mime type is unsupported                           |
| -2040622 | max file size exceeded                             |
| -2040623 | Amount must be >0                                  |
| -2040624 | Amount must be a number                            |
| -2040625 | Price min must be >0                               |
| -2040626 | Price min must be a number                         |
| -2040627 | Price min must be <= price                         |
| -2040628 | Price must be >0                                   |
| -2040629 | Price must be a number                             |
| -2040630 | Term must be >0                                    |
| -2040631 | Term must be in seconds                            |
| -2040632 | Amount must not be blank                           |
| -2040633 | Price min must not be blank                        |
| -2040634 | Price must not be blank                            |
| -2040635 | Term must not be blank                             |
| -2040636 | Cant change stage. AUCTION in progress             |
| -2040637 | Loan is not unique                                 |
| -2040638 | Loan is not fresh                                  |
| -2040639 | Cant change stage                                  |
| -2040640 | refuse\_reason must be numeric                     |
| -2040641 | purpose must be numeric                            |
| -2040642 | template must be numeric                           |
