Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
294 changes: 294 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ tags:
description: Contact Bio Forms — field schemas for creating and editing Beneficiary records
- name: Beneficiary Types
description: The four contact types — Person, Organisation, Animal, Object
- name: Audio Notes
description: |
AI AudioNotes (CaseNotes): audio recordings of a conversation with a Contact (Beneficiary) or
of an Event session, which Makerble transcribes and summarises into a draft survey response.
- name: Cases
description: Cases linked to a Beneficiary and a Project
- name: Stories
Expand Down Expand Up @@ -2671,6 +2675,203 @@ paths:
"401":
$ref: '#/components/responses/Unauthorized'

/case_notes:
get:
tags: [Audio Notes]
summary: List Audio Notes
description: |
The Audio Notes (CaseNotes) the user may see on the **Audio Notes** page, newest first:
every one in the Organisations (Charities) they are an admin (Charity Editor) of and the
Projects they are a Project Editor of, plus the ones they recorded themselves. Each is a
CaseNote (`note_type: case_note`, about one Contact) or a SessionNote
(`note_type: session_note`, about an Event). Get one to read its transcript and summary.
operationId: listCaseNotes
security: [{tokenAuth: []}]
parameters:
- name: charity_id
in: query
schema:
type: integer
description: Only Audio Notes in this Organisation (Charity)
- name: project_id
in: query
schema:
type: integer
description: Only Audio Notes in this Project
- name: beneficiary_id
in: query
schema:
type: integer
description: Only CaseNotes about this Contact (Beneficiary)
- name: event_id
in: query
schema:
type: integer
description: Only SessionNotes about this Event
- name: note_type
in: query
schema:
type: string
enum: [case_note, session_note]
- $ref: '#/components/parameters/Page'
- $ref: '#/components/parameters/PerPage'
- $ref: '#/components/parameters/LastSyncDatetime'
responses:
"200":
description: Paginated list of Audio Notes
content:
application/json:
schema:
$ref: '#/components/schemas/PaginatedCaseNotes'
"401":
$ref: '#/components/responses/Unauthorized'

post:
tags: [Audio Notes]
summary: Attach an audio file as a new Audio Note
description: |
Creates an Audio Note (CaseNote) from an audio file, as the **New AudioNote** popup on the Audio
Notes page does. Send it as `multipart/form-data`. Makerble then transcribes and summarises it
and writes a draft survey response, the same as for a recording made in Makerble; poll
**Get an Audio Note** until `status` is `completed`. The note's `source` is `manual` and its
`platform` is `api`.

