Get credit scorecard
curl --request GET \
--url https://api-staging.bsa.ai/v1/credit-scorecard/{external_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api-staging.bsa.ai/v1/credit-scorecard/{external_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api-staging.bsa.ai/v1/credit-scorecard/{external_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-staging.bsa.ai/v1/credit-scorecard/{external_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-staging.bsa.ai/v1/credit-scorecard/{external_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api-staging.bsa.ai/v1/credit-scorecard/{external_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-staging.bsa.ai/v1/credit-scorecard/{external_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"externalId": "<string>",
"halopesaGrade": "<string>",
"finalCreditScore": 123,
"finalCreditLimit": 123,
"totalOutstanding": 123,
"totalPaid": 123,
"availableCreditLimit": 123,
"executionPeriod": "<string>"
}Credit Scoring
Get credit scorecard
Fetch the current credit profile for a customer by externalId.
GET
/
v1
/
credit-scorecard
/
{external_id}
Get credit scorecard
curl --request GET \
--url https://api-staging.bsa.ai/v1/credit-scorecard/{external_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api-staging.bsa.ai/v1/credit-scorecard/{external_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api-staging.bsa.ai/v1/credit-scorecard/{external_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-staging.bsa.ai/v1/credit-scorecard/{external_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-staging.bsa.ai/v1/credit-scorecard/{external_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api-staging.bsa.ai/v1/credit-scorecard/{external_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-staging.bsa.ai/v1/credit-scorecard/{external_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"externalId": "<string>",
"halopesaGrade": "<string>",
"finalCreditScore": 123,
"finalCreditLimit": 123,
"totalOutstanding": 123,
"totalPaid": 123,
"availableCreditLimit": 123,
"executionPeriod": "<string>"
}Returns the customer’s current credit grade, score, and pre-approved
loan limit as held by the HaloPesa credit scoring engine. The lookup
key is the same
Branch on
externalId you set on the customer record — so
once you’ve created a customer, scoring and lending share one
identifier.
This endpoint is read-only — it has no side effects (no SMS, no
database write).
Path parameters
The customer’s partner-supplied
externalId (the same value you sent
on POST /v1/customers). 1–128 characters; URL-encode if it contains
special characters.Example
curl -sf "$BASE/v1/credit-scorecard/partner-key-1779709585" \
-H "Authorization: Bearer $TOKEN"
Response
200 OK
{
"externalId": "partner-key-1779709585",
"halopesaGrade": "C",
"finalCreditScore": 500,
"finalCreditLimit": 5000.0,
"totalOutstanding": 0.0,
"totalPaid": 0.0,
"availableCreditLimit": 5000.0,
"executionPeriod": "0.01 seconds"
}
Fields
Pre-approved ceiling in TZS as set by the scoring engine.
0 for
unscored customers. This is the raw upstream value — it doesn’t
account for any current debt.Sum of
summary.totalOutstanding across every disbursed loan the
customer holds in the LMS (a loan that is still submitted or approved
lent nothing and is not counted). 0 if the customer has no loans or
doesn’t exist in the LMS yet. Omitted (together with totalPaid and
availableCreditLimit) when the LMS cannot be read at that moment:
an unknown position is never reported as 0, because 0 would mean
the customer owes nothing. If the field is absent, retry, or treat the
customer as not eligible until it is present. The scoring fields are
still returned.Sum of
summary.totalRepayment across every loan the customer
holds — total amount paid in over the lifetime of the customer’s
loans (principal + interest + fees + penalty). Omitted whenever
totalOutstanding is.Computed. What the customer can borrow right now:
finalCreditLimit when the customer has no active loan and
totalOutstanding == 0, otherwise 0. The binary rule means any
active obligation locks the customer out of new credit — partial
top-ups against existing debt aren’t allowed. A loan that was never
disbursed does not count. This is exactly the figure
loan creation enforces.
Omitted whenever totalOutstanding is: do not offer a loan on a
response without this field.Unscored customers
A customer with no scoring record yet is not an error. The upstream returns200 OK with sentinel values so the USSD layer always has
something to render:
{
"externalId": "no-such-customer",
"halopesaGrade": "XX",
"finalCreditScore": 100,
"finalCreditLimit": 0.0,
"totalOutstanding": 0.0,
"totalPaid": 0.0,
"availableCreditLimit": 0.0,
"executionPeriod": "0.00 seconds"
}
halopesaGrade == "XX" to detect “unscored”. Use
availableCreditLimit > 0 to decide whether a new loan can be
offered — that folds in both the scoring result and the LMS debt
state in one check — and treat a response without
availableCreditLimit as “cannot decide right now”.
Loan creation enforces the same figure: a
principal above availableCreditLimit is refused with
credit_limit_exceeded, so an offer built on this response cannot be
exceeded even if the customer’s position changes in between.
Errors
| Code | When |
|---|---|
invalid_argument | external_id path segment is empty |
unauthenticated | Your token is missing, invalid or expired — refresh it and retry once |
unavailable | The credit scoring service is unreachable, rejected the API’s own credentials, or is serving a different contract. Nothing on your side is wrong and refreshing your token will not help; retry with backoff, and if it persists the BSA team is already paged |
internal | The credit scoring service returned an unhandled error |

