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

# LinkedIn API

> Options for posting using the LinkedIn API

The LinkedIn API has the following requirements and restrictions:

<ul class="custom-bullets">
  <li>The `post` field accepts up to 3,000 characters.</li>

  <li>
    LinkedIn will automatically preview the link in the post unless there is an image or video
    included. In the above example the image will show. Removing the image will cause the link
    preview to show. If the link preview cannot be retrieved, the post will still be published and a
    `linkPreviewFailed: true` field will be returned in the /post response.
  </li>

  <li>Hashtags are clickable in LinkedIn. Use the # symbol to specify a LinkedIn hashtag.</li>

  <li>
    If publishing a video and doesn't end in a known video extension such as mp4, please use the
    `isVideo` parameter. See the [/post endpoint](/apis/post/post) for details.
  </li>

  <li>
    LinkedIn video processing takes several minutes to complete. Please wait before trying the share
    URL or getting video analytics.
  </li>

  <li>LinkedIn limits 150 posts per day per LinkedIn account.</li>
  <li>Posting to LinkedIn Groups is not supported.</li>

  <li>
    LinkedIn also supports sending media without post text. If you do not want post text included
    send an empty String `post: ""`.
  </li>

  <li>You may link either a company page or a personal LinkedIn account.</li>

  <li>
    See [LinkedIn Media Guidelines](/media-guidelines/linkedin) and [LinkedIn
    Authorization](/dashboard/connect-social-accounts/linkedin) for more information.
  </li>
</ul>

<Warning>
  You must be a "Super Admin" or a "Content Admin" to connect a LinkedIn company page.{" "}
</Warning>

## Posting to LinkedIn

JSON for a basic post with a link and image to LinkedIn:

```json LinkedIn Post theme={"system"}
{
  "post": "The best LinkedIn post ever #best https://www.linkedin.com", // empty string is allowed
  "mediaUrls": ["https://img.ayrshare.com/012/gb.jpg"],
  "platforms": ["linkedin"]
}
```

## LinkedIn Options

You can set additional options for a post by using the `linkedInOptions` parameter.

```json LinkedIn Options theme={"system"}
{
  "linkedInOptions": {
    "altText": ["This is my best pic", "😃 here is the next one"],
    "disableShare": true,
    "targeting": {
      "countries": ["US", "IN", "DE", "GB"],
      "seniorities": ["Senior", "VP"],
      "degrees": ["Master of Digital Design", "Bachelor of Engineering"],
      "fieldsOfStudy": ["Consumer Economics", "Computer Games and Programming Skills"],
      "industries": ["Telecommunications Carriers", "Banking"],
      "jobFunctions": ["Information Technology", "Entrepreneurship"],
      "staffCountRanges": ["size_51_to_200", "size_5001_to_10000"]
    },
    "thumbNail": "https://example.com/thumbnail.jpg",
    "title": "Sample PPTX",
    "titles": ["This is an amazing video", "😃 here is the next one"],
    "visibility": "public"
  }
}
```

LinkedIn options are optional fields that can be used to control the post.

