All posts

LINKEDIN

LinkedIn API: A Practical Guide to Posting Programmatically

How posting through the LinkedIn API works: app setup, OAuth scopes, posting to profiles and pages, media uploads and the limits to plan for.

11 min read

Posting to LinkedIn programmatically means creating an app, getting approved for a product that grants the right OAuth scope, sending the member or page through a consent flow, and then sending a JSON body to POST https://api.linkedin.com/rest/posts. The API itself costs nothing. The work is in the approvals, the versioned headers and a few limits that catch people out after launch.

Everything below is from LinkedIn’s official documentation on Microsoft Learn, checked in November 2026. LinkedIn versions its APIs monthly, so confirm the current version before you build.

Is the LinkedIn API free?

Yes. There is no fee to call LinkedIn’s APIs, and no paid tier for posting. What you are actually asking for when you ask about cost is access, and that is granted per product rather than bought.

In the LinkedIn Developer Portal you create an app, associate it with a company page, then request products on the Products tab. Each product unlocks scopes. Self-serve products are approved immediately. The Community Management API, which covers posting as an organisation, requires an application and review.

Which product and scope do you need?

What you want to doScopeHow you get it
Post as a signed-in memberw_member_socialAdd the “Share on LinkedIn” product. Self-serve.
Identify the member and get their URNopenid, profileAdd “Sign In with LinkedIn using OpenID Connect”. Self-serve.
Post as a company pagew_organization_socialCommunity Management API. Requires review.
Read a page’s posts, comments and likesr_organization_socialCommunity Management API. Requires review.
Read a member’s own postsr_member_socialRestricted. Approved users only.

For the organisation scopes, the member who authorises your app must hold a page role on that organisation: Administrator, Content Admin or Direct Sponsored Content Poster. A valid token with the right scope still returns 403 if the person behind it has no role on the page. This is the single most common surprise when a team moves from posting as a person to posting as a brand.

How does the OAuth flow work?

Standard three-legged OAuth 2.0. Send the member to LinkedIn, get a code back, exchange the code for a token.

GET https://www.linkedin.com/oauth/v2/authorization
  ?response_type=code
  &client_id={your_client_id}
  &redirect_uri={your_callback_url}
  &state={random_anti_csrf_value}
  &scope=openid%20profile%20w_member_social

The member approves, and LinkedIn redirects to your callback with code and state. Check that state matches what you sent before you do anything else. The authorization code is valid for 30 minutes and is single use.

POST https://www.linkedin.com/oauth/v2/accessToken
Content-Type: application/x-www-form-urlencoded

grant_type=authorization_code
&code={code_from_callback}
&client_id={your_client_id}
&client_secret={your_client_secret}
&redirect_uri={your_callback_url}

Three details from this step that shape how you build:

  • Access tokens last 60 days. The response returns expires_in: 5184000 seconds.
  • Programmatic refresh tokens are not available to everyone. LinkedIn documents them as available to a limited set of partners. Without them, refreshing means sending the member through the authorisation screen again, which is silent if they are still signed in to LinkedIn and their token has not yet expired, and a visible prompt if not.
  • Changing your scopes invalidates existing tokens. Add a scope later and every connected user has to re-authorise.

Plan for re-authorisation from day one. A tool that quietly stops posting on day 61 is the classic version of this integration going wrong.

How do you get the author URN?

Every post needs an author, which is a URN rather than a name. For a member, call the OpenID Connect userinfo endpoint with the token and use the sub value:

GET https://api.linkedin.com/v2/userinfo
Authorization: Bearer {access_token}

→ { "sub": "abc123", ... }
→ author: "urn:li:person:abc123"

For a company page the format is urn:li:organization:{id}, and you find the ids the authorising member can post for through LinkedIn’s organization access control endpoint.

How do you create a text post?

The Posts API replaces the older ugcPosts API. Three headers are mandatory on every versioned call: the bearer token, the protocol version, and the API version in YYYYMM form.

curl -X POST 'https://api.linkedin.com/rest/posts' \
  -H 'Authorization: Bearer {token}' \
  -H 'X-Restli-Protocol-Version: 2.0.0' \
  -H 'LinkedIn-Version: 202610' \
  -H 'Content-Type: application/json' \
  --data '{
    "author": "urn:li:person:abc123",
    "commentary": "We shipped scheduling for Threads today.",
    "visibility": "PUBLIC",
    "distribution": {
      "feedDistribution": "MAIN_FEED",
      "targetEntities": [],
      "thirdPartyDistributionChannels": []
    },
    "lifecycleState": "PUBLISHED",
    "isReshareDisabledByAuthor": false
  }'

A success is 201, and the new post’s id comes back in the x-restli-id response header, looking like urn:li:share:6844785523593134080. Store that id. It is how you later fetch, edit or delete the post, and there is no other way to find it again reliably.

To post as a page, swap the author for the organisation URN. Nothing else about the request changes.

How do you attach an image?

Two steps. Initialise an upload to get an image URN and an upload URL, PUT the bytes to that URL, then reference the URN in the post.

POST https://api.linkedin.com/rest/images?action=initializeUpload
{ "initializeUploadRequest": { "owner": "urn:li:person:abc123" } }

→ { "value": { "uploadUrl": "https://...", "image": "urn:li:image:D4E10AQ..." } }

# upload the binary to uploadUrl, then:
"content": { "media": { "title": "Chart", "id": "urn:li:image:D4E10AQ..." } }

Videos and documents work the same way through the Videos API and Documents API, each returning its own URN type. Multi-image posts use the MultiImage API.

What can you not post through the API?

