Entity files are files uploaded to a relevant entity. Possible files, for example, would be a pitch deck for an opportunity or a physical mail correspondence for a person.

Properties

pagedIterator: ((params: Omit<undefined | AllNotesRequest, keyof PagedRequest> & Omit<PagedRequest, "page_token">) => AsyncGenerator<Unwrapped<FN, PAYLOAD_KEY>>) = ...

Returns an async iterator that yields all notes matching the given request Each yielded array contains up to the number specified in PagedRequest.page_size of notes. Use this method if you want to process the notes in a streaming fashion.

Please note: the yielded notes array may be empty on the last page.

let page = 0
for await (const entries of affinity.notes.pagedIterator({
person_id: 123,
page_size: 10
})) {
console.log(`Page ${++page} of entries:`, entries)
}

Methods

  • Creates a new note with the supplied parameters.

    Set the type parameter to 2 to create an HTML note. See here for more information on the sorts of rich text formatting we support in notes. Please note that <a> tags aren't currently clickable inside the Affinity web app - though full links are.

    It is possible to create a reply to an existing note by setting parent_id. The parent note should not have a parent_id itself. It is possible for a single parent note to have multiple reply notes - They just get displayed in order of creation. opportunity_ids, person_ids, and organization_ids will be ignored when a parent_id is provided.

    Parameters

    Returns Promise<Note>

    const newNote = await affinity.notes.create({
    person_ids: [
    38706,
    624289
    ],
    organization_ids: [
    120611418
    ],
    opportunity_ids: [
    167
    ],
    content: "Had a lunch meeting with Jane and John today. They want to invest in Acme Corp."
    })
    console.log(newNote)
  • Deletes a note with a specified note_id.

    Parameters

    Returns Promise<boolean>

    true if the deletion was successful

    const success = await affinity.notes.delete({
    note_id: 12345
    })
    console.log(success ? 'Note deleted': 'Note not deleted')
  • Fetches a note with a specified note_id.

    Parameters

    Returns Promise<Note>

    The Note object corresponding to the note_id.

    const note = await affinity.notes.get({
    note_id: 12345
    })
    console.log(note)
  • Updates an existing person with note_id with the supplied parameters.

    Caveats:

    • You cannot update the content of a note that has mentions.
    • You also cannot update the content of a note associated with an email.
    • You cannot update the type of a note.

    Note from 2024-08-13: Updating an HTML note with changed HTML content seems to result in the note being displayed as plain text in the Affinity web app. Bug is reported.

    Parameters

    Returns Promise<Note>

    const updatedNote = await affinity.notes.update({
    note_id: 12345,
    content: "Dinner wasn't great, but the conversation was excellent.",
    })
    console.log(updatedNote)