Accounts
Manage your connected LinkedIn accounts programmatically. See the Admin overview for initialization.
Get all accounts
try {
const { accounts, pendingConnectionSessions } = await admin.accounts.getAll();
for (const account of accounts) {
console.log(`${account.name} (${account.status}) – ${account.id}`);
console.log(`Profile: ${account.url}`);
console.log(`Headline: ${account.headline ?? 'not parsed yet'}`);
if (account.reconnectionLink) {
console.log(`Reconnect: ${account.reconnectionLink}`);
}
}
for (const session of pendingConnectionSessions) {
console.log(`Pending session: ${session.sessionId} (${session.status})`);
}
} catch (e) {
if (e instanceof LinkedApiError) {
console.error(`Critical Error - Type: ${e.type}, Message: ${e.message}`);
} else {
console.error('An unexpected, non-API error occurred:', e);
}
}Data
accounts– array of connected accounts, each containing:id– account UUID.name– LinkedIn account name.url– public LinkedIn profile URL for the connected account.avatarUrl/avatar_url– LinkedIn profile image URL, ornull/Nonewhen it has not been parsed yet.headline– LinkedIn headline shown below the account name, ornull/Nonewhen it has not been parsed yet.countryCode– country code selected during connection.identificationToken– token used in theidentification-tokenheader for Account API calls.status–active,frozen, orreconnection_required.connectedAt– ISO 8601 timestamp.reconnectionSessionId/reconnection_session_id– present whenstatusisreconnection_required.reconnectionLink/reconnection_link– present whenstatusisreconnection_required.
pendingConnectionSessions– array of pending sessions, each containingsessionIdandstatus.
For reconnection_required accounts, getAll creates a new reconnection session automatically when no active reconnection session exists.
Refresh account profile info
Use reparseAccountInfo to refresh the stored LinkedIn profile URL, avatar URL, headline, and name for a connected account. The method starts a background workflow and returns its workflowId; call getAll after the workflow completes to read the updated account fields.
const { workflowId } = await admin.accounts.reparseAccountInfo({
accountId: 'f9b4346a-...',
});
console.log('Reparse workflow:', workflowId);Params
accountId/account_id– UUID of the account to refresh.
Result
workflowId/workflow_id– workflow ID for the background reparse operation.
avatarUrl / avatar_url and headline can remain empty when LinkedIn does not render those values or the account session needs reconnection.
Connect a new account
Connecting a LinkedIn account is a multi-step process:
// 1. Create a connection session
const { sessionId, connectionLink } = await admin.accounts.createConnectionSession();
console.log('Open this link to connect:', connectionLink);
// 2. Poll until the session completes
const POLL_INTERVAL_MS = 3000;
const MAX_WAIT_MS = 2 * 60 * 1000;
const deadline = Date.now() + MAX_WAIT_MS;
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
let session;
do {
if (Date.now() >= deadline) {
throw new Error('Timed out waiting for connection session completion');
}
await sleep(POLL_INTERVAL_MS);
session = await admin.accounts.getConnectionSession({ sessionId });
} while (session.session.status === 'pending' ||
session.session.status === 'preparing' ||
session.session.status === 'serving' ||
session.session.status === 'streaming');
if (session.session.status === 'success') {
console.log('Account connected successfully!');
// 3. Get the new account details
const { accounts } = await admin.accounts.getAll();
console.log('Total accounts:', accounts.length);
}createConnectionSession data
sessionId– session UUID for tracking.connectionLink– URL to open in a browser to complete the LinkedIn login.
createConnectionSession errors
noAvailableSeats– no available seats. All seats are occupied by active accounts or pending connection sessions.dailyConnectionAttemptsExceeded– too many connection attempts in the last 24 hours.
Reconnect an account
Use createReconnectionSession for accounts with status equal to reconnection_required. The method cancels the previous active reconnection session, if one exists, and returns a fresh reconnection link. If an in-progress reconnection session is applying a pending proxy change, Linked API returns that existing session instead so the proxy change state is preserved.
const { reconnectionSessionId, reconnectionLink } =
await admin.accounts.createReconnectionSession({
accountId: 'f9b4346a-...',
});
console.log('Open this link to reconnect:', reconnectionLink);createReconnectionSession params
accountId/account_id– UUID of the account to reconnect.
createReconnectionSession data
reconnectionSessionId/reconnection_session_id– session UUID for tracking.reconnectionLink/reconnection_link– URL to open in a browser to complete LinkedIn reconnection.
createReconnectionSession errors
invalidRequestPayload– the account is not inreconnection_requiredstatus or cannot be reconnected.
getConnectionSession params
sessionId– session UUID.
Session statuses
| Status | Description |
|---|---|
pending | Session created, waiting for user to open the link |
preparing | Browser is being provisioned |
serving | Browser is ready, waiting for user to connect |
streaming | User is connected and logging in |
success | Login completed, account is being created |
expired | Session timed out |
error | An error occurred |
cancelled | Session was cancelled |
Cancel connection session
await admin.accounts.cancelConnectionSession({ sessionId: '990eef7a-...' });Params
sessionId– session UUID.
Disconnect account
await admin.accounts.disconnect({ accountId: 'f9b4346a-...' });Params
accountId– UUID of the account to disconnect.
Warning: This action is irreversible. The account must be reconnected from scratch.
Regenerate identification token
const { token } = await admin.accounts.regenerateIdentificationToken({
accountId: 'f9b4346a-...',
});
console.log('New token:', token);Params
accountId– UUID of the account.
Data
token– the new identification token.
Important: Update the
identificationTokenin all your SDK instances immediately after regeneration.
Errors
All account methods may throw:
linkedApiTokenRequired– missing token.invalidLinkedApiToken– invalid or expired token.accountNotFound– account does not exist or does not belong to you.tooManyRequests– rate limit exceeded.
For the complete HTTP API reference, see Admin API: Accounts.