<ParamField body="altText" type="array of strings">
  The alternative text of images for accessibility and screen readers.

  See [LinkedIn Alternative Text](/apis/post/social-networks/linkedin#alternative-text) for more information.
</ParamField>

<ParamField body="disableShare" type="boolean" default={false}>
  Disable the ability for users to reshare the LinkedIn post.

  See [LinkedIn Disable Share](/apis/post/social-networks/linkedin#disable-share) for more information.
</ParamField>

<ParamField body="targeting" type="object">
  Target your organic posts to specific groups by countries, industry, job title, and more.

  Requires at least 300 followers in the targeted audience.

  See [LinkedIn Audience Targeting](/apis/post/social-networks/linkedin#audience-targeting) for more information.
</ParamField>

<ParamField body="thumbNail" type="string">
  The thumbnail of a video. Must be PNG or JPG, same dimensions as video, under 10MB. URL should end in .png or .jpg.

  See [LinkedIn Video Thumbnail](/apis/post/social-networks/linkedin#video-thumbnail) for more information.
</ParamField>

<ParamField body="title" type="string">
  The title of a document when posting PPT, PPTX, DOC, DOCX, or PDF files. Maximum length: 400 characters.

  If not specified, the filename is used.

  See [LinkedIn Documents](/apis/post/social-networks/linkedin#documents) for more information.
</ParamField>

<ParamField body="titles" type="array of strings">
  Title or media captions to LinkedIn images or videos.

  Each title corresponds to a media URL in order.

  See [LinkedIn Media Titles](/apis/post/social-networks/linkedin#media-titles) for more information.
</ParamField>

<ParamField body="visibility" type="string" default="public">
  The visibility of the post.

  Values: `public`, `connections`, or `loggedin`.

  See [LinkedIn Post Visibility](/apis/post/social-networks/linkedin#post-visibility) for more information.
</ParamField>

## Alternative Text

Add LinkedIn alternative text, also known as LinkedIn alt text, to a LinkedIn image. LinkedIn alt text is an accessibility feature used for additional user info and screen readers. LinkedIn does not support altText on videos or documents.

Use the `altText` in the `linkedInOptions` object.

```json LinkedIn Alt Text theme={"system"}
{
  "linkedInOptions": {
    "altText": ["This is my best pic", "😃 here is the next one"] // Array of Alt Texts
  }
}
```

Each alt text must correspond to an image in the `mediaUrls` array. The alt text will be applied to each image in order.

## Audience Targeting

LinkedIn allows you to target your organic posts to specific groups of users. You can target by countries, industry, job title, and more.

<Warning>
  LinkedIn targeting requires at least **300 followers in the targeted audience**. For example if
  you have 400 followers and target just users in the country US, but only 200 of your followers are
  in the US, the targeting will fail since the audience is too small.
</Warning>

Use the `targeting` object in the `linkedInOptions` object:

```json LinkedIn Audience Targeting theme={"system"}
{
  "linkedInOptions": {
    "targeting": {
      "countries": ["US", "IN", "DE", "GB"],
      "seniorities": ["Senior", "VP"],
      "degrees": ["Master of Digital Design", "Bachelor of Engineering"],
      "fieldsOfStudy": ["Consumer Economics", "Computer Games and Programming Skills"],
      "industries": ["Telecommunications Carriers", "Banking"],
      "jobFunctions": ["Information Technology", "Entrepreneurship"],
      "staffCountRanges": ["size_51_to_200", "size_5001_to_10000"]
    }
  }
}
```

The available targeting options are listed in the following JSON files:

<ul class="custom-bullets">
  <li>[LinkedIn Countries](https://logo.ayrshare.com/data/linkedin/countries.json)</li>
  <li>[LinkedIn Seniorities](https://logo.ayrshare.com/data/linkedin/seniorities.json)</li>
  <li>[LinkedIn Degrees](https://logo.ayrshare.com/data/linkedin/degrees.json)</li>
  <li>[LinkedIn Fields of Study](https://logo.ayrshare.com/data/linkedin/fieldsOfStudy.json)</li>
  <li>[LinkedIn Industries](https://logo.ayrshare.com/data/linkedin/industries.json)</li>
  <li>[LinkedIn Job Functions](https://logo.ayrshare.com/data/linkedin/jobFunctions.json)</li>

  <li>
    [LinkedIn Staff Count Ranges](https://logo.ayrshare.com/data/linkedin/staffCountRanges.json)
  </li>
</ul>

## Authorization Refresh

LinkedIn must be reauthorized *every year* via the Social Accounts page.

<ul class="custom-bullets">
  <li>
    An email and webhook social action notification will be sent 15 days in advance of authorization
    expiration.
  </li>

  <li>
    The refresh required date and remaining days can be retrieved from the
    [/user](/apis/user/overview) endpoint.
  </li>

  <li>
    The user will see on their social account linkage page an alert and a refresh button 30 days
    prior to expiration.
  </li>
</ul>

## Character Limits

Please see [LinkedIn Character Limits](/help-center/technical-support/character_limits#linkedin-character-limits) for more information.

## Disable Share

You can disable the ability for users to reshare the LinkedIn post by setting the `disableShare` field to `true` in the `linkedInOptions` object:

```json LinkedIn Disable Share theme={"system"}
{
  "linkedInOptions": {
    "disableShare": true
  }
}
```

## Documents

Use the API to post a document on LinkedIn. Supported file formats include: PPT, PPTX, DOC, DOCX, and PDF. Ensure the document is under 100MB in size and does not exceed 300 pages.

Below is a code sample demonstrating how to post a PPTX document with a title:

```json LinkedIn Document Post theme={"system"}
{
  "post": "What a great document",
  "platforms": ["linkedin"],
  "linkedInOptions": {
    "title": "Sample PPTX" // optional. If not specified, the file name used.
  },
  "mediaUrls": ["https://scholar.harvard.edu/files/torman_personal/files/samplepptx.pptx"]
}
```

The media URL provided must end in a known document extension: ppt, pptx, doc, docx, or pdf.

## LinkedIn Mentions

You may mention other LinkedIn organizations, i.e. company pages, or member profiles, i.e. individual profile pages, in your posts.

Ayrshare makes an attempt to resolve the @mention by doing a lookup on the handle.
If the @mention is not found, the @ will be removed from the post since LinkedIn will not accept posts with unresolved mentions.
Individual LinkedIn profiles cannot be mentioned.

<Warning>
  If any mention in a LinkedIn post cannot be resolved (due to privacy settings,
  account restrictions, or other platform limitations), LinkedIn may fail to
  render all mentions in that post as clickable links. This is LinkedIn's platform
  behavior and not an API issue. To avoid this, ensure all mentioned users and
  organizations allow mentions from your organization or consider posting mentions
  separately to isolate any problematic mentions.
</Warning>

Please review the [important rules](/testing/post-verification#mentions) on mentions.

### Organization Profiles

Mention another LinkedIn organization handle by adding `@handle` in the post text. The `@handle` is the name of the company or organization.
You can mention in posts, comments, and reply to comments.

For example,

<ul class="custom-bullets">
  <li>
    Ayrshare's LinkedIn company profile is
    [https://www.linkedin.com/company/ayrshare](https://www.linkedin.com/company/ayrshare) and the
    handle used would be *@ayrshare*.
  </li>

  <li>
    Zara's LinkedIn company profile is
    [https://www.linkedin.com/company/zara-sa/](https://www.linkedin.com/company/zara-sa/) and the
    handle used would be *@zara-sa*.
  </li>
</ul>

```json LinkedIn Mention theme={"system"}
{
  "post": "The best social media API @ayrshare ever!",
  "platforms": ["linkedin"]
}
```

### Member Profiles

Mention another LinkedIn member profile by adding `@vanity_name` or `@[John Smith]` in the post text.

1. `@vanity_name` is the vanity name of the member profile. For example in the member's profile URL `https://www.linkedin.com/in/vanity_name/`, the vanity name is `vanity_name`.
2. `@[John Smith]` is the person's full name. For example if the person's full name is `John Smith`, the mention would be `@[John Smith]`.

You can mention in posts, comments, and reply to comments.

```json LinkedIn Mention theme={"system"}
{
  "post": "The best social media API @[John Smith] and @ava_smith ever!",
  "platforms": ["linkedin"]
}
```

In the above example, John Smith and Ava Smith will be mentioned in the post - the first using their full name and the second using their vanity name.

**Important Notes:**

1. You must have a LinkedIn company page connected to your Ayrshare account to mention member
   profiles. If you connect your own personal LinkedIn account, you will not be able to mention other
   people's profiles.
2. LinkedIn only allows mentioning people who follow your organization / company page.

## Media Titles

Add title or media captions to LinkedIn images or videos.

Use the `titles` in the `linkedInOptions` object.

```json LinkedIn Media Titles theme={"system"}
{
  "linkedInOptions": {
    "titles": ["This is an amazing video", "😃 here is the next one"] // Array of Alt Texts
  }
}
```

Each title must correspond to an image or video in the `mediaUrls` array. The title will be applied to each image or video in order.

## Multi Image Posts

You may post up to *9 image URLs* in the `mediaUrls` to LinkedIn.

```json LinkedIn Multi Image Post theme={"system"}
{
  "mediaUrls": ["https://url1", ..., "https://url9"]
}
```

LinkedIn does not yet support carousel images for organic posts.

## Post Visibility

LinkedIn allows you to control the visibility of your posts.
You can set the visibility to public, connections only, or loggedin users only.
If no visibility is specified, the post will be "public" and visible to all LinkedIn users.

<ul class="custom-bullets">
  <li>
    `public`: The post will be visible to all LinkedIn users. Available for both company pages and
    personal LinkedIn connected accounts. Default if no visibility is specified.
  </li>

  <li>
    `connections`: The post will be visible to the 1st degree network of the owner (user profile).
    Available for personal LinkedIn connected accounts only.
  </li>

  <li>
    `loggedin`: The post will be visible to logged in LinkedIn users only. Available for both
    company pages and personal LinkedIn connected accounts.
  </li>
</ul>

Use the `visibility` field in the `linkedInOptions` object:

```json LinkedIn Post Visibility theme={"system"}
{
  "linkedInOptions": {
    "visibility": "public" // "public", "connections", or "loggedin"
  }
}
```

## Video Publishing Permissions

On LinkedIn, only users with specific permissions can publish videos to company pages:

1. Users with Admin permissions.
2. Users with Direct Sponsored Content (DSC) permissions.

Content Administrators do not have the ability to publish videos to LinkedIn company pages.

## Video Thumbnail

Set a LinkedIn thumbnail for a video. Send a remote URL of a PNG or JPG file that is the same dimensions as the video and less than 10 MB. URL should end in .png or .jpg.

Use the `thumbNail` in the `linkedInOptions` object.

```json LinkedIn Video Thumbnail theme={"system"}
{
  "linkedInOptions": {
    "thumbNail": "https://octodex.github.com/images/Fintechtocat.png"
  }
}
```

Please see here for more [examples of using the LinkedIn API](https://www.ayrshare.com/how-to-post-and-get-analytics-with-the-linkedin-api#linkedin-api-examples).
