# Get Learner Parent Info

## Retrieve debtor financial transactions

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

Use this endpoint to fetch a school's learners and optionally include the parent info and the accountable person's details.

By default, only persons with active accounts (current learners or accounts with an outstanding balance) will be returned. You can use the `all_accounts` query parameter to fetch accountable persons for all accounts (includes left learners and 0 balance accounts).

To include parent info use the `include_parents` query parameter to include parent info in the response. For including the accountable person's details, use the `include_accountable_person` query parameter.

Optionally it is possible to filter on a specific `learner_id`, `debtor_code` or `accountable_person_id`. &#x20;

#### Path Parameters

<table><thead><tr><th width="258">Name</th><th width="134">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</td></tr></tbody></table>

#### Headers

<table><thead><tr><th width="265">Name</th><th width="121">Type</th><th>Description</th></tr></thead><tbody><tr><td>HTTP-X-USERNAME<mark style="color:red;">*</mark></td><td>String</td><td>As provided by d6</td></tr><tr><td>HTTP-X-PASSWORD<mark style="color:red;">*</mark></td><td>String</td><td>As provided by d6</td></tr></tbody></table>

#### Query Parameters

<table><thead><tr><th width="258">Name</th><th width="134">Type</th><th>Description</th></tr></thead><tbody><tr><td>learner_id</td><td>Integer</td><td>The ID of a specific learner</td></tr><tr><td>all_accounts</td><td>Boolean</td><td>Whether to include all accounts</td></tr><tr><td>include_parents</td><td>Boolean</td><td>Whether to include the parent data in the response</td></tr><tr><td>include_accountable_person</td><td>Boolean</td><td>Whether to include the accountable person's data in the response</td></tr><tr><td>learner_id</td><td>Integer</td><td>To filter on a specific Learner ID</td></tr><tr><td>debtor_code</td><td>Integer</td><td>To filter on a specific Debtor Code</td></tr><tr><td>accountable_person_id</td><td>Integer</td><td>To filter on a specific Accountable Person ID</td></tr></tbody></table>

#### Response Examples

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

```json
[
    {
        "learner_id": "1",
        "first_name": "John",
        "last_name": "Smith",
        "gender": "M",
        "grade": "7",
        "debtor_code": "1001",
        "parent1_id": "40",
        "parent2_id": "41",
        "accountable_person_id": "40"
    },
    {
        "learner_id": "2",
        "first_name": "Jane",
        "last_name": "Doe",
        "gender": "F",
        "grade": "5",
        "debtor_code": "1001",
        "parent1_id": "40",
        "parent2_id": "41",
        "accountable_person_id": "40"
    }
]
```

{% endtab %}

{% tab title="200 Including Parent Info" %}

```json
[
    {
        "learner_id": "1",
        "first_name": "John",
        "last_name": "Smith",
        "gender": "M",
        "grade": "7",
        "debtor_code": "1001",
        "parent1_id": "40",
        "parent2_id": "41",
        "accountable_person_id": "40",
        "parents": [
            {
                "parent_id": "40",
                "title": "Mr",
                "first_name": "John",
                "full_names": "John James",
                "last_name": "Smith",
                "mobile_calling_code": "27",
                "mobile_number": "0823456789",
                "work_tel_number": "0860010012",
                "home_tel_number": "0123456789",
                "email_address": "jjsmith@example.com",
                "date_of_birth": "1967-02-14",
                "gender": "M",
                "residential_address": "Plot 101\r\nDaffodil Street\r\nPretoria",
                "postal_address": "PO Box 12\r\nMenlyn\r\nPretoria",
                "home_language": "English",
                "correspondence_language": "English",
                "communication_method": "E-Mail",
                "include_in_debtor_comms": "Yes",
                "nationality": "South Africa",
                "debtor_code": "1001",
                "id_number": "6702145076084",
                "passport_number": "A0176543",
                "employer": "Smith Attorneys",
                "employer_address": "Suite 101\r\nSmith Street\r\nSouth Africa"
            },
            {
                "parent_id": "41",
                "title": "Mrs",
                "first_name": "Jane",
                "full_names": "Jane Jenny",
                "last_name": "Smith",
                "mobile_calling_code": "27",
                "mobile_number": "0798765432",
                "work_tel_number": "0860010012",
                "home_tel_number": "0123456789",
                "email_address": "smith.jj@example.org",
                "date_of_birth": "1955-06-17",
                "gender": "F",
                "residential_address": "Plot 101\r\nDaffodil Street\r\nPretoria",
                "postal_address": "PO Box 12\r\nMenlyn\r\nPretoria",
                "home_language": "English",
                "correspondence_language": "English",
                "communication_method": "SMS",
                "include_in_debtor_comms": "Yes",
                "nationality": "South Africa",
                "debtor_code": "1001",
                "id_number": "5506170079082",
                "passport_number": "",
                "employer": "Smith Attorneys",
                "employer_address": "Suite 101\r\nSmith Street\r\nSouth Africa"
            }
        ]
    },
    {
        "learner_id": "2",
        "first_name": "Jane",
        "last_name": "Doe",
        "gender": "F",
        "grade": "5",
        "debtor_code": "1002",
        "parent1_id": "55",
        "parent2_id": "56",
        "accountable_person_id": "40",
        "parents": [
            {
                "parent_id": "55",
                "title": "Mr",
                "first_name": "Jonathan",
                "full_names": "Jonathan Andrew",
                "last_name": "Doe",
                "mobile_calling_code": "27",
                "mobile_number": "0813456789",
                "work_tel_number": "0860010012",
                "home_tel_number": "0123456789",
                "email_address": "jd@example.com",
                "date_of_birth": "1969-03-11",
                "gender": "M",
                "residential_address": "91 Monument Street\r\nMonument Park\r\nPretoria",
                "postal_address": "PO Box 12\r\nMonument Park\r\nPretoria",
                "home_language": "English",
                "correspondence_language": "English",
                "communication_method": "E-Mail",
                "include_in_debtor_comms": "Yes",
                "nationality": "South Africa",
                "debtor_code": "1002",
                "id_number": "6903115013085",
                "passport_number": "",
                "employer": "Happy Car Hire",
                "employer_address": "10 Happy Street\r\nJohannesburg\r\nSouth Africa"
            },
            {
                "parent_id": "56",
                "title": "Mrs",
                "first_name": "Janine",
                "full_names": "Janine",
                "last_name": "Doe",
                "mobile_calling_code": "27",
                "mobile_number": "0798124678",
                "work_tel_number": "0860010012",
                "home_tel_number": "0123456789",
                "email_address": "jd2@example.org",
                "date_of_birth": "1984-10-07",
                "gender": "F",
                "residential_address": "91 Monument Street\r\nMonument Park\r\nPretoria",
                "postal_address": "PO Box 12\r\nMonument Park\r\nPretoria",
                "home_language": "English",
                "correspondence_language": "English",
                "communication_method": "SMS",
                "include_in_debtor_comms": "Yes",
                "nationality": "South Africa",
                "debtor_code": "1002",
                "id_number": "8410070079082",
                "passport_number": "",
                "employer": "Happy Car Hire",
                "employer_address": "10 Happy Street\r\nJohannesburg\r\nSouth Africa"
            }
        ]
    }
]
```

