Notes

Namespace notes (actionstools_app/notes/), table em_actions_notes2 in production (em_actions_notes_staging elsewhere), key (target_uuid, uuid). All routes require a JWT (api/index.adoc#authentication). Notes use AllowEverythingValidator, so any authenticated user may edit any note.

Method Path Behaviour

GET

/notes/

Notes for X-Actions-TargetUUID, newest update first (target_uuid-updated_at-index). Each item carries latest_comments (1) and comments_count. meta.count is the total for the target.

POST

/notes/

Create. Body {"body": "<html>", "user": {…​}, "is_pinned": false}; headers X-Actions-TargetUUID and X-Actions-TargetType (default note) are required. owner_uuid is the JWT’s login_key.

GET

/notes/<uuid>/

Single note, looked up by X-InstanceId + uuid (instance_id-uuid-index), because the primary key needs target_uuid.

PUT

/notes/<uuid>/

Replace body and top-level fields. Needs X-Actions-TargetUUID.

PATCH

/notes/<uuid>/

Change top-level attributes only (is_pinned, target_type, owner_uuid, target_uuid). Any other key is a 400. Pinning alone also stamps is_pinned_updated_at.

DELETE

/notes/<uuid>/

Soft delete (sets deleted_at).

GET

/notes/pinned

Pinned notes for the target (target_uuid-is_pinned-index), sorted by is_pinned_updated_at (falling back to created_at) descending. Page size is forced to at least 500.

POST

/notes/pinned/batch

{"keys": ["<supplier key>", …​]} → {"<key>": [up to 5 pinned notes]}.

POST

/notes/bulk-update/

A list of notes: items with uuid are updated, items without are created. Stops at the first failure and returns {"updated": […​], "created": […​]} with a 500.

is_pinned is stored as 0/1 and returned as a boolean (translate_pinned). Every returned item gets "type": "note", which the activity stream relies on.

Create a note
{
  "body": "<p>Supplier asked for a call back on Monday</p>",
  "user": {"email": "agent@payability.com", "loginKey": "73f3d1f2-b0b1-41d6-9580-56de610577a4"},
  "is_pinned": false
}