Getting startedInstall the SDK
Install the SDK
The JavaScript SDK lets your app send notes to Fieldnote and read back the links it suggests. Setup takes three steps.
Requirements
- Node.js 18 or later, or any runtime with
fetch - A Fieldnote workspace on the Pro plan
- An API key with the
notes:writescope
Install
-
Add the package
terminal$ npm install @fieldnote/sdk
-
Create an API key
Open Settings → API keys in the app and create a key. Store it in an environment variable named
FIELDNOTE_KEY. -
Send your first note
suggest.jsimport { Fieldnote } from "@fieldnote/sdk"; const fn = new Fieldnote({ key: process.env.FIELDNOTE_KEY }); const note = await fn.notes.create({ title: "Call with Priya", body: "She wants the pricing draft before Friday.", }); // Suggestions are ready within a second of creating the note const links = await fn.links.suggest(note.id); console.log(links.map((l) => l.title)); // [ "Pricing draft", "Priya Nair" ]
Server only
Do not ship the API key to a browser. Call the SDK from your server, or create short-lived tokens with fn.tokens.create().
Options
All options are passed to the Fieldnote constructor.
| Option | Type | Default | What it does |
|---|---|---|---|
key | string | none | Your API key. Required. |
region | "us" | "eu" | "us" | Where requests are sent. Match the region of your workspace. |
timeout | number | 10000 | Milliseconds before a request is cancelled. |
retries | number | 2 | Retries for network errors and 5xx responses. |
Troubleshooting
401 Unauthorized
The key is missing or was revoked. Check that FIELDNOTE_KEY is set in the process that runs the SDK, not only in your shell.
Suggestions come back empty
A new workspace needs about 20 notes before suggestions start. Import existing notes first, see Import notes.