Skip to main content
The Node.js SDK lets you interact with the Nango API from your server-side code. It is available on npm as @nangohq/node.

Installation

npm install @nangohq/node

Constructor

import { Nango } from '@nangohq/node';

const nango = new Nango({ secretKey: '<SECRET-KEY>' });
secretKey
string
required
Your secret key from the Nango dashboard. Go to Settings > Environment Settings to find it. Never expose this key in client-side code.
host
string
The URL of your Nango instance. Defaults to https://api.nango.dev (Nango Cloud). For local development use http://localhost:3003. For self-hosted instances, use your instance URL.

Rate limits

The SDK is rate-limited on a per-account basis. When the limit is exceeded the API returns a 429 Too Many Requests status code with a Retry-After header indicating how many seconds to wait.
try {
    const res = await nango.listIntegrations();
} catch (err) {
    if (err.response.status === 429) {
        const retryAfter = err.response.headers['retry-after'];
        // wait retryAfter seconds, then retry
    }
}

Providers

listProviders

Returns all available API providers in the Nango catalog.
const providers = await nango.listProviders(queries);
queries
object
Optional query parameters to filter providers.
Example response

getProvider

Returns a specific provider by name.
const provider = await nango.getProvider({ provider: 'github' });
provider
string
required
The provider name (e.g. github, slack, salesforce). See providers.yaml for all IDs.
Example response

Integrations

listIntegrations

Returns all integrations configured in your Nango environment.
const { configs } = await nango.listIntegrations();
Example response

getIntegration

Returns a specific integration by its unique key.
const integration = await nango.getIntegration(
    { uniqueKey: 'my-github-integration' },
    { include: ['webhook'] } // optional
);
uniqueKey
string
required
The integration ID (unique key) as shown in the Nango dashboard.
include
string[]
Include additional sensitive data. Allowed value: webhook.

createIntegration

Creates a new integration.
const integration = await nango.createIntegration({
    provider: 'github',
    unique_key: 'my-github-integration',
    display_name: 'GitHub',
    credentials: {
        oauth_client_id: '<CLIENT-ID>',
        oauth_client_secret: '<CLIENT-SECRET>'
    }
});
provider
string
required
The provider ID (e.g. github). See providers.yaml for all IDs.
unique_key
string
required
A unique identifier for this integration within your environment.
display_name
string
A human-readable name shown in the Connect UI.
credentials
Record<string, string>
Provider-specific credentials such as OAuth client ID and secret.

updateIntegration

Patches an existing integration. All fields are optional.
await nango.updateIntegration(
    { uniqueKey: 'my-github-integration' },
    { display_name: 'GitHub (Production)' }
);
uniqueKey
string
required
The integration ID to update.
body
object
required
Fields to update. Accepts display_name and credentials.

deleteIntegration

Deletes an integration and all its connections.
await nango.deleteIntegration('my-github-integration');
providerConfigKey
string
required
The integration unique key to delete.
Deleting an integration also deletes all connections associated with it. This action cannot be undone.

Connect sessions

createConnectSession

Creates a short-lived session token (valid for 30 minutes) used to open the Connect UI for a specific end user.
const { data } = await nango.createConnectSession({
    tags: {
        end_user_id: 'user-123',
        end_user_email: '[email protected]',
        organization_id: 'org-456'
    },
    allowed_integrations: ['github', 'slack'],
    integrations_config_defaults: {
        github: {
            connection_config: {
                repo: 'my-repo'
            }
        }
    }
});

const { token, connect_link, expires_at } = data;
tags
Record<string, string>
Key-value tags copied onto the created connection and included in auth webhooks. Use end_user_id, end_user_email, and organization_id for standard attribution.
allowed_integrations
string[]
Restrict the session to specific integration IDs. When omitted, all integrations are available.
integrations_config_defaults
object
Default configuration per integration. Useful for pre-populating connection config or allowing users to supply their own OAuth credentials.
Example response

createReconnectSession

Creates a session token to re-authorize an existing connection (e.g. when credentials have expired).
const { data } = await nango.createReconnectSession({
    connection_id: 'user-123-github',
    integration_id: 'my-github-integration',
    tags: {
        end_user_id: 'user-123'
    }
});
connection_id
string
required
The ID of the existing connection to reconnect.
integration_id
string
required
The integration ID for the connection.
tags
Record<string, string>
Tags to update on the connection during reconnection.
This method is only compatible with connections originally created with a session token.

Connections

listConnections

Returns a list of connections (without credentials).
const result = await nango.listConnections({
    connectionId: 'user-123',
    integrationId: 'my-github-integration',
    limit: 100,
    tags: { end_user_id: 'user-123' }
});
connectionId
string
Filter to a specific connection ID. May return multiple connections with the same ID across different integrations.
integrationId
string | string[]
Filter by one or more integration IDs.
tags
Record<string, string>
Filter by tag key-value pairs associated with connections.
limit
number
Maximum number of connections to return.
Example response

getConnection

