# Get Note(s)

<mark style="color:blue;">`GET`</mark> `/v2/finplus/debtmanagement/debtornotes/notes/` `(/{id})`&#x20;

Use this endpoint to **fetch one or more debtor note records** for the specified school.

**Deleted** debtor notes are excluded by default but **can be included** by setting the optional `include_deleted` query parameter.

Additionally, you can **search for debtor notes** using the **`debtor_code`**, **`accountable_person_id`**, and/or **`note_type_id`** query parameters. To return notes for **a specific year**, use the **`year`** query parameter.s

To **include "Promise to Pay" records** directly in the response, set the **`include_promise_to_pays`** query parameter. The payment arrangement data will be included in a **sub-array within each note**.

{% hint style="info" %}
By default, this endpoint returns a **collection of records**, wrapped in a `data` array. To retrieve a **single record**, provide its **ID in the URL**, which will return a **single object** instead of a collection.
{% endhint %}

### Pagination

The response data includes a `meta` object that contains **pagination-specific metadata**. You can use the following query parameters to **control pagination**:

* **limit**: This parameter allows you to override the default limit of records returned, up to the `max_allowed_limit` specified in the response's `meta` object.
* **cursor**: If the `meta` object contains a `next_cursor` field, it indicates that more records are available. To fetch the next set of records, include the `cursor` parameter in your request with the value of `next_cursor`. If the `next_cursor` field is not present, it means there are no more records to retrieve.
* **reverse\_order**: This parameter can be used to reverse the order in which the data is returned, useful for fetching the latest records first.

### Path Parameters

<table><thead><tr><th width="184.5712890625">Name</th><th width="120.68572998046875">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>{id}</code></td><td>Integer</td><td>Optionally provide the <strong>Note ID</strong> for retrieving a single record.</td></tr></tbody></table>

### Request Headers

<table><thead><tr><th width="226.60003662109375">Name</th><th width="117.0286865234375">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>HTTP-X-USERNAME</code><mark style="color:red;">*</mark></td><td>String</td><td>As provided by d6</td></tr><tr><td><code>HTTP-X-PASSWORD</code><mark style="color:red;">*</mark></td><td>String</td><td>As provided by d6</td></tr><tr><td><code>HTTP-X-SCHOOLID</code><mark style="color:red;">*</mark></td><td>Integer</td><td>The unique identifier of the school for which the data is being queried.</td></tr></tbody></table>

### Query Parameters

<table><thead><tr><th width="234.05712890625">Name</th><th width="116.60003662109375">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>note_type_id</code></td><td>Integer</td><td>To only return notes of a given note type</td></tr><tr><td><code>communication_type_id</code></td><td>Integer</td><td>To only return notes of a given communication type</td></tr><tr><td><code>accountable_person_id</code></td><td>Integer</td><td>To only return a specific accountable person's notes</td></tr><tr><td><code>debtor_code</code></td><td>Integer</td><td>To only return a given debtor code's notes</td></tr><tr><td><code>year</code></td><td>Integer</td><td>To filter on a specific year</td></tr><tr><td><code>include_deleted</code></td><td>Boolean</td><td>Whether to include notes that have been deleted already</td></tr><tr><td><code>include_promise_to_pays</code></td><td>Boolean</td><td>Whether to include promise-to-pay data in the response</td></tr><tr><td><code>cursor</code></td><td>String</td><td>To retrieve the next group of items (if any)</td></tr><tr><td><code>limit</code></td><td>Integer</td><td>To override the default limit of records returned (up to the <code>max_allowed_limit</code> provided in the response metadata).</td></tr><tr><td><code>reverse_order</code></td><td>Boolean</td><td>To reverse the order the data is returned in</td></tr></tbody></table>

### Response Examples

{% tabs %}
{% tab title="Success - Collection (200 OK)" %}
**Status:** <mark style="color:green;">`200 OK`</mark>

```json
{
    "data": [
        {
            "note_id": 6,
            "accountable_person_id": 40,
            "accountable_person": "Mr James, John",
            "debtor_code": "1001",
            "debtor_reference": "James",
            "date": "2024-03-03",
            "note_type_id": 2,
            "note_type": "Promise to Pay",
            "communication_type_id": 2,
            "communication_type": "E-mail",
            "note": "Payment arrangement of R1000 to be paid off on outstanding school fees",
            "status": "Created"
        },
        {
            "note_id": 7
            "accountable_person_id": 3,
            "accountable_person": "Mr Webster, Nic",
            "debtor_code": "1002",
            "debtor_reference": "Webster",
            "date": "2024-04-15",
            "note_type_id": 3
            "note_type": "Internal",
            "communication_type_id": 7,
            "communication_type": "Internal",
            "note": "Mr Webster asked to be phoned back tomorrow at 2pm",
            "status": "Created"
        }
    ],
    "meta": {
        "limit": 10,
        "max_allowed_limit": 50,
        "cursor": "eyJpZCI6MjU0NiwiX2JhY2t3YXJkIjpmYWxzZX0"
    }
}
```

{% endtab %}

{% tab title="Success Including Promise to Pays (200 OK)" %}
**Status:** <mark style="color:green;">`200 OK`</mark>

