# Update Note

<mark style="color:purple;">`PATCH`</mark> `/v2/finplus/debtmanagement/debtornotes/notes/{id}`

Use this endpoint to **update an existing debtor note** for a specified school.

* The **note ID** must be passed in the URL and can be retrieved using the [**Get Note(s)**](/v2/reference/finance+/debt-management/debtor-notes/get-note-s.md) call.
* If you need to update the **payment arrangements** attached to a promise-to-pay note, include the updated data in the `promise_to_pays` array (see details below).
* To update an **existing** promise-to-pay entry, provide its `promise_to_pay_id`. This ID can be retrieved using either the [**Get Note(s)**](/v2/reference/finance+/debt-management/debtor-notes/get-note-s.md) or [**Get Promise To Pay(s)**](/v2/reference/finance+/debt-management/debtor-notes/get-promise-to-pay-record-s.md) call.
* If a `promise_to_pay_id` is **not included**, a **new** promise-to-pay entry will be created.
* The API will **not** allow a duplicate promise-to-pay entry to be added if both `date_promised` and `amount_promised` match an existing record.
* To **restore** a previously deleted note, provide the `note_id` and set the `status` field to `"Created"`.
* For a detailed explanation of individual fields, refer to the [**Create Note**](/v2/reference/finance+/debt-management/debtor-notes/create-note.md) documentation.

### Path Parameters

<table><thead><tr><th width="226.31427001953125">Name</th><th width="106.05712890625">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>{id}</code><mark style="color:red;">*</mark></td><td>Integer</td><td>The <strong>Note ID</strong> of the note to be updated</td></tr></tbody></table>

### Request Headers

<table><thead><tr><th width="228.5714111328125">Name</th><th width="96">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>

### Request Body

<table><thead><tr><th width="219.85711669921875">Name</th><th width="98">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>accountable_person_id</code></td><td>Integer</td><td>The id of the accountable person who the note belongs to.</td></tr><tr><td><code>date</code></td><td>String</td><td>The date of the note in "yyyy-mm-dd" format.</td></tr><tr><td><code>note_type_id</code></td><td>Integer</td><td>The id of the note type.</td></tr><tr><td><code>communication_type_id</code></td><td>Integer</td><td>The id of the communication type (not required for internal notes).</td></tr><tr><td><code>note</code></td><td>String</td><td>The note text</td></tr><tr><td><code>status</code></td><td>String</td><td>The status of the note (either "Created" or "Deleted")</td></tr><tr><td><code>promise_to_pays</code></td><td>Array</td><td>An array of payment arrangement data for promise-to-pay notes</td></tr></tbody></table>

### Request Examples

{% tabs %}
{% tab title="Update a note" %}

```json
{
    "note_id": 7,
    "date": "2024-04-16",
    "note": "Mr Webster asked to be phoned back tomorrow at 10am"
}
```

{% endtab %}

{% tab title="Update / Add Promise-to-Pay" %}

```json
{
    "note_id": 6,
    "promise_to_pays": [
        {
            // Updating an existing promise to pay
            "promise_to_pay_id": 12, // <- promise to pay ID included
            "date_promised": "2020-05-31",
            "amount_promised": "1500.00"
        },
        {
            // Create a new promise to pay
            "date_promised": "2020-06-30",
            "amount_promised": "500.00"
        }
    ]
}
```

{% endtab %}

{% tab title="Restore a deleted note" %}

```json
{
    "note_id": 6
    "status": "Created"
}
```

{% endtab %}
{% endtabs %}

### Response Examples

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

```json
{
    "success": true,
    "message": "Note updated successfully",
    "data": {
        "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 10am",
        "status": "Created"
    }
}
```

{% endtab %}

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

```json
{
    "success": true,
    "message": "Note updated successfully",
    "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": "1500.00",
                "amount_paid": "",
                "promise_completed": "No"
            },
            {
                "promise_to_pay_id": 13,
                "date_promised": "2020-06-30",
                "amount_promised": "500.00",
                "amount_paid": "",
                "promise_completed": "No"
            }
        ]
    }
}
```

{% endtab %}

{% tab title="ID Missing Error (400 Bad Request)" %}
**Description:** When the note ID was not included in the URL.

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

```json
{
    "success": false,
    "message": "The Note ID is required"
}
```

{% endtab %}

{% tab title="ID Not Found Error (404 Not Found)" %}
**Description:** When the note ID provided does not exist.

**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": {
        "accountable_person_id": "The accountable_person_id is invalid",
        "date": "The Date is not valid date format. Expected format is 'Y-m-d'."
    }
}
```

{% 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';

// Note ID to update (retrieved from Get Note(s) or Get Promise To Pay(s) calls)
$note_id = '1234';

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

// Request payload data
$request_data = [
    "accountable_person_id" => 1234,             // Replace with actual accountable person ID
    "date"                  => "2025-04-01",       // Date of the note in "YYYY-MM-DD" format
    "note_type_id"          => 2,                  // Replace with actual note type ID
    "communication_type_id" => 1,                  // Required for all note types except Internal Notes
    "note"                  => "Updated debtor note text.",
    "status"                => "Created",          // Use "Created" to restore a deleted note
    "promise_to_pays"       => [                   // Optional: Promise-to-pay details
        [
            "promise_to_pay_id" => 5678,           // To update an existing promise-to-pay, include its ID. Omit to create a new one.
            "date_promised"     => "2025-05-15",
            "amount_promised"   => "2000.00"
        ]
    ]
];

// 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  => 'PATCH',
    CURLOPT_POSTFIELDS     => json_encode($request_data),
    CURLOPT_HTTPHEADER     => [
        "HTTP-X-USERNAME: $api_username",
        "HTTP-X-PASSWORD: $api_password",
        "HTTP-X-SCHOOLID: $school_id",
        "Content-Type: application/json"
    ],
]);

// Execute the 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 session and output the response
curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="cURL" %}

```bash
curl --location --request PATCH 'https://integrate.d6plus.co.za/api/v2/finplus/debtmanagement/debtornotes/notes/{note_id}' \
     --header 'HTTP-X-USERNAME: your_username' \
     --header 'HTTP-X-PASSWORD: your_password' \
     --header 'HTTP-X-SCHOOLID: the_school_id' \
     --header 'Content-Type: application/json' \
     --data-raw '{
         "accountable_person_id": 1234,
         "date": "2025-04-01",
         "note_type_id": 2,
         "communication_type_id": 1,
         "note": "Updated debtor note text.",
         "status": "Created",
         "promise_to_pays": [
             {
                 "promise_to_pay_id": 5678,
                 "date_promised": "2025-05-15",
                 "amount_promised": "2000.00"
             }
         ]
     }'
```

{% 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/update-note.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.