These are the limits people discover late, so they are worth knowing up front.

  • Organic carousels are not supported. Carousel content is sponsored only. The native-looking “carousel” most people mean on LinkedIn is a PDF document post, which you create through the Documents API.
  • Article posts do not scrape URLs. LinkedIn deliberately does not fetch a link preview for you. You set the thumbnail, title and description yourself, and the thumbnail must be uploaded through the Images API first.
  • Only some fields can be edited after publishing, mainly commentary and the call-to-action fields, using X-RestLi-Method: PARTIAL_UPDATE.
  • There is no batch delete. Deletes are one at a time, and they are idempotent, returning 204 either way.
  • Targeted organic posts need an audience above 300 members, so you cannot narrow a page post to a very small segment.

How do mentions and hashtags work?

Mentions go inside commentary with the URN attached, in the form @[Devtestco](urn:li:organization:2414183). The visible text has to match the entity’s name, and matching is case sensitive. For an organisation it must be the full name; for a person, one part of the name is enough. Get it wrong and it silently renders as plain text rather than erroring, which makes it easy to ship broken mentions.

Hashtags are typed normally as #coding. When you read a post back, LinkedIn returns them in a template form such as {hashtag|\#|coding}, so parse accordingly rather than assuming the text round-trips unchanged.

What are the rate limits?

LinkedIn’s Share on LinkedIn documentation lists a daily throttle of 150 requests per member and 100,000 requests per application, both measured in UTC. Exceeding them returns 429 TOO_MANY_REQUESTS.

The per-member limit is generous for publishing and tight for anything that polls. If you are checking post analytics on a schedule for every connected account, that budget disappears quickly, so cache reads and back off on 429 rather than retrying immediately.

Which errors should you handle?

StatusMeaningUsual cause
400MISSING_FIELD or INVALID_VALUE_FOR_FIELDA required field such as distribution or lifecycleState was omitted
401EMPTY_ACCESS_TOKENMissing header, or an expired 60-day token
403ACCESS_DENIEDScope not granted, or the member has no role on the page
422UNPROCESSABLE_ENTITYWell-formed request, contradictory values
429TOO_MANY_REQUESTSDaily throttle hit. Back off, do not retry straight away

How does versioning work, and what breaks?

Every call carries LinkedIn-Version: YYYYMM. Versions are retired on a schedule: LinkedIn’s documentation currently warns that Marketing version 202601 will be sunset on 15 January 2027. Pin the version in configuration rather than scattering it through your code, and put a calendar reminder against it. An integration that works for a year and then stops on a date nobody wrote down is the normal failure mode here.

Is scraping LinkedIn allowed instead?

No. Scraping LinkedIn is prohibited by its terms of use, and accounts and apps doing it get restricted. The API is the sanctioned route, and the approval process exists precisely because LinkedIn wants to know who is posting through it. If a tool offers LinkedIn automation without an OAuth consent screen, it is almost certainly driving a logged-in session rather than the API, and your account carries that risk.

Should you build this yourself?

Build it if LinkedIn is the only network you need, the posting is part of your own product, and you are comfortable owning token refreshes, version migrations and the review process. It is a few days of work to get a text post live and considerably longer to handle media, pages, retries and expiry properly.

Do not build it if what you actually want is scheduling across several networks. Every network has its own version of this document, with different scopes, different upload flows and different limits, and all of them change. Zempost already holds the approved apps for LinkedIn, X, Facebook, Instagram, YouTube, Pinterest, TikTok and Threads.

There is also a middle path worth knowing about. If you want posting inside your own scripts or an AI agent without touching OAuth, Zempost exposes a remote MCP server that handles the platform authentication for you, so an assistant can draft and schedule without you implementing any of the above. For the comparison with running your own instance, see self-hosted social schedulers.

FAQ

Questions people ask

Is the LinkedIn API free?

Yes. There is no fee to call LinkedIn’s APIs and no paid tier for posting. What is gated is access: you create an app in the Developer Portal and request products that grant scopes. Share on LinkedIn is self-serve, while the Community Management API needed for company pages requires review.

Which OAuth scope do you need to post to LinkedIn?

Use w_member_social to post as the signed-in member, granted by the Share on LinkedIn product. To post as a company page you need w_organization_social from the Community Management API, and the authorising member must hold an Administrator, Content Admin or Direct Sponsored Content Poster role on that page.

How long do LinkedIn access tokens last?

Access tokens are issued with a 60-day lifespan. Programmatic refresh tokens are documented as available only to a limited set of partners, so most apps refresh by sending the member through the authorisation screen again, which is silent if they are still signed in and their token has not expired.

How do you create a post with the LinkedIn Posts API?

Send a POST to https://api.linkedin.com/rest/posts with the bearer token, X-Restli-Protocol-Version 2.0.0 and a LinkedIn-Version header in YYYYMM form. The body needs author, commentary, visibility, distribution and lifecycleState. A success returns 201 with the new post id in the x-restli-id response header.

What are the LinkedIn API rate limits?

LinkedIn’s Share on LinkedIn documentation lists a daily throttle of 150 requests per member and 100,000 requests per application, measured in UTC. Exceeding them returns 429. The per-member budget is comfortable for publishing and tight for polling, so cache reads and back off rather than retrying immediately.

Is scraping LinkedIn allowed?

No. Scraping is prohibited by LinkedIn’s terms of use, and accounts and apps doing it get restricted. The API is the sanctioned route. If a tool offers LinkedIn automation with no OAuth consent screen, it is likely driving a logged-in session rather than the API, and your account carries that risk.

Bring Your Social Team Together Today

Compose, schedule and publish to every network from one workspace. Join 12,000+ teams your first 14 days are on us.

Start for Free
14-day free trialNo charge for 14 daysCancel anytime
Zempost

zempost

Zempost logo

Published

to 6 networks

+4