Returns a specific connection with its credentials. Nango automatically refreshes expired tokens before returning.
const connection = await nango.getConnection(
    'my-github-integration', // providerConfigKey
    'user-123',              // connectionId
    false,                   // forceRefresh (optional)
    false                    // refreshToken (optional)
);
providerConfigKey
string
required
The integration ID.
connectionId
string
required
The connection ID.
forceRefresh
boolean
When true, forces a token refresh even if the current token is still valid. Defaults to false. Do not use at high traffic.
refreshToken
boolean
When true, includes the refresh token in the response. Defaults to false.
Nango refreshes tokens automatically when they expire within 15 minutes. Avoid caching tokens for more than 5 minutes.
Example response

deleteConnection

Deletes a specific connection.
await nango.deleteConnection('my-github-integration', 'user-123');
providerConfigKey
string
required
The integration ID.
connectionId
string
required
The connection ID to delete.

waitForConnection

Polls until a connection is created for the given end user and integration. Useful in agentic workflows where you start an OAuth flow and need to wait for it to complete.
const connection = await nango.waitForConnection(
    'my-github-integration', // integrationKey
    'user-123'               // userId (end_user_id tag value)
);
integrationKey
string
required
The integration ID to wait for.
userId
string
required
The end_user_id tag value to match against.
This method polls every 2 seconds for up to 60 seconds. If no connection is found within that window, it throws a timeout error. Pass an AbortSignal via the third argument to cancel early.

patchConnection

Updates metadata or tags on an existing connection.
await nango.patchConnection(
    { connectionId: 'user-123', provider_config_key: 'my-github-integration' },
    { tags: { plan: 'pro' } }
);

getMetadata

Returns the custom metadata stored on a connection.
const metadata = await nango.getMetadata('my-github-integration', 'user-123');

// With typed return value:
interface MyMetadata {
    repo: string;
    plan: string;
}
const typed = await nango.getMetadata<MyMetadata>('my-github-integration', 'user-123');
providerConfigKey
string
required
The integration ID.
connectionId
string
required
The connection ID.

setMetadata

Replaces the entire metadata object on one or more connections.
// Single connection
await nango.setMetadata('my-github-integration', 'user-123', {
    repo: 'my-repo',
    plan: 'pro'
});

// Multiple connections at once
await nango.setMetadata('my-github-integration', ['user-123', 'user-456'], {
    plan: 'enterprise'
});
providerConfigKey
string
required
The integration ID.
connectionId
string | string[]
required
One or more connection IDs to update.
metadata
Record<string, any>
required
The metadata to store. Replaces all existing metadata.

updateMetadata

Merges metadata into one or more connections without replacing existing keys.
await nango.updateMetadata('my-github-integration', 'user-123', {
    plan: 'enterprise'
});
providerConfigKey
string
required
The integration ID.
connectionId
string | string[]
required
One or more connection IDs to update.
metadata
Record<string, any>
required
The metadata keys to set. Only specified keys are updated; existing keys are preserved.

Proxy

Make authenticated HTTP requests to external APIs through Nango’s proxy. Nango automatically injects credentials, handles retries, and routes the request to the correct provider.
const config = {
    endpoint: '/repos/octocat/hello-world',
    providerConfigKey: 'my-github-integration',
    connectionId: 'user-123'
};

const res = await nango.get(config);    // GET
await nango.post(config);               // POST
await nango.put(config);                // PUT
await nango.patch(config);              // PATCH
await nango.delete(config);             // DELETE
ProxyConfiguration
endpoint
string
required
The API endpoint path (e.g. /repos/octocat/hello-world).
providerConfigKey
string
required
The integration ID used to look up credentials.
connectionId
string
required
The connection ID whose credentials to inject.
headers
Record<string, string>
Additional request headers. These are forwarded with a Nango-Proxy- prefix internally.
params
Record<string, string | number>
Query parameters to append to the request URL.
data
unknown
The request body for POST, PUT, and PATCH requests.
retries
number
Number of retries on failure (with exponential backoff). Defaults to 0.
retryOn
number[]
Additional HTTP status codes to retry on, in addition to 5xx, 429, and network errors.
baseUrlOverride
string
Override the provider’s default base URL. Required only if the base URL is not configured in providers.yaml.
responseType
'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'
The expected response type. Defaults to json.
Example: POST with body and headers
const response = await nango.post({
    endpoint: '/issues',
    providerConfigKey: 'my-github-integration',
    connectionId: 'user-123',
    headers: {
        'Accept': 'application/vnd.github+json'
    },
    data: {
        title: 'Bug report',
        body: 'Something is broken.'
    }
});

console.log(response.data); // GitHub API response

Syncs

listRecords

Returns synced records for a model. Supports pagination via cursors.
import type { GithubIssue } from './nango-integrations/models';

const result = await nango.listRecords<GithubIssue>({
    providerConfigKey: 'my-github-integration',
    connectionId: 'user-123',
    model: 'GithubIssue',
    limit: 100,
    filter: 'added,updated'
});

