How to post on LinkedIn via API
How to post on LinkedIn via API: publish text posts, image posts, and article shares programmatically with a single JSON request to POST /v1/posts, after connecting LinkedIn through GET /v1/connect/{platform} and retrieving your accountId. This guide preserves the exact fields shown in the worked examples — content, platforms, accountId, mediaItems, platformSpecificData, articleUrl, articleTitle, visibility, publishNow, scheduledFor, and timezone — so you can copy, adapt the placeholders, and check each failure case before sending.
What you need
You need an API key and a connected LinkedIn account. Retrieve the API key from the Access Keys page and keep it secret, treating it like a password. Every request in the examples below sends it in the x-access-key header. Before posting, confirm the LinkedIn account is connected and note its accountId, because each entry in the platforms array targets a specific account.
Step 1: Connect LinkedIn
Start the OAuth 2.0 connection flow with GET /v1/connect/{platform}, using linkedin as the platform value. Open the returned URL, sign in to LinkedIn, and authorize. Then list integrations to retrieve the accountId for the connected account. You can also connect accounts directly in the dashboard, which gives a visual overview of all connected accounts. Failure check: if the integrations list does not show LinkedIn, do not attempt to post — an unconnected account or a wrong accountId will not produce a valid LinkedIn target.
Step 2: Post a text update
Send a POST request to /v1/posts with content containing the post text, a platforms array containing one object with platform set to linkedin and accountId set to your connected account, and publishNow set to true for immediate publishing. That is the complete text post: no URN formatting, no versioning headers, and no nested specificContent objects are required in this request shape. Failure check: verify content is present, platform is exactly linkedin, and accountId matches an entry from the integrations list.
Posting with an image
Add a mediaItems array to the same POST /v1/posts request. Each item in the example uses type image and a url pointing to a publicly reachable image. In the described workflow, the service manages the LinkedIn-side handling for images, so the caller only supplies the URL. Failure check: confirm the image URL loads and returns an image before posting, and confirm mediaItems is an array of objects with type and url fields as shown.
Visibility settings
By default, posts are public and visible to anyone. To restrict visibility, set platformSpecificData.visibility inside the LinkedIn platform entry. The examples show two values: public and connections. Use connections when testing content or posting something intended only for your network. Failure check: an unsupported visibility value is not shown in the examples, so use only public or connections and verify the value is spelled exactly as shown.
Scheduling LinkedIn posts
Scheduling LinkedIn posts uses scheduledFor with a datetime value and timezone with an IANA timezone name, instead of publishNow. The example schedules for 2026-04-22T09:00:00 in America/New_York. Write the post when ready, schedule it for the intended time, and then check the posts listing to confirm the scheduled post is recorded with the expected status. Failure check: do not combine scheduledFor with publishNow in the same request as shown in the examples, and confirm the timezone string is a valid IANA name.
Why not use LinkedIn's API directly?
Working with the LinkedIn API directly brings several complications that a wrapper API abstracts away. Requests need a LinkedIn-Version header carrying a date string, and behavior can shift between versions. Author identity uses URN-style values such as urn:li:person:XXXX, so obtaining the right identifier takes an extra call. For images, LinkedIn expects a staged sequence involving an upload registration, a transfer to a signed location, and only then post creation tied to the resulting asset identifier. Some endpoints also sit behind partner or Marketing Developer Platform approval. Even a plain text update needs a heavily nested body containing fields such as specificContent, shareCommentary, and shareMediaCategory. Choose the wrapper approach when you want one consistent payload across platforms; choose the native LinkedIn API when you need direct control and can manage versioning, URNs, and staged media handling yourself.
Cross-post to multiple platforms
Add multiple objects to the platforms array to cross-post in one POST /v1/posts request. The example targets LinkedIn, Twitter, and Facebook with separate accountId values, and the content is delivered to each platform in its native format. This suits content that works across audiences, such as career advice or industry observations. A separate worked example shows publishing immediately to a single platform with publishNow, which illustrates mixing immediate delivery on one network with scheduled delivery on another. Failure check: confirm every accountId in the array belongs to a connected account for its stated platform, because one invalid target can affect the multi-platform request.
What's next and limitations
You now have the full workflow: connect LinkedIn, retrieve the accountId, and publish text posts, image posts, and article shares with Visibility settings and Scheduling LinkedIn posts options. Before relying on any request in production, verify the account connection, the accountId, the media URL, the article URL, the visibility value, and the scheduled time. Response bodies, status codes, error contracts, rate limits, and idempotency behavior are not specified in the examples on this page, so check the current API reference for those details rather than assuming them.
| Field | Where it appears | Example value | Notes |
|---|---|---|---|
| content | POST /v1/posts body | Post text | Main text of the post |
| platforms | POST /v1/posts body | Array of platform targets | Each entry targets one platform and account |
| platforms[].platform | POST /v1/posts body | Use linkedin for LinkedIn posts | |
| platforms[].accountId | POST /v1/posts body | your-account-id | Retrieved from the integrations list |
| platforms[].platformSpecificData | POST /v1/posts body | Object | LinkedIn-specific options such as article and visibility fields |
| platformSpecificData.articleUrl | platformSpecificData | https://yourblog.com/building-social-media-api | URL for article shares |
| platformSpecificData.articleTitle | platformSpecificData | What I Learned Building a Social Media API | Optional; LinkedIn can pull title from OG tags |
| platformSpecificData.visibility | platformSpecificData | public or connections | Default behavior described as public |
| mediaItems | POST /v1/posts body | Array of media objects | Used for image posts |
| mediaItems[].type | mediaItems entry | image | Type shown in the image example |
| mediaItems[].url | mediaItems entry | https://your-cdn.com/dashboard-screenshot.png | URL of the image |
| publishNow | POST /v1/posts body | true | Used for immediate publishing in examples |
| scheduledFor | POST /v1/posts body | 2026-04-22T09:00:00 | Used with timezone for scheduled posts |
| timezone | POST /v1/posts body | America/New_York | IANA timezone name for scheduled posts |
| x-access-key | Request header | YOUR_API_KEY | API key header on every request |
Fields and values are exactly as shown in the source worked examples; requiredness, types, and response behavior beyond the examples were not supplied.
| Failure case | What to check | How to verify |
|---|---|---|
| Missing API key | x-access-key header is present on every request | Confirm the header is included before sending |
| Unconnected LinkedIn account | LinkedIn appears in the integrations list | List integrations after completing the connect flow |
| Invalid accountId | accountId matches an entry from the integrations list | Compare the platforms[].accountId value against the list |
| Unsupported visibility value | visibility is public or connections | Use only the values shown in the examples |
| Scheduled versus immediate conflict | Use publishNow for immediate posts or scheduledFor plus timezone for scheduled posts, as shown | Confirm only the intended publishing mode is present in the request |
Checks are derived from the fields and flow shown in the examples; no response bodies, status codes, or error contracts were supplied, so none are stated here.
Frequently asked questions
How do I get the accountId for a LinkedIn post?
Use GET /v1/connect/{platform} for LinkedIn, then list integrations to retrieve the accountId to use in the platforms array. The connect request returns a URL to open, sign in to LinkedIn, and authorize.
How do I attach an image to a LinkedIn post?
Add a mediaItems array with an object whose type is image and whose url points to the image. The request example shows mediaItems with type image and a URL field; the underlying LinkedIn image upload flow is handled behind the scenes in the described workflow.
How do I restrict a LinkedIn post to connections only?
Set platformSpecificData.visibility to connections instead of the default public behavior described in the examples. The examples show public as the default and connections as the restricted option.
How do I schedule instead of publishing immediately?
Use scheduledFor with a datetime value and timezone with an IANA timezone name, as shown in the scheduled example, instead of publishNow. Confirm the scheduled post appears in the posts listing before relying on it.
curl {{API_BASE_URL}}/v1/connect/linkedin \
-H "x-access-key: YOUR_API_KEY"curl {{API_BASE_URL}}/v1/connect/integrations \
-H "x-access-key: YOUR_API_KEY"curl -X POST {{API_BASE_URL}}/v1/posts \
-H "x-access-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "A short example update.",
"platforms": [
{ "platform": "linkedin", "accountId": "your-account-id" }
],
"publishNow": true
}'curl -X POST {{API_BASE_URL}}/v1/posts \
-H "x-access-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "A short example update.",
"platforms": [
{ "platform": "linkedin", "accountId": "your-account-id" }
],
"mediaItems": [
{ "type": "image", "url": "https://your-cdn.com/dashboard-screenshot.png" }
],
"publishNow": true
}'curl -X POST {{API_BASE_URL}}/v1/posts \
-H "x-access-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "A short example update.",
"platforms": [
{
"platform": "linkedin",
"accountId": "your-account-id",
"platformSpecificData": {
"articleUrl": "https://yourblog.com/building-social-media-api",
"articleTitle": "What I Learned Building a Social Media API"
}
}
],
"publishNow": true
}'curl -X POST {{API_BASE_URL}}/v1/posts \
-H "x-access-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "A short example update.",
"platforms": [
{
"platform": "linkedin",
"accountId": "your-account-id",
"platformSpecificData": {
"visibility": "connections"
}
}
],
"publishNow": true
}'curl -X POST {{API_BASE_URL}}/v1/posts \
-H "x-access-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "A short example update.",
"platforms": [
{ "platform": "linkedin", "accountId": "your-account-id" }
],
"scheduledFor": "2026-04-22T09:00:00",
"timezone": "America/New_York"
}'curl -X POST {{API_BASE_URL}}/v1/posts \
-H "x-access-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "A short example update.",
"platforms": [
{ "platform": "linkedin", "accountId": "acc_li_123" },
{ "platform": "twitter", "accountId": "acc_tw_456" },
{ "platform": "facebook", "accountId": "acc_fb_789" }
],
"publishNow": true
}'curl -X POST {{API_BASE_URL}}/v1/posts \
-H "x-access-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "A short example update.",
"platforms": [
{ "platform": "twitter", "accountId": "acc_tw_456" }
],
"publishNow": true
}'