Skip to main content
The hackmd.mjs module wraps @hackmd/api to create and update meeting minutes documents on HackMD.

createHackMDClient(config, meetingConfig)

Creates an authenticated HackMD API client, pointed at either a team endpoint or the personal endpoint.
import * as hackmd from './src/hackmd.mjs';

const hackmdClient = hackmd.createHackMDClient(config, meetingConfig);

Parameters

config
AppConfig
required
Application configuration. Reads config.hackmd.apiToken for authentication.
meetingConfig
MeetingConfig
required
Meeting configuration returned by readMeetingConfig. Reads meetingConfig.properties.HACKMD_TEAM_NAME to determine the API base URL.

Returns

HackMDAPI — a configured client instance.
  • If HACKMD_TEAM_NAME is set in the meeting template: the client uses https://api.hackmd.io/v1/teams/<team> as its base URL, so all requests operate in the context of that team’s workspace.
  • If HACKMD_TEAM_NAME is not set: the client uses https://api.hackmd.io/v1 (personal workspace).

getOrCreateMeetingNotesDocument(hackmdClient, title, config)

Returns an existing HackMD note with the given title, or creates a new empty one if none is found.
const note = await hackmd.getOrCreateMeetingNotesDocument(
  hackmdClient,
  meetingTitle,
  config
);

Parameters

hackmdClient
HackMDAPI
required
HackMD API client returned by createHackMDClient.
title
string
required
The meeting title used to look up or name the document.
config
AppConfig
required
Application configuration. Reads config.force to decide whether to skip the existing-note check.

Returns

Promise<HackMDNote> — the existing or newly created note object. Logic:
  1. If force is false: fetches the full note list from the HackMD account and returns the first note whose title exactly matches the given title.
  2. If force is true or no match is found: calls createMeetingNotesDocument with an empty string for content. The caller is expected to populate the content in a subsequent updateMeetingNotesDocument call.

createMeetingNotesDocument(hackmdClient, title, content)

Creates a new HackMD note with the given title and content.
const note = await hackmd.createMeetingNotesDocument(
  hackmdClient,
  title,
  content
);

Parameters

hackmdClient
HackMDAPI
required
HackMD API client.
title
string
required
Document title.
content
string
required
Initial document content in markdown.

Returns

Promise<HackMDNote> — the created note object. The note is created with the following default permissions from HACKMD_DEFAULT_PERMISSIONS:
PermissionValue
readPermission"guest"
writePermission"signed_in"
commentPermission"signed_in_users"
The HackMD API may return either { note: { ... } } or { ... } directly. The function normalises both shapes and always resolves with the note object itself.

updateMeetingNotesDocument(hackmdClient, noteId, content)

Updates the content of an existing HackMD note by its ID.
await hackmd.updateMeetingNotesDocument(
  hackmdClient,
  hackmdNote.id,
  minutesContent
);

Parameters

hackmdClient
HackMDAPI
required
HackMD API client.
noteId
string
required
The ID of the HackMD note to update. Available as note.id on the object returned by getOrCreateMeetingNotesDocument.
content
string
required
The new document content in markdown.

Returns

Promise<HackMDNote> — the updated note object.
Like createMeetingNotesDocument, this function normalises the API response to handle both { note: { ... } } and { ... } return shapes.

Build docs developers (and LLMs) love