Skip to main content
DocsPlatformsAPI ReferenceAI & Integrations

LinkedIn

Publish posts, images, and videos to LinkedIn via the PostPeer API.

Overview

Publish text posts, images, videos, and articles to LinkedIn personal profiles and company pages. PostPeer handles OAuth, token management, and LinkedIn's media upload process.

Quick Start

1. Connect a LinkedIn Account

curl https://api.postpeer.dev/v1/connect/linkedin \
  -H "x-access-key: YOUR_API_KEY"

Response:

{
	"url": "https://www.linkedin.com/oauth/v2/authorization?..."
}

Redirect the user to the url. After authorization, the account is connected to your project. See Connect Accounts for the full OAuth flow.

2. Get the Account ID

curl https://api.postpeer.dev/v1/connect/integrations \
  -H "x-access-key: YOUR_API_KEY"

Find the integration with "platform": "linkedin" and note the id.

3. Publish a Post

curl -X POST "https://api.postpeer.dev/v1/posts" \
  -H "x-access-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Excited to share our latest update!",
    "platforms": [
      { "platform": "linkedin", "accountId": "li_123" }
    ],
    "publishNow": true
  }'
import PostPeer from '@postpeer/node';

const client = new PostPeer();
const { data } = await client.posts.create({
	body: {
		content: 'Excited to share our latest update!',
		platforms: [{ platform: 'linkedin', accountId: 'li_123' }],
		publishNow: true,
	},
});
from postpeer import PostPeer

with PostPeer() as client:
    post = client.posts.create(
        content="Excited to share our latest update!",
        platforms=[{"platform": "linkedin", "accountId": "li_123"}],
        publish_now=True,
    )

Response:

{
	"success": true,
	"status": "published",
	"postId": "post_abc123",
	"platforms": [
		{
			"platform": "linkedin",
			"success": true,
			"platformPostUrl": "https://www.linkedin.com/feed/update/urn:li:share:123456"
		}
	]
}

Features

Text Posts

Post text updates up to 3,000 characters.

Images & Videos

Attach media using the mediaItems array:

curl -X POST "https://api.postpeer.dev/v1/posts" \
  -H "x-access-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Here'\''s a look at what we'\''ve been building.",
    "platforms": [
      { "platform": "linkedin", "accountId": "li_123" }
    ],
    "mediaItems": [
      { "type": "image", "url": "https://cdn.example.com/photo.jpg" }
    ],
    "publishNow": true
  }'

Supported media:

  • Images: JPG, PNG, GIF (up to 9 per post)
  • Videos: MP4 (1 per post, up to 5 GB)

Visibility

Control post visibility using platformSpecificData.visibility:

  • "PUBLIC" (default) — visible to everyone
  • "CONNECTIONS" — visible to connections only
curl -X POST "https://api.postpeer.dev/v1/posts" \
  -H "x-access-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "An update for my network.",
    "platforms": [
      {
        "platform": "linkedin",
        "accountId": "li_123",
        "platformSpecificData": {
          "visibility": "CONNECTIONS"
        }
      }
    ],
    "publishNow": true
  }'

Mentions

Tag a company page in the post text using platformSpecificData.mentions. LinkedIn's API only supports mentioning organization/company pages, not personal profiles. Each entry maps an exact substring of content to the organization URN to mention; LinkedIn renders it as a clickable @mention. The text must appear exactly once in content, case-sensitive.

curl -X POST "https://api.postpeer.dev/v1/posts" \
  -H "x-access-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Great working with Acme Corp on this launch!",
    "platforms": [
      {
        "platform": "linkedin",
        "accountId": "li_123",
        "platformSpecificData": {
          "mentions": [
            { "text": "Acme Corp", "urn": "urn:li:organization:2414183" }
          ]
        }
      }
    ],
    "publishNow": true
  }'

Find a company's organization URN from its LinkedIn page URL or via the Connect Accounts integration data.

Platform-Specific Data

Pass this object in platformSpecificData when posting to LinkedIn.

FieldTypeRequiredValues and constraintsDescription
visibilitystringNoPUBLIC, CONNECTIONSPost visibility. "PUBLIC" = visible to everyone, "CONNECTIONS" = visible to connections only. Defaults to "PUBLIC".
mentionsobject[]NoItems: 0–30Tag company pages in the post text. Each entry maps an exact substring of content to the organization URN to mention; LinkedIn renders it as a clickable @mention. Only company pages can be mentioned, not personal profiles.
mentions[].textstringYes, in each mentions[] itemLength: 1–unboundedExact substring within the post content to turn into a clickable mention (e.g. "Acme Corp"). Case-sensitive, must appear exactly once in content.
mentions[].urnstringYes, in each mentions[] itemLinkedIn URN of the company page to mention, e.g. "urn:li:organization:12345". LinkedIn's API only supports mentioning organization/company pages, not personal profiles.
articleUrlstringNoFormat: uriURL for an article/link post. When provided, the post becomes a link share with a preview card.
articleTitlestringNoLength: 0–400Title for the article preview card. Max 400 characters.
articleDescriptionstringNoLength: 0–400Description for the article preview card. Max 400 characters.
documentTitlestringNoLength: 0–200Title shown on the document card when posting a PDF. Required by LinkedIn when a document media item is included.

Limits

LimitValue
Character limit3,000 per post
Images per post9
Videos per post1
Max video size5 GB
Max image size10 MB

On this page