Managing LinkedIn Accounts

Create a New User First

As a reminder, to automate LinkedIn actions, you must first create a user in Captain Data using the Create a User endpoint. Example request:

curl --request POST \
  --url https://api.captaindata.com/v4/users \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <your_api_key>' \
  --data '{
  "full_name": "John Doe",
  "email": "[email protected]",
  "timezone": "Europe/Paris"
}'
email
string

The email of the user.

full_name
string

The user’s full name.

timezone
string

The user’s timezone.

The timezone field provisions a proxy IP matching that timezone/country. This needs to match the location where you log into your LinkedIn account to avoid restrictions.

When using a VPN, either: 1. Log out of your VPN before accessing social media, or 2. Ensure the “timezone” you send matches the country of the VPN IP address.

Connect LinkedIn Accounts to Users

After adding a User, you will Connect a User’s Integration in order to link the LinkedIn account to the user.

You can connect LinkedIn accounts in two ways:

  1. Synchronize cookies: Send LinkedIn authentication cookies (li_at and optionally li_a for Sales Navigator) to connect an account. This is useful when:

    • You already have the cookies from your own Chrome extension
    • You want to handle authentication yourself
    • You need precise control over cookie management
curl --request POST \
  --url https://api.captaindata.com/v4/users/{user_uid}/integrations/linkedin \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <your_api_key>' \
  --data '{
  "account_name": "LinkedIn Account #1",
  "auth_data": {
    "cookies": {
      "li_at": "<li_at_token>",
      "li_a": "<li_a_token>"
    }
  }
}'
account_name
string

Name of the LinkedIn account, e.g. “LinkedIn Account #1”. It’s generally the User’s full_name or email.

auth_data.cookies
object

For COOKIES integration types, provide authentication cookies here.

Important note: If you’re connecting an account for LinkedIn Sales Navigator, you need to send both cookies. If you don’t include the li_a token, the connection may not work properly with LinkedIn Sales Navigator. Including the li_a token will also speed up account synchronization.

  1. Connect natively: Provide the LinkedIn email and password to let Captain Data handle the authentication flow. This is recommended when:
    • You want a simpler integration
    • You don’t want to manage cookies
    • You need automatic cookie refresh
curl --request POST \
  --url https://api.captaindata.com/v4/users/{user_uid}/integrations/linkedin \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '{
  "auth_data": {
    "basic": {
      "username": "[email protected]",
      "password": "********"
    }
  }
}'

Best Practices for LinkedIn Automation

VPN and Timezone/Country Settings

  • Ensure the timezone in Captain Data matches your login location on LinkedIn.
  • Match your VPN’s country with Captain Data, or disconnect the VPN while logging in.

Managing Chrome Sessions

  • Use Captain Data’s Chrome Extension to automatically sync cookies, useful for testing purposes.
  • If you’re using multiple LinkedIn accounts on the same browser, you must create separate Chrome profiles:
    • Click your Chrome profile icon > Add a new profile.
    • Name it according to the LinkedIn account (e.g., “Account B”).
    • Log in to Captain Data and LinkedIn within this new session.

Updating cookies for Account A while logged into Account B can lead to mismatches and errors.

Refreshing Cookies

Cookies need refreshing if:

  • You log out of LinkedIn
  • LinkedIn expires or changes cookies
  • LinkedIn restricts the account due to excessive activity

Regular activity and following Smart Limits guidelines help prevent restrictions.

How to refresh cookies via API

To refresh accounts via API, use the PUT - Update a User’s Integration endpoint by passing the updated li_at and/or li_a cookie values:

If you build your own Chrome Extension, you should refresh cookies every 2 hours or so.

Here’s a code example for a Chrome Extension that runs in the background using alarms:

/**
 * Alarm to update cookies every X minutes.
 */
chrome.alarms.onAlarm.addListener(() => {
  // Ensure updateTokensHandle() is defined elsewhere in your code
  return updateTokensHandle();
});

// Set up the alarm when the extension is installed
chrome.runtime.onInstalled.addListener(async ({ reason }) => {
  const periodDurationMinutes = 120; // Every 2 hours

  // Create an alarm that will trigger every `periodDurationMinutes`
  await chrome.alarms.create("updateToken", {
    periodInMinutes: periodDurationMinutes,
  });

  console.log(
    "Alarm created to update token every " + periodDurationMinutes + " minutes"
  );
});

Complete source code is available on GitHub.

Smart Limits to Prevent Restrictions

Captain Data developed a unique Smart Limits feature to protect your users’ LinkedIn accounts. Learn more in this article LinkedIn Rate Limits.

LinkedIn Licenses Compatibility

Captain Data supports various LinkedIn licenses, each with unique features and limitations. Below is a breakdown of how each license integrates with Captain Data:

LicenseCaptain Data LevelCaptain Data CompatibilityInMails/MonthInvitations with NoteCRM Integration
LinkedIn BasicClassic✅ Yes05/monthNo
LinkedIn Premium CareerClassic❌ No5N/ANo
LinkedIn Premium BusinessClassic✅ Yes15400No
Sales Navigator CoreSales Navigator✅ Yes50400No

Today Captain Data handles LinkedIn Basic, LinkedIn Premium Business, and Sales Navigator Core which are defined as level in the LinkedIn integration.

By following this guide, you can safely automate LinkedIn activities with Captain Data, ensuring stable sessions and avoiding platform restrictions.

For further assistance, feel free to reach out to our support team at [email protected] 🙌