{% endtab %}

{% tab title="200 Including Accountable Person" %}

```json
[
    {
        "learner_id": "1",
        "first_name": "John",
        "last_name": "Smith",
        "gender": "M",
        "grade": "7",
        "debtor_code": "1001",
        "parent1_id": "40",
        "parent2_id": "41",
        "accountable_person_id": "40",
        "accountable_person": {
            "accountable_person_id": "40",
            "title": "Mr",
            "full_names": "John James",
            "first_name": "John",
            "last_name": "Smith",
            "mobile_calling_code": "27",
            "mobile_number": "0823456789",
            "work_tel_number": "0860010012",
            "home_tel_number": "0123456789",
            "email_address": "jjsmith@example.com",
            "date_of_birth": "1967-02-14",
            "gender": "M",
            "residential_address": "Plot 101\r\nDaffodil Street\r\nPretoria",
            "postal_address": "PO Box 12\r\nMenlyn\r\nPretoria",
            "home_language": "English",
            "correspondence_language": "English",
            "communication_method": "E-Mail",
            "include_in_debtor_comms": "Yes",
            "nationality": "South Africa",
            "debtor_code": "1001",
            "id_number": "6702145076084",
            "passport_number": "A0176543",
            "employer": "Smith Attorneys",
            "employer_address": "Suite 101\r\nSmith Street\r\nSouth Africa"
        }
    },
    {
        "learner_id": "2",
        "first_name": "Jane",
        "last_name": "Doe",
        "gender": "F",
        "grade": "5",
        "debtor_code": "1002",
        "parent1_id": "55",
        "parent2_id": "56",
        "accountable_person_id": "55",
        "accountable_person": {
            "accountable_person_id": "55",
            "title": "Mr",
            "full_names": "Jonathan Andrew",
            "first_name": "Jonathan",
            "last_name": "Doe",
            "mobile_calling_code": "27",
            "mobile_number": "0813456789",
            "work_tel_number": "0860010012",
            "home_tel_number": "0123456789",
            "email_address": "jd@example.com",
            "date_of_birth": "1969-03-11",
            "gender": "M",
            "residential_address": "91 Monument Street\r\nMonument Park\r\nPretoria",
            "postal_address": "PO Box 12\r\nMonument Park\r\nPretoria",
            "home_language": "English",
            "correspondence_language": "English",
            "communication_method": "SMS",
            "include_in_debtor_comms": "Yes",
            "nationality": "South Africa",
            "debtor_code": "1002",
            "id_number": "6903115013085",
            "passport_number": "",
            "employer": "Happy Car Hire",
            "employer_address": "10 Happy Street\r\nJohannesburg\r\nSouth Africa"
        }
    }
]
```

{% 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/learnerparentinfo';
const SCHOOL_LOGIN_ID = '1000';
const PARAMS = [
    'all_persons' => 1
    ];
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 . '?' . $query,
    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/learnerparentinfo/1000?all_persons=1' \
--header 'HTTP-X-USERNAME: your_username' \
--header 'HTTP-X-PASSWORD: your_password'
```

{% endtab %}
{% endtabs %}
