# Sale of applications

To send a loan application to the Ninja Lender system, you must do the following:

1. [Log in](/ninja-lender-v2-api-en/authorization.md) to the system and get a token, which will be used in all subsequent requests.
2. Get the reference [“Loan Purpose”](/ninja-lender-v2-api-en/seller/untitled.md) and [“Refuse Reason”](/ninja-lender-v2-api-en/seller/getting-handbook-refuse-reason.md), as the data from these directories is used when loading applications into the system.
3. Get the body of the [template](/ninja-lender-v2-api-en/seller/getting-template.md) on the basis of which the application will be filled with requisites.
4. Create an application and [send ](/ninja-lender-v2-api-en/seller/application-upload.md)it in.

Example: We have a loan application where the borrower requests 10,000 for 30 days to buy household appliances, but we can’t give out a loan due to discrepancy with age restrictions.

To begin with, we find the necessary loan purpose (in the example below, this is the purpose with "id": "2")

```
{
    "code": 0,
    "message": "ok",
    "data": [
        {
            "id": 1,
            "label": "health_care",
            "title": "Health care"
        },
        {
            "id": 2,
            "label": "other_purchases",
            "title": "Other purchases"
        },
        {
            "id": 3,
            "label": "debt_restructuring",
            "title": "Debt restructuring"
        }
    ],
    "log_key": 750
}
```

and refuse reason (in the example below, this is the reason with "id": "4")

```
{
    "code": 0,
    "message": "ok",
    "data": [
        {
            "id": 1,
            "label": "auto_scoring",
            "title": "Auto scoring"
        },
        {
            "id": 2,
            "label": "unstable_income",
            "title": "Unstable income"
        },
        {
            "id": 3,
            "label": "low_income",
            "title": "Low Income"
        },
        {
            "id": 4,
            "label": "age_criteria",
            "title": "Age criteria"
        }
    ],
    "log_key": 750
}
```

Next we get the body of the template

```
{
    "code": 0,
    "message": "ok",
    "data": {
        "body": {
            "age": {
                "id": "4",
                "kind": 2,
                "type": 0,
                "label": "age",
                "required": true,
                "variants": null,
                "description": null,
                "title": "Age"
            },
            "income": {
                "id": "5",
                "kind": 2,
                "type": 0,
                "label": "income",
                "required": true,
                "variants": null,
                "description": null,
                "title": "Income"
            },
            "marital_status": {
                "id": "14",
                "kind": 5,
                "type": 0,
                "label": "marital_status",
                "required": false,
                "variants": [
                    {
                        "label": "married",
                        "title": "married"
                    },
                    {
                        "label": "single",
                        "title": "single"
                    },
                    {
                        "label": "widowed",
                        "title": "widowed"
                    },
                    {
                        "label": "divorced",
                        "title": "divorced"
                    }
                ],
                "description": null,
                "title": "Marital status"
            }
            
        },
        "id": 20,
        "label": "1-8test",
        "description": null,
        "title": "1-8test"
    },
    "log_key": 757
}
```

And we proceed to compile JSON to upload the application. To begin, fill in the amount, the minimum amount, the term, the cause of failure, purpose of the loan and what template we use for application

```
{
    "params": {
        "amount": "10000",
        "price_min": "10",
        "term": "864000",
        "refuse_reason": 4,
        "purpose": 2,
        "template": "4"
        "requisites": {
           
        },
        
    }
}
```

Now we need to fill in the details of the application based on the body of the template. Each requisite in the body is described by a JSON object, where the object key is the name (key) of the requisite, and a description of the requisite contained in the value.

Example of requisite from the template body:

| Key         | Type       | Description                                                                                                                                                                                                                                                                                                                                                  |
| ----------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| id          | int        | id of requisite                                                                                                                                                                                                                                                                                                                                              |
| kind        | int        | <p>Kind of requisite, defines data type for requisite value:</p><p>0 – string</p><p>1 – text</p><p>2 – number</p><p>3 – date</p><p>4 – boolean</p><p>5 – handbook(in the case of this kind, the system will expect, as the value requisite, one of the elements from the variants array)<br>6 - phone in international format<br>7 - valid email address</p> |
| label       | string     | requisite name                                                                                                                                                                                                                                                                                                                                               |
| required    | boolean    | is requisite required                                                                                                                                                                                                                                                                                                                                        |
| variants    | JSON.array | list of variants for handbook kind requisites                                                                                                                                                                                                                                                                                                                |
| description | string     | description of requisite                                                                                                                                                                                                                                                                                                                                     |
| title       | string     | requisite title                                                                                                                                                                                                                                                                                                                                              |

```
{
    "params": {
        "amount": "10000",
        "price_min": "10",
        "term": "864000",
        "refuse_reason": 4,
        "purpose": 2,
        "template": "4"
        "requisites": {
           "age":"",
           "income":"",
           "marital_status":""
        },
        
    }
}
```

We fill in the requisites according to their types

```
{
    "params": {
        "amount": "10000",
        "price_min": "10",
        "term": "864000",
        "refuse_reason": 4,
        "purpose": 2,
        "template": "4"
        "requisites": {
           "age":"55",
           "income":"10000",
           "marital_status":"single"
        },
        
    }
}
```

Now the JSON of application is ready and it can be uploaded to the system.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ninja-lender.gitbook.io/ninja-lender-v2-api-en/sale-of-applications.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
