Skip to main content

Notes API

Usageโ€‹

import { epilot } from '@epilot/sdk'

epilot.authorize(() => '<token>')
const { data } = await epilot.notes.createNote(...)

Tree-shakeable importโ€‹

import { getClient, authorize } from '@epilot/sdk/notes'

const notesClient = getClient()
authorize(notesClient, () => '<token>')
const { data } = await notesClient.createNote(...)

Operationsโ€‹

Notes

Pinning

Reactions

Schemas

createNoteโ€‹

Creates a new Note entry

POST /v1/note

const { data } = await client.createNote(
null,
{
_tags: ['string'],
type: 'string',
entity_id: 'string',
parent_id: 'string',
contexts: [
{
type: 'workflow_execution',
id: 'string'
}
],
additional_contexts: [
{
type: 'workflow_execution',
id: 'string'
}
],
content: 'string',
attachments: ['string'],
read_by: ['string']
},
)

getNoteโ€‹

Retrieves a single Note entry based on it's Entity ID

GET /v1/note/{id}

const { data } = await client.getNote({
id: '123e4567-e89b-12d3-a456-426614174000',
hydrate: true,
})

patchNoteโ€‹

Updates an existing Note entry

PATCH /v1/note/{id}

const { data } = await client.patchNote({
id: '123e4567-e89b-12d3-a456-426614174000',
})

updateNoteโ€‹

Updates an existing Note entry

PUT /v1/note/{id}

const { data } = await client.updateNote(
{
id: '123e4567-e89b-12d3-a456-426614174000',
},
{
_id: 'string',
_org: 'string',
_schema: 'string',
_created_at: '1970-01-01T00:00:00.000Z',
_updated_at: '1970-01-01T00:00:00.000Z',
_created_by: 'string',
_tags: ['string'],
_acl: {},
_owners: [
{
org_id: 'string',
user_id: 'string'
}
],
type: 'string',
context_entities: {
$relation: [
{
entity_id: 'string'
}
]
},
parent: {
$relation: [
{
entity_id: 'string'
}
]
},
attachments: {
$relation: [
{
entity_id: 'string'
}
]
},
content: 'string',
contexts: [
{
type: 'workflow_execution',
id: 'string'
}
],
pinned_at: '1970-01-01T00:00:00.000Z',
created_by: {
type: 'user',
user_id: 'string',
display_name: 'string',
org_id: 'string',
email: 'string',
phone: 'string'
},
read_by: ['string'],
reactions: {}
},
)

deleteNoteโ€‹

Deletes a single Note entry based on it's Entity ID

DELETE /v1/note/{id}

const { data } = await client.deleteNote({
id: '123e4567-e89b-12d3-a456-426614174000',
})

searchNotesByContextโ€‹

Search for a paginated list of Notes based on one or more contexts

POST /v1/notes:search

const { data } = await client.searchNotesByContext(
null,
{
contexts: [
{
type: 'workflow_execution',
id: 'string'
}
],
from: 0,
size: 10
},
)

pinNoteโ€‹

Pins a single Note entry based on it's Entity ID

POST /v1/note/{id}/pin

const { data } = await client.pinNote({
id: '123e4567-e89b-12d3-a456-426614174000',
})

getNoteContextsโ€‹

Gets all the Entity and non-Entity records the Note is contextually attached to

GET /v1/note/{id}/context

const { data } = await client.getNoteContexts({
id: '123e4567-e89b-12d3-a456-426614174000',
})
Response
[
{
"type": "workflow_execution",
"context": {
"_id": "string",
"_org": "string",
"_schema": "string",
"_created_at": "1970-01-01T00:00:00.000Z",
"_updated_at": "1970-01-01T00:00:00.000Z",
"_created_by": "string",
"_tags": ["string"],
"_acl": {},
"_owners": [
{
"org_id": "string",
"user_id": "string"
}
],
"type": "string"
}
}
]

addNoteReactionโ€‹

Adds an emoji reaction to a note

POST /v1/note/{id}/reaction

const { data } = await client.addNoteReaction(
{
id: '123e4567-e89b-12d3-a456-426614174000',
},
{
emoji: 'thumbs-up'
},
)

removeNoteReactionโ€‹

Removes an emoji reaction from a note

DELETE /v1/note/{id}/reaction/{emoji_shortcode}

const { data } = await client.removeNoteReaction({
id: '123e4567-e89b-12d3-a456-426614174000',
emoji_shortcode: 'example',
})

toggleNoteReactionsโ€‹

Toggles multiple emoji reactions on a note. If a user has already reacted with an emoji, it removes the reaction. If a user hasn't reacted with an emoji, it adds the reaction.

POST /v1/note/{id}/reactions/toggle

const { data } = await client.toggleNoteReactions(
{
id: '123e4567-e89b-12d3-a456-426614174000',
},
{
emojis: ['thumbs-up', 'heart']
},
)

Schemasโ€‹

NotePostRequestBodyโ€‹

type NotePostRequestBody = {
_tags?: string[]
type?: string
entity_id?: string
parent_id?: string
contexts?: Array<{
type: "workflow_execution" | "workflow_task" | "workflow_configuration" | "journey_configuration" | "entity"
id: string
}>
additional_contexts?: Array<{
type: "workflow_execution" | "workflow_task" | "workflow_configuration" | "journey_configuration" | "entity"
id: string
}>
content?: string
attachments?: string[]
read_by?: string[]
}

ContextTypeโ€‹

