NudgeForMe REST API example in JavaScript
Use server-side JavaScript and fetch to list mailboxes and follow-up opportunities.
JavaScript example: read follow-up opportunities
This example uses Node.js 18 or later. Store your Nudge API key in an environment variable, not in frontend code.
export NUDGE_BASE_URL=https://app.nudgeforme.com
export NUDGE_API_KEY=YOUR_DEVELOPER_KEY
const base = (process.env.NUDGE_BASE_URL || 'https://app.nudgeforme.com').replace(/\/$/, '');
const key = process.env.NUDGE_API_KEY;
if (!key) throw new Error('Missing NUDGE_API_KEY');
async function nudgeGet(route, params = {}) {
const url = new URL(base + '/api/v1/' + route);
for (const [name, value] of Object.entries(params)) {
if (value !== undefined && value !== null) url.searchParams.set(name, String(value));
}
const response = await fetch(url, {
headers: { Authorization: `Bearer ${key}` }
});
const body = await response.json().catch(() => ({}));
if (!response.ok) {
throw new Error(`Nudge API HTTP ${response.status}: ${body.message || body.error || 'Unknown error'}`);
}
return body;
}
console.log(await nudgeGet('mailboxes'));
console.log(await nudgeGet('opportunities', { limit: 10 }));
Required permissions
The API key needs nudge.mailboxes.read and nudge.conversations.read. Restrict it to a single workspace if the integration is client-specific.
Production notes
- Handle 429 by backing off and respecting the 60-requests-per-minute key limit.
- Never write API keys or email data to public logs.
- Do not run this secret-bearing code in the browser.
- Use your account's EU base URL for EU accounts.
Was this page helpful?