```json
{
    "data": [
        {
            "note_id": 6,
            "accountable_person_id": 40,
            "accountable_person": "Mr James, John",
            "debtor_code": "1001",
            "debtor_reference": "James",
            "date": "2024-03-03",
            "note_type_id": 2,
            "note_type": "Promise to Pay",
            "communication_type_id": 2,
            "communication_type": "E-mail",
            "note": "Payment arrangement of R1000 to be paid off on outstanding school fees",
            "status": "Created",
            "promise_to_pays": [
                {
                    "promise_to_pay_id": 8,
                    "date_promised": "2024-03-31",
                    "amount_promised": "1000.00",
                    "amount_paid": "1000.00",
                    "promise_completed": "Yes"
                },
                {
                    "promise_to_pay_id": 10,
                    "date_promised": "2024-04-30",
                    "amount_promised": "1000.00",
                    "amount_paid": "750.00",
                    "promise_completed": "Partial"
                },
                {
                    "promise_to_pay_id": 12,
                    "date_promised": "2020-05-31",
                    "amount_promised": "1000.00",
                    "amount_paid": "",
                    "promise_completed": "No"
                }
            ]
        }
    ],
    "meta": {
        "limit": 10,
        "max_allowed_limit": 50,
        "cursor": "eyJpZCI6MjU0NiwiX2JhY2t3YXJkIjpmYWxzZX0"
    }
}
```

{% endtab %}

{% tab title="Success - Resource (200 OK)" %}
**Description:** When querying a specific note ID

**Status:** <mark style="color:green;">`200 OK`</mark>

<pre class="language-json"><code class="lang-json"><strong>{
</strong>    "note_id": 6,
    "accountable_person_id": 40,
    "accountable_person": "Mr James, John",
    "debtor_code": "1001",
    "debtor_reference": "James",
    "date": "2024-03-03",
    "note_type_id": 2,
    "note_type": "Promise to Pay",
    "communication_type_id": 2,
    "communication_type": "E-mail",
    "note": "Payment arrangement of R1000 to be paid off on outstanding school fees",
    "status": "Created"
}
</code></pre>

{% endtab %}

{% tab title="ID Not Found Error (404 Not Found)" %}
**Description:** The requested ID does not exist in the system.

**Status:** <mark style="color:red;">`404 Not Found`</mark>

```json
{
    "success": false,
    "message": "The note does not exist"
}
```

{% endtab %}

{% tab title="Validation Error (400 Bad Request)" %}
**Description:** When validation failed for one or more fields

**Status:** <mark style="color:red;">`400 Bad Request`</mark>

```json
{
    "success": false,
    "message": "Validation Failed",
    "validation_errors": {
        "note_type_id": "The Note type id only allows '1', '2', or '3'",
        "year": "The Year must be integer"
    }
}
```

{% endtab %}
{% endtabs %}

### Code Samples

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

```php
<?php

// API Credentials
$api_username = 'your_username';
$api_password = 'your_password';
$school_id = 'the_school_id';

// Base API endpoint
define('BASE_URL', 'https://integrate.d6plus.co.za/api/v2/finplus/debtmanagement/debtornotes/notes');

// Optional: Set an ID to fetch a specific note (or leave empty for all)
$id = '';

$url = BASE_URL;
if (!empty($id)) {
    $url .= '/' . $id;
}

// Query parameters (optional)
$query_params = [
    'year' => 2023,
    'debtor_code' => 1000,
    'accountable_person_id' => 1,
    'include_deleted' => 1,
    'include_promise_to_pays' => 1,
    'note_type_id' => 1,
    'reverse_order' => 1,
    'limit' => 10,
    'cursor' => 'eyJpZCI6MjU0NiwiX2JhY2t3YXJkIjpmYWxzZX0',
];

if (!empty($query_params)) {
    $url .= '?' . http_build_query($query_params);
}

// Initialize cURL
$curl = curl_init();

// Set cURL options
curl_setopt_array($curl, [
    CURLOPT_URL            => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT        => 30,  // Set timeout to prevent hanging requests
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST  => 'GET',
    CURLOPT_HTTPHEADER     => [
        "HTTP-X-USERNAME: $api_username",
        "HTTP-X-PASSWORD: $api_password",
        "HTTP-X-SCHOOLID: $school_id"
    ],
]);

// Execute request
$response = curl_exec($curl);

// Check for errors
$error = curl_error($curl);
if ($error) {
    curl_close($curl);
    throw new Exception("cURL Error: $error");
}

// Close cURL and output response
curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="cURL" %}

```bash
curl --location 'https://integrate.d6plus.co.za/api/v2/finplus/debtmanagement/debtornotes/notes?year=2023&debtor_code=1000&accountable_person_id=1&include_deleted=1&include_promise_to_pays=1&note_type_id=1&reverse_order=1&limit=10' \
     --header 'HTTP-X-USERNAME: your_username' \
     --header 'HTTP-X-PASSWORD: your_password' \
     --header 'HTTP-X-SCHOOLID: the_school_id'
```

{% 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://apidocs.d6plus.co.za/v2/reference/finance+/debt-management/debtor-notes/get-note-s.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.
