Code & Snippets

Fetch a Single Attio Note by ID.

Given a note ID, pulls one Attio note and returns a cleaned title plus content — drop-in for a Zapier 'Run JavaScript' step when you need a specific note.

Pure Operations
JavaScript · 50 lines
C.1

Download

Grab the source file. Drop it into your service, set the required environment variables, and deploy.

Download attio_note_by_id.jsJavaScript · 50 lines
C.2

How it works

The gist

Fetches a single Attio note by its ID and returns a cleaned title plus the note content — used when you already know which note you want and need to pull it into a Zap for downstream processing (e.g. parsing, summarizing, or writing into a drive folder).

The flow

  1. InputsATTIO_TOKEN and NOTE_ID, passed via inputData (Zapier "Run JavaScript" convention).
  2. Validate inputs. Missing token or ID throws immediately so the Zap surfaces the failure instead of writing blanks.
  3. Authenticated GET to /v2/notes/{NOTE_ID} with a Bearer token.
  4. Error loud on failure. Any non-2xx response throws with status and body text so you can debug auth or missing-note issues quickly.
  5. Clean the title. Strips non-alphanumeric characters (except spaces) and trims — useful when note titles contain emojis or punctuation that break downstream file-naming or spreadsheet imports.
  6. Return note_title and note_content. Content prefers plaintext and falls back to markdown. Two discrete fields make Zap mapping trivial.

Why this exists

Sometimes you don't need every note on a company — just the one you already know about. This is the lightweight counterpart to the bulk-notes snippet: one note in, two clean fields out.

C.3

Source

Full source, exactly as shipped. The download above is byte-identical.

attio_note_by_id.jsJavaScript
/**
 * Fetch a single Attio note by ID and return:
 *   - note_title (cleaned string)
 *   - note_content (plaintext or markdown)
 */

const ATTIO_TOKEN = inputData.ATTIO_TOKEN;
const NOTE_ID = inputData.NOTE_ID;

if (!ATTIO_TOKEN) throw new Error("Missing ATTIO_TOKEN");
if (!NOTE_ID) throw new Error("Missing NOTE_ID");

const BASE_URL = `https://api.attio.com/v2/notes/${NOTE_ID}`;

// Clean title: remove non-alphanumeric characters except spaces
function cleanTitle(title) {
  if (!title) return "";
  return title.replace(/[^a-zA-Z0-9\s]/g, "").trim();
}

async function fetchNote() {
  const res = await fetch(BASE_URL, {
    method: "GET",
    headers: {
      "Authorization": `Bearer ${ATTIO_TOKEN}`,
      "Accept": "application/json"
    }
  });

  if (!res.ok) {
    const text = await res.text();
    throw new Error(`Attio /v2/notes/${NOTE_ID} failed ${res.status}: ${text}`);
  }

  const json = await res.json();
  return json?.data || {};
}

const note = await fetchNote();

// Prepare clean outputs
const note_title = cleanTitle(note?.title);
const note_content = note?.content_plaintext || note?.content_markdown || "";

// Return both separately for easy Zap mapping
return {
  note_title,
  note_content
};