Choose an Organisation (Charity) with AI AudioNotes turned on and one of its running Projects
the user is a member of. For a `case_note` give a Contact (Beneficiary) in that Project whom
the user may see. For a `session_note` the `event_id` is optional; it must be an Event in that
Project that the user is an Event Manager or Event Worker of (a Project or Organisation admin
may choose any of the Project's Events). The file must be MP3, M4A, MP4, WAV, WEBM, OGG, OGA,
AAC or FLAC audio, up to 200 MB.
operationId: createCaseNote
security: [{tokenAuth: []}]
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
required: [charity_id, project_id, note_type, audio_file]
properties:
charity_id:
type: integer
project_id:
type: integer
note_type:
type: string
enum: [case_note, session_note]
beneficiary_id:
type: integer
description: Required for a `case_note`
event_id:
type: integer
description: Optional, for a `session_note`
audio_file:
type: string
format: binary
example:
charity_id: 913
project_id: 2201
note_type: case_note
beneficiary_id: 50412
audio_file: "(binary) session.mp3"
responses:
"201":
description: The Audio Note, queued for transcription
content:
application/json:
schema:
$ref: '#/components/schemas/CaseNoteDetail'
"401":
$ref: '#/components/responses/Unauthorized'
"422":
description: A choice was missing or not allowed, or the file is not a supported audio file
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error: "Choose a contact."
"503":
description: The audio file could not be stored; nothing was created
content:
application/json:
schema:
$ref: '#/components/schemas/Error'

/case_notes/{id}:
parameters:
- $ref: '#/components/parameters/ResourceId'
get:
tags: [Audio Notes]
summary: Get an Audio Note
description: |
One Audio Note (CaseNote) with its transcript and AI summary, if the user may see it on the
**Audio Notes** page (otherwise `404`).
operationId: getCaseNote
security: [{tokenAuth: []}]
responses:
"200":
description: The Audio Note
content:
application/json:
schema:
$ref: '#/components/schemas/CaseNoteDetail'
"401":
$ref: '#/components/responses/Unauthorized'
"404":
$ref: '#/components/responses/NotFound'

/case_notes/{id}/recording:
parameters:
- $ref: '#/components/parameters/ResourceId'
delete:
tags: [Audio Notes]
summary: Delete an Audio Note's recording
description: |
Deletes the audio recording of an Audio Note (CaseNote), for example to meet a privacy request,
as **Delete Recording** does on the Audio Note page. The note itself is kept, with its transcript,
summary and draft or saved survey response; `has_recording` becomes false and `audio_deleted_at`
is set. This cannot be undone. Only the Organisation's admins (Charity Editors) and Makerble
System Access admins may do this (`403`), and only once the note has finished processing
(`status` is `completed` or `failed`; otherwise `422`). Deleting an already deleted recording
returns the note unchanged. `503` means the recording could not be removed from storage and
nothing was changed: try again.
operationId: deleteCaseNoteRecording
security: [{tokenAuth: []}]
responses:
"200":
description: The Audio Note, without its recording
content:
application/json:
schema:
$ref: '#/components/schemas/CaseNoteDetail'
"401":
$ref: '#/components/responses/Unauthorized'
"403":
description: The user is not an admin of the Audio Note's Organisation
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error: "Only an organisation admin can delete a recording."
"404":
$ref: '#/components/responses/NotFound'
"422":
description: The Audio Note is still being processed
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error: "The recording can be deleted once it has been transcribed."
"503":
description: The recording could not be removed from storage; nothing was changed
content:
application/json:
schema:
$ref: '#/components/schemas/Error'

/cases:
get:
tags: [Cases]
Expand Down Expand Up @@ -18586,6 +18787,99 @@ components:
items:
$ref: '#/components/schemas/SeatColleague'

CaseNote:
type: object
properties:
id:
type: integer
charity_id:
type: integer
project_id:
type: integer
user_id:
type: integer
description: The colleague who recorded it
user_name:
type: string
nullable: true
note_type:
type: string
enum: [case_note, session_note]
description: "`case_note` is about one Contact (Beneficiary); `session_note` is about an Event"
status:
type: string
enum: [queued, recording, transcribing, completed, failed, stitching, summarizing]
beneficiary_id:
type: integer
nullable: true
beneficiary_name:
type: string
nullable: true
event_id:
type: integer
nullable: true
draft_story_id:
type: integer
nullable: true
description: The draft survey response written from the summary, once there is one
story_id:
type: integer
nullable: true
description: The survey response (Story) saved from that draft
started_at:
type: string
format: date-time
duration_seconds:
type: integer
nullable: true
source:
type: string
enum: [product, manual]
description: "`product` when recorded in Makerble, `manual` when an audio file was attached"
platform:
type: string
enum: [desktop_web, mobile_web, api]
nullable: true
description: Where it was started; null for Audio Notes made before this was recorded
has_recording:
type: boolean
description: false once the recording has been deleted, or before it is uploaded
audio_deleted_at:
type: string
format: date-time
nullable: true
description: When the recording was deleted, if it has been
created_at:
type: string
format: date-time
updated_at:
type: string
format: date-time

CaseNoteDetail:
allOf:
- $ref: '#/components/schemas/CaseNote'
- type: object
properties:
transcript:
type: string
nullable: true
description: "The transcript, one paragraph per speaker turn (Speaker A: ...)"
summary:
type: string
nullable: true
description: The AI summary

PaginatedCaseNotes:
allOf:
- $ref: '#/components/schemas/PaginationEnvelope'
- type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/CaseNote'

PaginatedWebhookEndpoints:
allOf:
- $ref: '#/components/schemas/PaginationEnvelope'
Expand Down
50 changes: 50 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,7 @@ function buildDocsPage() {
<a href="#contacts" class="nav-link"><span class="nav-method method-POST">POST</span>Contacts</a>
<a href="#contact-forms" class="nav-link"><span class="nav-method method-GET">GET</span>Contact Bio Forms</a>
<a href="#cases" class="nav-link"><span class="nav-method method-POST">POST</span>Cases</a>
<a href="#audio-notes" class="nav-link"><span class="nav-method method-POST">POST</span>Audio Notes</a>
</div>
<div class="nav-section">
<div class="nav-section-label">Surveys &amp; stories</div>
Expand Down Expand Up @@ -1625,6 +1626,55 @@ function buildDocsPage() {
</div>
</section>

<!-- Audio Notes -->
<section class="section" id="audio-notes">
<div class="section-eyebrow">Core resource</div>
<h2 class="section-title">Audio Notes</h2>
<div class="section-desc">
<p>AI AudioNotes (CaseNotes in the API) are audio recordings of a conversation with one Contact (<code>note_type: case_note</code>) or of an Event session (<code>note_type: session_note</code>). Makerble transcribes and summarises each one, then writes a draft survey response from the summary for a colleague to check and save. These endpoints return the same Audio Notes the user sees on the <strong>Audio Notes</strong> page: every one in the Organisations they are an admin of and the Projects they are a Project Editor of, plus the ones they recorded themselves.</p>
<p><code>source</code> is <code>product</code> for a recording made in Makerble and <code>manual</code> for an attached audio file. <code>platform</code> is <code>desktop_web</code>, <code>mobile_web</code> or <code>api</code>, and null for notes made before it was recorded.</p>
</div>
<div class="endpoint-list">
${endpointCard("GET", "/case_notes", "List Audio Notes", true, [
{ name: "charity_id", type: "integer", required: false, desc: "Only Audio Notes in this Organisation" },
{ name: "project_id", type: "integer", required: false, desc: "Only Audio Notes in this Project" },
{ name: "beneficiary_id", type: "integer", required: false, desc: "Only CaseNotes about this Contact" },
{ name: "event_id", type: "integer", required: false, desc: "Only SessionNotes about this Event" },
{ name: "note_type", type: "string", required: false, desc: "<code>case_note</code> or <code>session_note</code>" },
{ name: "page", type: "integer", required: false, desc: "Page number" },
{ name: "per_page", type: "integer", required: false, desc: "Records per page (default 10, max 200)" },
{ name: "last_synced_datetime", type: "string", required: false, desc: "ISO 8601 incremental sync" }
], [{ code: "200", cls: "response-2xx", desc: "Paginated list of Audio Notes, newest first" }])}
${endpointCard("GET", "/case_notes/{id}", "Get an Audio Note", true, [
{ name: "id", type: "integer", required: true, in: "path", desc: "Audio Note (CaseNote) ID" }
], [
{ code: "200", cls: "response-2xx", desc: "The Audio Note with its <code>transcript</code> and <code>summary</code>" },
{ code: "404", cls: "response-4xx", desc: "Not found, or not one the user may see" }
])}
${endpointCard("POST", "/case_notes", "Attach an audio file as a new Audio Note", true, [
{ name: "charity_id", type: "integer", required: true, in: "form", desc: "An Organisation with AI AudioNotes turned on" },
{ name: "project_id", type: "integer", required: true, in: "form", desc: "One of its running Projects the user is a member of" },
{ name: "note_type", type: "string", required: true, in: "form", desc: "<code>case_note</code> or <code>session_note</code>" },
{ name: "beneficiary_id", type: "integer", required: false, in: "form", desc: "Required for a <code>case_note</code>: a Contact in the Project the user may see" },
{ name: "event_id", type: "integer", required: false, in: "form", desc: "Optional for a <code>session_note</code>: an Event in the Project the user manages or works on" },
{ name: "audio_file", type: "file", required: true, in: "form", desc: "MP3, M4A, MP4, WAV, WEBM, OGG, OGA, AAC or FLAC, up to 200 MB" }
], [
{ code: "201", cls: "response-2xx", desc: "Created and queued for transcription" },
{ code: "422", cls: "response-4xx", desc: "A choice is missing or not allowed, or the file is not supported audio" },
{ code: "503", cls: "response-5xx", desc: "The file could not be stored; nothing was created" }
], "Send as <code>multipart/form-data</code>, then poll <code>GET /case_notes/{id}</code> until <code>status</code> is <code>completed</code>.")}
${endpointCard("DELETE", "/case_notes/{id}/recording", "Delete an Audio Note's recording", true, [
{ name: "id", type: "integer", required: true, in: "path", desc: "Audio Note (CaseNote) ID" }
], [
{ code: "200", cls: "response-2xx", desc: "The Audio Note, with <code>has_recording: false</code>" },
{ code: "403", cls: "response-4xx", desc: "Only the Organisation's admins may delete a recording" },
{ code: "404", cls: "response-4xx", desc: "Not found, or not one the user may see" },
{ code: "422", cls: "response-4xx", desc: "Still being transcribed" },
{ code: "503", cls: "response-5xx", desc: "Could not be removed from storage; nothing changed" }
], "Keeps the note, its transcript, summary and survey response. Cannot be undone.")}
</div>
</section>

<!-- Surveys -->
<section class="section" id="surveys">
<div class="section-eyebrow">Surveys &amp; Stories</div>
Expand Down
Loading