Guides

Notes API

Integrate with CreditRisk endpoints using clear request and response examples.

Notes Endpoint

Retrieve, add and update account notes for the grantors you have access to.

Endpoint Details

GET /api/notes
GET /api/notes/{id} — a single note
POST /api/notes — add a note
PUT /api/notes/{id} — update a note

Authentication Required

  • API Token: Required in URL parameter ?api_token=xxx
  • User Token: Required in Authorization header Authorization: Bearer xxx

Only notes linked to an account of a grantor the user has access to are returned.

Query Parameters

Parameter Type Required Description
api_tokenstringYesYour API access token
grantor_idintegerNoLimit to one grantor (default: all grantors the user can access)
account_idintegerNoOnly notes for this account
account_sync_idstringNoOnly notes for accounts with this external account sync ID; distinct from the note's sync_id
follow_up_completeintegerNo0 or 1
sync_idstringNoFilter by the note's sync ID
activeintegerNoDefault 1. Use 0 for inactive notes
pageintegerNoPage number (default: 1, 100 per page)
pagingintegerNoSet to 0 to disable pagination and get all results

Filtering by type is not supported; supplying it as a query parameter returns HTTP 400.

Response Format

Success Response (200 OK)
{
  "success": true,
  "message": "Notes retrieved successfully",
  "data": {
    "notes": [
      {
        "id": 1,
        "account_id": 123,
        "account_sync_id": "a1b2c3",
        "grantor_id": 5,
        "app_invite_id": null,
        "pre_legal_id": null,
        "crm_id": null,
        "user_id": 7,
        "note": "Called customer about overdue invoice",
        "activity": "Phone",
        "type": "account-note",
        "follow_up_date": "2024-02-01",
        "follow_up_complete": 0,
        "active": 1,
        "sync_id": "n-456",
        "import_id": null,
        "created_at": "2024-01-15 10:00:00",
        "updated_at": "2024-01-15 10:00:00"
      }
    ],
    "pagination": {
      "current_page": 1,
      "per_page": 100,
      "total_results": 1,
      "total_pages": 1,
      "has_previous": false,
      "has_next": false,
      "previous_page": null,
      "next_page": null
    }
  }
}

GET /api/notes/{id} returns data.note instead of data.notes.

Add or Update a Note

Send a JSON body. POST adds a note; if the body contains an id or a sync_id that matches an existing note, that note is updated instead (upsert). PUT only updates and returns 404 if the note does not exist. The id can be in the path (/api/notes/{id}) or in the body. On create and update, the server always sets type to account-note; any supplied value is ignored.

FieldTypeRequiredDescription
account_idintegerOn create, unless account_sync_id is suppliedAccount the note belongs to (must be in a grantor you can access)
account_sync_idstringOn create, unless account_id is suppliedExternal account reference used to find the account. Distinct from the note's sync_id.
notestringOn createNote text
activitystring or nullNoPhone, Email, Meeting or null. The string "null" is also treated as null. Defaults to null on create; unchanged on update if omitted.
follow_up_datedateNoe.g. 2024-02-01
follow_up_completeintegerNo0 or 1
pre_legal_idintegerNoOptional link to a related record
sync_idstringNoYour external reference; used to match existing notes
activeintegerNoDefault 1 on create; set 0 to deactivate

On update, either account reference can be supplied to change the linked account. If both are supplied, they must identify the same accessible account. An unknown or inaccessible account returns HTTP 404; if an external account reference matches multiple accessible accounts, the API returns HTTP 409 and requires account_id to disambiguate.

The note's user_id is set to the authenticated API user on create and update, replacing the previous value on update. Any supplied user_id is ignored. crm_id and app_invite_id cannot be supplied on create or update, even as null; they remain available in GET responses. Invalid activity values and restricted fields return HTTP 400.

{
  "success": true,
  "message": "Note created successfully",
  "data": { "id": 42, "status": "created" }
}
Add a Note
curl -X POST "https://api.creditrisk.co.za/api/notes?api_token=your_token" \
-H "Authorization: Bearer your_user_token" -H "Content-Type: application/json" \
-d '{"account_sync_id":"ACC-001","note":"Called customer","activity":"Phone","follow_up_date":"2024-02-01"}'
Update a Note
curl -X PUT "https://api.creditrisk.co.za/api/notes/42?api_token=your_token" \
-H "Authorization: Bearer your_user_token" -H "Content-Type: application/json" \
-d '{"follow_up_complete":1}'

Examples

All Notes
curl -X GET "https://api.creditrisk.co.za/api/notes?api_token=your_token" \
-H "Authorization: Bearer your_user_token"
Notes for an Account
curl -X GET "https://api.creditrisk.co.za/api/notes?api_token=your_token&account_id=123" \
-H "Authorization: Bearer your_user_token"
Notes for an External Account Reference
curl -X GET "https://api.creditrisk.co.za/api/notes?api_token=your_token&account_sync_id=ACC-001" \
-H "Authorization: ******"

Error Responses

Authentication Failed (401 Unauthorized)
{
  "success": false,
  "error": "Authentication failed",
  "message": "Invalid or expired access token"
}
Note Not Found (404)
{
  "success": false,
  "message": "Note not found"
}