# Risk scoring

The **`risk score`**  has been designed to measure the likelihood of a customer (individual or business) to default on credit. The underlying scorecard is built using statistical judgment model built from credit risk metrics, all of which are extracted from transaction data.

&#x20;The **`payability score`** quantifies the near-term funds available to a customer. It quantifies the probability to determine a customer’s capacity to repay credit by analysing how likely a customer’s account balance will hit zero within 90 days, inferred from modelling a customer’s balance history.

{% hint style="warning" %}
For the best risk scoring results, insert at least 3 months of transaction history of your customer
{% endhint %}

### Scoring requires transaction data

For us to calculate a risk score of your customer, we need transaction data from their bank account, wallet and or POS in the case of SMEs.

#### Example Transactions Object schema required:

```javascript
{
  "transactions": [
    {
      "external_transaction_id": "958d14298-91ee-405d-89da-248c30eaf0e81-pending",
      "type": "debit",
      "amount": -255,
      "currency": "ZAR",
      "status": "Approved",
      "account_name": "Capitec-bank",
      "account_number": "123-123-123",
      "balance": {
        "amount": 12105,
        "currency": "ZAR",
        "type": "ClosingAvailable"
      },
      "date_time": 1774672448
    },
    {
      "external_transaction_id": "958d14298-91ee-405d-89da-248c30eaf0e81-pending",
      "type": "debit",
      "amount": -100,
      "currency": "ZAR",
      "status": "Approved",
      "account_name": "Capitec-bank",
      "account_number": "123-123-123",
      "balance": {
        "amount": 12005,
        "currency": "ZAR",
        "type": "ClosingAvailable"
      },
      "date_time": 1574672448
    }
    ]
}
```

## Upload customer transaction data for scoring

<mark style="color:green;">`POST`</mark> `https://api.akibadigital.com/v1/scoring`

#### Headers

| Name                                           | Type   | Description       |
| ---------------------------------------------- | ------ | ----------------- |
| Token<mark style="color:red;">\*</mark>        | String | Access auth Token |
| Content-Type<mark style="color:red;">\*</mark> | String | application/json  |

#### Request Body

| Name                                                  | Type   | Description                                            |
| ----------------------------------------------------- | ------ | ------------------------------------------------------ |
| customer\_reference<mark style="color:red;">\*</mark> | String | your custom reference of the customer i.e phone number |
| transactions<mark style="color:red;">\*</mark>        | Object | transaction object similar to example provided above   |
| customer\_type<mark style="color:red;">\*</mark>      | String | `1` for individual and `2` for business                |
| webhook\_url                                          | String |                                                        |

{% tabs %}
{% tab title="200: OK Successful " %}

```javascript
{
    "score": 0.2964672868854194,
    "income_volatility": 0.675, 
    "balance_variability": 0.123, 
    "payability_score": 0.814060422422,
    "confidence": 0.8730592042
}
```

{% endtab %}
{% endtabs %}

## Returns risk score of your individual or business customer&#x20;

<mark style="color:blue;">`GET`</mark> `https://api.akibadigital.com/v1/scoring/{customer_id}/`

#### Headers

| Name                                           | Type   | Description      |
| ---------------------------------------------- | ------ | ---------------- |
| Token<mark style="color:red;">\*</mark>        | String |                  |
| Content-Type<mark style="color:red;">\*</mark> | String | application/json |

{% tabs %}
{% tab title="404: Not Found Customer not founder " %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="403: Forbidden Customer has no bank data" %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="400: Bad Request Insert valid customer\_id" %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="200: OK Risk score successfully retrieved" %}

```javascript
{
    "score": 0.2964672868854194,
    "income_volatility": 0.675, 
    "balance_variability": 0.123, 
    "payability_score": 0.814060422422,
    "confidence": 0.8730592042
}
```

{% endtab %}

{% tab title="204: No Content Customer's risk score not yet available" %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}


---

# 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://akiba-digital.gitbook.io/akiba-api-docs/api-documentation/risk-analysis/risk-scoring.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.
