> For the complete documentation index, see [llms.txt](https://apidocs.d6plus.co.za/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs.d6plus.co.za/reference/finance+/debt-management/get-schools.md).

# Get Schools

## Retrieve debtor financial transactions

<mark style="color:blue;">`GET`</mark> `https://integrate.d6plus.co.za/api/v1/finplus/debtmanagement/schools/{school_login_id}`

Use this endpoint to fetch schools and their details. The inclusion of the `/{school_login_id}` is optional and if it is not included, all schools will be returned.

#### Path Parameters

<table><thead><tr><th width="247">Name</th><th width="102">Type</th><th>Description</th></tr></thead><tbody><tr><td>school_login_id<mark style="color:red;">*</mark></td><td>Integer</td><td>The login ID of the school to retrieve data from (optional)</td></tr></tbody></table>

#### Headers

| Name                                              | Type   | Description       |
| ------------------------------------------------- | ------ | ----------------- |
| HTTP-X-USERNAME<mark style="color:red;">\*</mark> | String | As provided by d6 |
| HTTP-X-PASSWORD<mark style="color:red;">\*</mark> | String | As provided by d6 |

#### Response Examples

{% tabs %}
{% tab title="200 The request was successful." %}

```json
[
    {
        "school_id": "1000",
        "school_name": "d6+ Primary School",
        "school_short_name": "primary",
        "ownership_type": "Public",
        "country": "South Africa",
        "province": "Gauteng",
        "town": "Pretoria",
        "suburb": "Waterkloof Glen",
        "district": "METRO EAST",
        "district_code": "D1",
        "circuit": "Circuit 2",
        "quantile": "4",
        "emis_number": "600000001",
        "telephone_number": "0123334444",
        "lowest_grade": "Grade R",
        "highest_grade": "Grade 7",
        "admin_email_address": "info@d6.co.za",
        "debtors_email_address": "accounts@d6.co.za",
        "finance_email_address": "accounts@d6.co.za",
        "physical_address": "Spaces Building, Floor 3,/r/n210 Amarand Ave,/r/nWaterkloof Glen,/r/nPretoria,/r/n0010",
        "postal_address": "Spaces Building, Floor 3,/r/n210 Amarand Ave,/r/nWaterkloof Glen,/r/nPretoria,/r/n0010",
        "has_after_school_center": "Yes",
        "has_hostel": "No",
        "uses_debit_orders": "No",
        "uses_cashless": "Yes"
    },
    {
        "school_id": "1001",
        "school_name": "d6+ Secondary School",
        "school_short_name": "secondary",
        "ownership_type": "Public",
        "country": "South Africa",
        "province": "Western Cape",
        "town": "Stellenbosch",
        "suburb": "Techno Park",
        "district": "CAPE WINELANDS",
        "district_code": "D1",
        "circuit": "Circuit 10",
        "quantile": "5",
        "emis_number": "600000002",
        "telephone_number": "0213337654",
        "lowest_grade": "Grade 8",
        "highest_grade": "Grade 12",
        "admin_email_address": "info@d6.co.za",
        "debtors_email_address": "accounts@d6.co.za",
        "finance_email_address": "accounts@d6.co.za",
        "physical_address": "Octo Place, Block B\r\nElektron Road\r\nTechno Park\r\nStellenbosch\r\n7600",
        "postal_address": "Octo Place, Block B\r\nElektron Road\r\nTechno Park\r\nStellenbosch\r\n7600",
        "has_after_school_center": "No",
        "has_hostel": "Yes",
        "uses_debit_orders": "Yes",
        "uses_cashless": "No"
    }
]
```

{% endtab %}

{% tab title="200 Including Learners" %}

```json
[
    {
        "accountable_person_id": "40",
        "title": "Mr",
        "first_name": "John",
        "full_names": "John James",
        "last_name": "Smith",
        "debtor_code": "1001",
        "mobile_calling_code": "27",
        "mobile_number": "0821237654",
        "work_tel_number": "0124567890",
        "home_tel_number": "0123214567",
        "email_address": "jjsmith@example.com",
        "residential_address": "Moneytow Street\r\nNow Village\r\n0123\r\nSouth Africa",
        "postal_address": "Moneytow Street\r\nNow Village\r\n0123\r\nSouth Africa",
        "home_language": "English",
        "nationality": "South Africa",
        "id_number": "8104050240082",
        "passport_number": "A456732243",
        "employer": "Greenholt Group",
        "employer_address": "3 School Lane\r\nBig City\r\nSouth Africa",
        "account_closing_date": "0000-00-00",
        "account_start_date": "2023-01-01",
        "learners": [
            {
                "learner_id": "1",
                "first_name": "John",
                "last_name": "Smith",
                "gender": "M",
                "grade": "7"
            }
        ]
    },
    {
        "accountable_person_id": "3",
        "title": "Mr",
        "first_name": "Nic",
        "full_names": "Nicholas Nigel",
        "last_name": "Webster",
        "debtor_code": "1002",
        "mobile_calling_code": "27",
        "mobile_number": "0678901234",
        "work_tel_number": "",
        "home_tel_number": "",
        "email_address": "nicnwebster@example.co.za",
        "residential_address": "7th Street\r\nSmall Town\r\n0123\r\nSouth Africa",
        "postal_address": "7th Street\r\nSmall Town\r\n0123\r\nSouth Africa",
        "home_language": "English",
        "nationality": "South Africa",
        "id_number": "",
        "passport_number": "",
        "employer": "",
        "employer_address": "",
        "account_closing_date": "0000-00-00",
        "account_start_date": "2023-01-01",
        "learners": [
            {
                "learner_id": "51",
                "first_name": "Michelle",
                "last_name": "Webster",
                "gender": "F",
                "grade": "3"
            }
        ]
    }
]
```

{% endtab %}

{% tab title="204: No Content" %}

```json
```

{% endtab %}

{% tab title="401: Unauthorized The server understood the request, but is refusing it or access is not allowed." %}

```json
{
    "error": "Unauthorized",
    "error_description": "Client access not authorised"
}
```

{% endtab %}

{% tab title="403: Forbidden The server understood the request, but the requested action is not allowed." %}

```json
{
    "error": "Integration not activated",
    "error_description": "Please activate the Finance+ API for this client before making this request"
}
```

{% endtab %}
{% endtabs %}

## Code Samples

{% tabs %}
{% tab title="PHP" %}

```php
<?php

const BASE_URL = 'https://integrate.d6plus.co.za/api/v1/finplus/debtmanagement/schools';
const SCHOOL_LOGIN_ID = '1000';
const API_USERNAME = getenv('API_USERNAME'); // Assuming you have these environment variables set
const API_PASSWORD = getenv('API_PASSWORD');

$curl = curl_init();

$query = http_build_query(PARAMS);

$options = [
    CURLOPT_URL => BASE_URL . '/' . SCHOOL_LOGIN_ID,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => [
        "HTTP-X-USERNAME: " . API_USERNAME,
        "HTTP-X-PASSWORD: " . API_PASSWORD
    ],
];

curl_setopt_array($curl, $options);

$response = curl_exec($curl);

if (curl_errno($curl)) {
    throw new Exception('Curl error: ' . curl_error($curl));
}

curl_close($curl);

echo $response;
```

{% endtab %}

{% tab title="cURL" %}

```bash
curl --location 'https://integrate.d6plus.co.za/api/v1/finplus/debtmanagement/schooldebtors/1000?all_persons=1' \
--header 'HTTP-X-USERNAME: your_username' \
--header 'HTTP-X-PASSWORD: your_password'
```

{% endtab %}
{% endtabs %}