const { records, next_cursor } = result;
providerConfigKey
string
required
The integration ID.
connectionId
string
required
The connection ID.
model
string
required
The model name as defined in your integration functions.
variant
string
The sync variant to fetch records from. Defaults to the base variant.
cursor
string
Pagination cursor from a previous response’s _nango_metadata.cursor. Pass this to fetch only records that changed since the last cursor.
limit
number
Maximum number of records to return. Defaults to 100.
filter
string
Comma-separated filter for record state. Options: added, updated, deleted.
modifiedAfter
string
ISO 8601 timestamp. Only returns records modified after this time.
ids
string[]
Filter to specific record IDs.
Example response

triggerSync

Triggers a one-off execution of one or more syncs.
// Trigger a single sync
await nango.triggerSync('my-github-integration', ['github-issues'], 'user-123');

// Full resync from scratch
await nango.triggerSync('my-github-integration', ['github-issues'], 'user-123', {
    reset: true,
    emptyCache: true
});

// Using sync variants
await nango.triggerSync('my-github-integration', [
    { name: 'github-issues', variant: 'enterprise' },
    'github-repos'
], 'user-123');
providerConfigKey
string
required
The integration ID.
syncs
Array<string | { name: string; variant: string }>
required
Syncs to trigger. Pass an empty array to trigger all syncs.
connectionId
string
The connection ID. When omitted, the sync triggers for all applicable connections.
opts.reset
boolean
When true, clears the sync checkpoint and starts fresh.
opts.emptyCache
boolean
When true, deletes all cached records before triggering. Must be combined with reset: true.

startSync

Starts the schedule for one or more syncs. If already running, this has no effect.
await nango.startSync('my-github-integration', ['github-issues'], 'user-123');

pauseSync

Pauses the schedule for one or more syncs.
await nango.pauseSync('my-github-integration', ['github-issues'], 'user-123');

syncStatus

Returns the current status of one or more syncs.
// Specific syncs
const status = await nango.syncStatus('my-github-integration', ['github-issues'], 'user-123');

// All syncs for a connection
const allStatus = await nango.syncStatus('my-github-integration', '*', 'user-123');
Example response

updateSyncConnectionFrequency

Overrides the sync frequency for a specific connection.
// Override to every hour
await nango.updateSyncConnectionFrequency(
    'my-github-integration',
    'github-issues',
    'user-123',
    'every hour'
);

// Revert to default frequency
await nango.updateSyncConnectionFrequency(
    'my-github-integration',
    'github-issues',
    'user-123',
    null
);
providerConfigKey
string
required
The integration ID.
sync
string | { name: string; variant: string }
required
The sync name, or an object with name and variant.
connectionId
string
required
The connection ID to update the frequency for.
frequency
string | null
required
The new frequency string (e.g. 'every hour', 'every 30 minutes'). Uses vercel/ms notation. Minimum: 5 minutes. Pass null to revert to the default.

pruneRecords

Removes record payloads from Nango’s cache up to a given cursor. Record metadata is retained. Useful to reduce storage when you no longer need historical payloads.
const result = await nango.pruneRecords({
    providerConfigKey: 'my-github-integration',
    connectionId: 'user-123',
    model: 'GithubIssue',
    untilCursor: 'MjAyNC0wMi0yNlQw...'
});

console.log(`Pruned ${result.count} records. More available: ${result.has_more}`);

Actions

triggerAction

Triggers an action synchronously and returns the result.
const result = await nango.triggerAction(
    'my-github-integration',  // providerConfigKey
    'user-123',               // connectionId
    'create-issue',           // actionName
    {                         // input (optional)
        title: 'New bug',
        body: 'Description here'
    }
);
providerConfigKey
string
required
The integration ID.
connectionId
string
required
The connection ID.
actionName
string
required
The name of the action to trigger.
input
unknown
Input data passed to the action’s exec function.
Action output cannot exceed 10 MB.

triggerActionAsync

Triggers an action asynchronously and returns an ID to poll for the result.
const { id, statusUrl } = await nango.triggerActionAsync(
    'my-github-integration',
    'user-123',
    'export-data',
    { format: 'csv' }
);

// Later, poll for the result:
const result = await nango.getAsyncActionResult({ id });

getAsyncActionResult

Retrieves the result of an async action.
// By action ID
const result = await nango.getAsyncActionResult({ id: 'action_123456' });

// By status URL
const result = await nango.getAsyncActionResult({ statusUrl: '/action/action_123456' });

Webhooks

verifyIncomingWebhookRequest

Verifies that an incoming webhook request originates from Nango using HMAC-SHA256.
app.post('/webhook', (req, res) => {
    const isValid = nango.verifyIncomingWebhookRequest(
        req.body,    // raw body as a string
        req.headers  // request headers
    );

    if (!isValid) {
        return res.status(401).send('Invalid signature');
    }

    // handle the webhook
});
body
string
required
The raw HTTP body as a string. Do not parse it before passing.
headers
Record<string, unknown>
required
The HTTP request headers. The method looks for x-nango-hmac-sha256.

Integration functions

getScriptsConfig

Returns the configuration for all deployed integration functions. Useful for feeding integration metadata to an AI model.
// Nango format (default)
const config = await nango.getScriptsConfig();

// OpenAI function-calling format
const openaiConfig = await nango.getScriptsConfig('openai');
format
'nango' | 'openai'
The output format. Defaults to 'nango'.

Build docs developers (and LLMs) love