> For the complete documentation index, see [llms.txt](https://akiba-digital.gitbook.io/akiba-api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://akiba-digital.gitbook.io/akiba-api-docs/api-documentation/risk-analysis/risk-scoring.md).

# Risk scoring

Calculates risk score and default score of an individual customer using transaction data

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 %}
