# Limits

Configure and monitor rate limits for your LinkedIn accounts with the SDK: view defaults, check usage, set custom limits, and reset.

Configure and monitor rate limits for your LinkedIn accounts. See the [Admin overview](/sdks/admin-overview) for initialization.

## Get defaults

Get the system default limits. These are applied when an account has no custom limits or after resetting.

```typescript
try {
  const { limits } = await admin.limits.getDefaults();

  for (const limit of limits) {
    console.log(`${limit.category} (${limit.period}): max ${limit.maxValue}, enabled: ${limit.isEnabled}`);
  }
} 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);
  }
}
```

```python
from linkedapi import LinkedApiError

try:
    limits = admin.limits.get_defaults().limits

    for limit in limits:
        print(f"{limit.category} ({limit.period}): max {limit.max_value}, enabled: {limit.is_enabled}")
except LinkedApiError as e:
    print(f"Critical Error - Type: {e.type}, Message: {e.message}")
except Exception as error:
    print("An unexpected, non-API error occurred:", error)
```

### Data

Array of limit objects:

- `category` – limit category (see table below).
- `period` – `daily`, `weekly`, or `monthly`.
- `maxValue` – maximum allowed actions.
- `isEnabled` – whether this limit is enforced.

### Limit categories

| Category | Description |
|----------|-------------|
| `stPersonProfileViews` | Standard LinkedIn profile views |
| `stCompanyPageViews` | Standard LinkedIn company page views |
| `stConnectionRequests` | Connection requests sent |
| `stMessages` | Messages sent |
| `stSearchQueries` | LinkedIn search queries |
| `stReactions` | Post reactions |
| `stComments` | Post comments |
| `stPosts` | Posts created |
| `nvPersonProfileViews` | Sales Navigator profile views |
| `nvCompanyPageViews` | Sales Navigator company page views |
| `nvMessages` | Sales Navigator messages |

## Get account limits

```typescript
const { limits } = await admin.limits.get({ accountId: 'f9b4346a-...' });
```

```python
from linkedapi import GetLimitsParams

limits = admin.limits.get(GetLimitsParams(account_id="f9b4346a-...")).limits
```

### Params

- `accountId` – account UUID.

## Get usage

Check current usage against configured limits.

```typescript
const { usage } = await admin.limits.getUsage({ accountId: 'f9b4346a-...' });

for (const entry of usage) {
  const remaining = entry.maxValue - entry.currentValue;
  console.log(`${entry.category} (${entry.period}): ${entry.currentValue}/${entry.maxValue} (${remaining} remaining)`);
}
```

```python
from linkedapi import GetLimitsUsageParams

usage = admin.limits.get_usage(GetLimitsUsageParams(account_id="f9b4346a-...")).usage

for entry in usage:
    remaining = entry.max_value - entry.current_usage
    print(f"{entry.category} ({entry.period}): {entry.current_usage}/{entry.max_value} ({remaining} remaining)")
```

### Params

- `accountId` – account UUID.

### Data

Array of usage objects:

- `category` – limit category.
- `period` – `daily`, `weekly`, or `monthly`.
- `maxValue` – maximum allowed actions.
- `currentValue` – actions performed in the current period.
- `isEnabled` – whether this limit is enforced.

## Set limits

Set or update limits for an account. Only the specified limits are created or updated; other limits remain unchanged.

```typescript
await admin.limits.set({
  accountId: 'f9b4346a-...',
  limits: [
    {
      category: 'stMessages',
      period: 'daily',
      maxValue: 25,
      isEnabled: true,
    },
    {
      category: 'stConnectionRequests',
      period: 'weekly',
      maxValue: 30,
    },
  ],
});
```

```python
from linkedapi import SetLimitEntry, SetLimitsParams

admin.limits.set(
    SetLimitsParams(
        account_id="f9b4346a-...",
        limits=[
            SetLimitEntry(
                category="stMessages",
                period="daily",
                max_value=25,
                is_enabled=True,
            ),
            SetLimitEntry(
                category="stConnectionRequests",
                period="weekly",
                max_value=30,
            ),
        ],
    )
)
```

### Params

- `accountId` – account UUID.
- `limits` – array of limit configurations:
  - `category` – limit category.
  - `period` – `daily`, `weekly`, or `monthly`.
  - `maxValue` – maximum allowed actions (>= 0).
  - `isEnabled` – whether this limit is enforced (default: `true`).

## Delete limits

Remove specific limits from an account. The account will fall back to default behavior for removed limits.

```typescript
await admin.limits.delete({
  accountId: 'f9b4346a-...',
  limits: [
    { category: 'stMessages', period: 'daily' },
    { category: 'stConnectionRequests', period: 'weekly' },
  ],
});
```

```python
from linkedapi import DeleteLimitEntry, DeleteLimitsParams

admin.limits.delete(
    DeleteLimitsParams(
        account_id="f9b4346a-...",
        limits=[
            DeleteLimitEntry(category="stMessages", period="daily"),
            DeleteLimitEntry(category="stConnectionRequests", period="weekly"),
        ],
    )
)
```

### Params

- `accountId` – account UUID.
- `limits` – array of limits to remove, each with `category` and `period`.

## Reset to defaults

Reset all limits for an account to the system defaults.

```typescript
await admin.limits.resetToDefaults({ accountId: 'f9b4346a-...' });
```

```python
from linkedapi import ResetLimitsParams

admin.limits.reset_to_defaults(ResetLimitsParams(account_id="f9b4346a-..."))
```

### Params

- `accountId` – account UUID.

## Errors

All limit 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: Limits](/docs/admin-limits).