type ContextType = "workflow_execution" | "workflow_task" | "workflow_configuration" | "journey_configuration" | "entity"

NoteEntityโ€‹

A note Entity object cotaining Entity metadata and content. Relational attributes are hydrated in place.

type NoteEntity = {
_id: string
_org?: string
_schema?: string
_created_at?: string // date-time
_updated_at?: string // date-time
_created_by?: string | number
_tags?: string[]
_acl?: Record<string, string[]>
_owners?: Array<{
org_id: string
user_id: string
}>
type?: string
}

Entityโ€‹

Base Entity schema

type Entity = {
_id: string
_org?: string
_schema?: string
_created_at?: string // date-time
_updated_at?: string // date-time
_created_by?: string | number
_tags?: string[]
_acl?: Record<string, string[]>
_owners?: Array<{
org_id: string
user_id: string
}>
type?: string
}

CreatedByTypeโ€‹

type CreatedByType = "user" | "group"

NoteGetRequestResponseโ€‹

type NoteGetRequestResponse = {
_id: string
_org?: string
_schema?: string
_created_at?: string // date-time
_updated_at?: string // date-time
_created_by?: string | number
_tags?: string[]
_acl?: Record<string, string[]>
_owners?: Array<{
org_id: string
user_id: string
}>
type?: string
}

NotePatchRequestBodyโ€‹

type NotePatchRequestBody = {
_tags?: string[]
type?: string
attachments?: {
$relation?: Array<{
entity_id: { ... }
}>
}
comments?: Array<{
_id: string
_org?: string
_schema?: string
_created_at?: string // date-time
_updated_at?: string // date-time
_created_by?: string | number
_tags?: string[]
_acl?: Record<string, string[]>
_owners?: Array<{
org_id: { ... }
user_id: { ... }
}>
type?: string
}>
content?: string
contexts?: Array<{
type: "workflow_execution" | "workflow_task" | "workflow_configuration" | "journey_configuration" | "entity"
id: string
}>
pinned_at?: string // date-time
created_by?: {
type: "user" | "group"
user_id?: string
display_name?: string
org_id?: string
email?: string
phone?: string
}
read_by?: string[]
reactions?: Record<string, string[]>
}

NonHydratedNoteEntityโ€‹

A note Entity object cotaining Entity metadata and content. Relational attributes are not hydrated in place.

type NonHydratedNoteEntity = {
_id: string
_org?: string
_schema?: string
_created_at?: string // date-time
_updated_at?: string // date-time
_created_by?: string | number
_tags?: string[]
_acl?: Record<string, string[]>
_owners?: Array<{
org_id: string
user_id: string
}>
type?: string
}

NoteEntityParentโ€‹

The Note's parent Note

type NoteEntityParent = {
$relation?: Array<{
entity_id: string
}>
}

NotePutRequestBodyโ€‹

type NotePutRequestBody = {
_id?: string
_org?: string
_schema?: string
_created_at?: string // date-time
_updated_at?: string // date-time
_created_by?: string | number
_tags?: string[]
_acl?: Record<string, string[]>
_owners?: Array<{
org_id: string
user_id: string
}>
type?: string
context_entities?: {
$relation: Array<{
entity_id: { ... }
}>
}
parent?: {
$relation?: Array<{
entity_id: { ... }
}>
}
attachments?: {
$relation?: Array<{
entity_id: { ... }
}>
}
content?: string
contexts?: Array<{
type: "workflow_execution" | "workflow_task" | "workflow_configuration" | "journey_configuration" | "entity"
id: string
}>
pinned_at?: string // date-time
created_by?: {
type: "user" | "group"
user_id?: string
display_name?: string
org_id?: string
email?: string
phone?: string
}
read_by?: string[]
reactions?: Record<string, string[]>
}

NoteSearchByContextRequestBodyโ€‹

type NoteSearchByContextRequestBody = {
contexts: Array<{
type: "workflow_execution" | "workflow_task" | "workflow_configuration" | "journey_configuration" | "entity"
id: string
}>
from?: number
size?: number
}

NotesSearchRequestResponseโ€‹

type NotesSearchRequestResponse = {
hits?: number
results: Array<{
_id: string
_org?: string
_schema?: string
_created_at?: string // date-time
_updated_at?: string // date-time
_created_by?: string | number
_tags?: string[]
_acl?: Record<string, string[]>
_owners?: Array<{
org_id: { ... }
user_id: { ... }
}>
type?: string
}>
}

NoteContextsโ€‹

List of resolved Entity and non-Entity contexts attached to a given Note.

type NoteContexts = {
type: "workflow_execution" | "workflow_task" | "workflow_configuration" | "journey_configuration" | "entity"
context: {
_id: string
_org?: string
_schema?: string
_created_at?: string // date-time
_updated_at?: string // date-time
_created_by?: string | number
_tags?: string[]
_acl?: Record<string, string[]>
_owners?: Array<{
org_id: { ... }
user_id: { ... }
}>
type?: string
} | {
id: string
definitionId: string
orgId: string
name: string
}
}

WorkflowExecutionโ€‹

Base metadata for a Workflow Execution. This is a lightweight representation of a Workflow Execution, and does not contain all it's data

type WorkflowExecution = {
id: string
definitionId: string
orgId: string
name: string
}

ReactionRequestโ€‹

type ReactionRequest = {
emoji: string
}

ToggleReactionsRequestโ€‹

type ToggleReactionsRequest = {
emojis: string[]
}