> ## Documentation Index
> Fetch the complete documentation index at: https://docs.api.nickautomations.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Getting LinkedIn Cookies

> How to extract the li_at and JSESSIONID cookies from your LinkedIn Sales Navigator browser session.

# Getting LinkedIn Cookies

The API needs your LinkedIn Sales Navigator session cookies to authenticate requests on your behalf. This guide shows you how to extract them from your browser.

## Which cookies you need

Two cookies are required:

| Cookie       | Purpose                                                 |
| ------------ | ------------------------------------------------------- |
| `li_at`      | Primary LinkedIn authentication token                   |
| `JSESSIONID` | Session identifier — also used to derive the CSRF token |

<Warning>
  **Cookies are session-specific.** They expire when your LinkedIn session ends (usually after a few hours to days). If the API returns `401 Authentication failed`, your cookies have likely expired — re-extract them and try again.
</Warning>

## Step-by-step: Chrome / Edge / Firefox

1. **Log in to LinkedIn Sales Navigator** — open [https://www.linkedin.com/sales](https://www.linkedin.com/sales) in your browser and make sure you're fully logged in.

2. **Open Developer Tools** — press `F12` (or `Cmd+Option+I` on Mac) to open DevTools.

3. **Go to Application > Cookies**:
   * **Chrome / Edge**: `Application` tab → `Storage` → `Cookies` → `https://www.linkedin.com`
   * **Firefox**: `Storage` tab → `Cookies` → `https://www.linkedin.com`

4. **Find the two cookies**:
   * Locate `li_at` in the cookie list and copy its **Value**
   * Locate `JSESSIONID` in the cookie list and copy its **Value** (including quotes)

5. **Build the cookie string** — combine them in the format the API expects:

   ```
   li_at=<li_at_value>; JSESSIONID=<JSESSIONID_value>
   ```

   For example:

   ```
   li_at=AQEDARSKH0YB7llVAAABi8Q2N...; JSESSIONID="ajax:0988250529423116538"
   ```

## Alternative: copy as cURL

A faster method if you're comfortable with DevTools:

1. Log in to LinkedIn Sales Navigator and navigate to a search page
2. Open DevTools (`F12`) → **Network** tab
3. Refresh the page
4. Right-click any request to `www.linkedin.com` → **Copy** → **Copy as cURL**
5. In the copied cURL command, find the `-H 'cookie: ...'` header — that entire string is your cookie value

<Note>
  The cookie string from this method includes all cookies, not just `li_at` and `JSESSIONID`. That's fine — the API will extract what it needs.
</Note>

## Providing cookies to the API

You can send cookies in two formats:

### Option A: Cookie string (recommended)

Pass the full cookie string in the `cookies` field:

```json theme={null}
{
  "cookies": "li_at=AQEDARSKH0YB7llVAAABi8Q2N...; JSESSIONID=\"ajax:0988250529423116538\"",
  "url": "https://www.linkedin.com/sales/search/people?query=...",
  "start": 0,
  "scraper_type": "contacts"
}
```

### Option B: List of cookie objects

If you're reading cookies programmatically (e.g., from a JSON export), pass them as a list:

```json theme={null}
{
  "cookies": [
    { "name": "li_at", "value": "AQEDARSKH0YB7llVAAABi8Q2N..." },
    { "name": "JSESSIONID", "value": "\"ajax:0988250529423116538\"" }
  ],
  "url": "https://www.linkedin.com/sales/search/people?query=...",
  "start": 0,
  "scraper_type": "contacts"
}
```

## Troubleshooting

| Problem                     | Likely cause                    | Solution                                              |
| --------------------------- | ------------------------------- | ----------------------------------------------------- |
| `401 Authentication failed` | Cookies expired                 | Re-extract cookies from a fresh browser session       |
| `422 Validation error`      | Missing `li_at` or `JSESSIONID` | Ensure both cookies are present in the string or list |
| `422 Validation error`      | Cookie too short                | The cookie string must be at least 100 characters     |

## Next steps

* [Quickstart](/guides/quickstart) — use your cookies in a real request
* [Pagination](/guides/pagination) — page through results
* [Scrape API Reference](/api-reference/scrape) — full endpoint documentation
