How to Like and Comment on LinkedIn Posts via API: A Developer's Guide
TL;DR
Learn how to programmatically add reactions (like, love, insightful) and post comments on LinkedIn using the Postpost API. Complete code examples in JavaScript, Python, and cURL.
Why Automate LinkedIn Engagement?
LinkedIn engagement — liking posts and leaving thoughtful comments — is one of the most effective ways to grow your professional network. But doing it manually at scale is time-consuming.
With the Postpost API, you can programmatically:
- React to posts with any of LinkedIn's 6 reaction types
- Comment on posts in your network
- Reply to existing comments (nested threads)
- Remove reactions and comments when needed
This guide walks you through every endpoint with working code examples.
Prerequisites
Before you start, you'll need:
- A Postpost account with an API key (starts with
sk_) - A LinkedIn account connected via the Postpost dashboard
- Your LinkedIn
platformId(find it via the List Connections endpoint)
Part 1: Reacting to LinkedIn Posts
LinkedIn supports 6 reaction types:
Add a Reaction
Endpoint: POST https://api.postpost.dev/api/v1/linkedin-reactions
JavaScript
const response = await fetch('https://api.postpost.dev/api/v1/linkedin-reactions', { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-postpost-key': 'YOUR_API_KEY' }, body: JSON.stringify({ postedId: 'urn:li:ugcPost:7429953213384187904', reactionType: 'LIKE', platformId: 'linkedin-ABC123' }) });
const data = await response.json(); console.log(data); // { success: true, reaction: { reactionType: “LIKE” } }
Python
import requests
response = requests.post( ‘https://api.postpost.dev/api/v1/linkedin-reactions’, headers={ ‘Content-Type’: ‘application/json’, ‘x-postpost-key’: ‘YOUR_API_KEY’ }, json={ ‘postedId’: ‘urn:li:ugcPost:7429953213384187904’, ‘reactionType’: ‘LIKE’, ‘platformId’: ‘linkedin-ABC123’ } ) print(response.json())
cURL
curl -X POST https://api.postpost.dev/api/v1/linkedin-reactions \
-H "Content-Type: application/json" \
-H "x-postpost-key: YOUR_API_KEY" \
-d '{
"postedId": "urn:li:ugcPost:7429953213384187904",
"reactionType": "LIKE",
"platformId": "linkedin-ABC123"
}'
Remove a Reaction
To unlike or remove any reaction:
await fetch('https://api.postpost.dev/api/v1/linkedin-reactions', {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
'x-postpost-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
postedId: 'urn:li:ugcPost:7429953213384187904',
platformId: 'linkedin-ABC123'
})
});
Change a Reaction
LinkedIn allows only one reaction per post. To change it, remove the existing reaction first, then add the new one:
// Remove old reaction await fetch('https://api.postpost.dev/api/v1/linkedin-reactions', { method: 'DELETE', headers: { 'Content-Type': 'application/json', 'x-postpost-key': 'YOUR_API_KEY' }, body: JSON.stringify({ postedId: 'urn:li:ugcPost:7429953213384187904', platformId: 'linkedin-ABC123' }) });
// Add new reaction await fetch(‘https://api.postpost.dev/api/v1/linkedin-reactions’, { method: ‘POST’, headers: { ‘Content-Type’: ‘application/json’, ‘x-postpost-key’: ‘YOUR_API_KEY’ }, body: JSON.stringify({ postedId: ‘urn:li:ugcPost:7429953213384187904’, reactionType: ‘INTEREST’, platformId: ‘linkedin-ABC123’ }) });
Part 2: Commenting on LinkedIn Posts
Post a Comment
Endpoint: POST https://api.postpost.dev/api/v1/linkedin-comments
JavaScript
const response = await fetch('https://api.postpost.dev/api/v1/linkedin-comments', { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-postpost-key': 'YOUR_API_KEY' }, body: JSON.stringify({ postedId: 'urn:li:ugcPost:7429953213384187904', message: 'Great insights! This is exactly what our team has been discussing.', platformId: 'linkedin-ABC123' }) });
const data = await response.json(); console.log(data); // { // success: true, // comment: { // id: “7434695495614312448”, // commentUrn: “urn:li:comment:(urn:li:ugcPost:xxx,7434695495614312448)”, // message: { text: “Great insights! …” } // } // }
Python
import requests
response = requests.post( ‘https://api.postpost.dev/api/v1/linkedin-comments’, headers={ ‘Content-Type’: ‘application/json’, ‘x-postpost-key’: ‘YOUR_API_KEY’ }, json={ ‘postedId’: ‘urn:li:ugcPost:7429953213384187904’, ‘message’: ‘Great insights! This is exactly what our team has been discussing.’, ‘platformId’: ‘linkedin-ABC123’ } ) print(response.json())
cURL
curl -X POST https://api.postpost.dev/api/v1/linkedin-comments \
-H "Content-Type: application/json" \
-H "x-postpost-key: YOUR_API_KEY" \
-d '{
"postedId": "urn:li:ugcPost:7429953213384187904",
"message": "Great insights! This is exactly what our team has been discussing.",
"platformId": "linkedin-ABC123"
}'
Reply to a Comment
To create a threaded reply, add the parentComment parameter:
await fetch('https://api.postpost.dev/api/v1/linkedin-comments', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-postpost-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
postedId: 'urn:li:ugcPost:7429953213384187904',
message: 'Totally agree with your point!',
platformId: 'linkedin-ABC123',
parentComment: 'urn:li:comment:(urn:li:ugcPost:xxx,7434695495614312448)'
})
});
Delete a Comment
await fetch('https://api.postpost.dev/api/v1/linkedin-comments', {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
'x-postpost-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
postedId: 'urn:li:ugcPost:7429953213384187904',
commentId: 'urn:li:comment:(urn:li:ugcPost:xxx,7434695495614312448)',
platformId: 'linkedin-ABC123'
})
});
Part 3: Getting the Post URN
The postedId parameter requires a LinkedIn URN — not the URL you see in your browser.
Important: LinkedIn URLs use urn:li:activity:xxx format, but the API requires urn:li:share:xxx or urn:li:ugcPost:xxx.
For posts you created via Postpost, retrieve the URN from the get-post endpoint:
const response = await fetch( 'https://api.postpost.dev/api/v1/get-post/YOUR_POST_GROUP_ID', { headers: { 'x-postpost-key': 'YOUR_API_KEY' } } );
const data = await response.json(); const linkedInUrn = data.posts[0].postedId; // e.g., “urn:li:share:7434685316856377344”
Part 4: Putting It All Together
Here's a complete workflow that reacts to a post and leaves a comment:
const API_KEY = process.env.POSTPOST_API_KEY; const PLATFORM_ID = 'linkedin-ABC123'; const BASE_URL = 'https://api.postpost.dev/api/v1';async function engageWithPost(postUrn, reactionType, comment) { const headers = { ‘Content-Type’: ‘application/json’, ‘x-postpost-key’: API_KEY };
// Step 1: Add a reaction const reactionRes = await fetch(
${BASE_URL}/linkedin-reactions, { method: ‘POST’, headers, body: JSON.stringify({ postedId: postUrn, reactionType, platformId: PLATFORM_ID }) }); console.log(‘Reaction:’, (await reactionRes.json()).success);// Step 2: Post a comment const commentRes = await fetch(
${BASE_URL}/linkedin-comments, { method: ‘POST’, headers, body: JSON.stringify({ postedId: postUrn, message: comment, platformId: PLATFORM_ID }) }); const commentData = await commentRes.json(); console.log(‘Comment ID:’, commentData.comment?.id);return commentData; }
// Usage await engageWithPost( ‘urn:li:ugcPost:7429953213384187904’, ‘INTEREST’, ‘Excellent post! The data really backs up your thesis.’ );
Common Errors
| Reaction | API Value | Icon |
|---|---|---|
| Like | LIKE |
Thumbs up |
| Celebrate | PRAISE |
Fire |
| Love | EMPATHY |
Heart |
| Insightful | INTEREST |
Lightbulb |
| Support | APPRECIATION |
Clapping hands |
| Funny | ENTERTAINMENT |
Laughing face |
| Error | Cause | Fix |
|---|---|---|
"postedId is required" |
Missing post URN | Include postedId in request body |
"Invalid postedId" |
Wrong URN format | Use urn:li:share:xxx or urn:li:ugcPost:xxx |
"Invalid reactionType" |
Typo in reaction | Use one of: LIKE, PRAISE, EMPATHY, INTEREST, APPRECIATION, ENTERTAINMENT |
"LinkedIn connection not found" |
Wrong platformId | Check your connections via List Connections |
"Invalid API key" |
Bad API key | Verify your key at postpost.dev/dashboard |
Tips for LinkedIn Engagement at Scale
- Add delays between requests — LinkedIn has rate limits. Add at least 1 second between API calls.
- Use meaningful comments — Generic comments get flagged. Write substantive, relevant responses.
- Mix reaction types — Don't just "like" everything. Use "Insightful" for thought leadership posts, "Celebrate" for announcements.
- Track engagement with MCP — If you use Claude, Cursor, or another AI assistant, Postpost's MCP server lets you engage with LinkedIn posts conversationally.
Bonus: Use Claude Code or Cursor Instead of Writing Code
Don't want to write API calls? Postpost's MCP server lets you like, comment, and mention people on LinkedIn using plain English — directly from Claude Code or Cursor.
Step 1: Connect Postpost MCP to Claude Code
Run this single command in your terminal:
claude mcp add postpost --transport http https://mcp.postpost.dev --header "Authorization: Bearer sk_YOUR_API_KEY"
Or add it to your global config at ~/.claude.json:
{
"mcpServers": {
"postpost": {
"type": "http",
"url": "https://mcp.postpost.dev",
"headers": {
"Authorization": "Bearer sk_YOUR_API_KEY"
}
}
}
}
Step 1 (alt): Connect Postpost MCP to Cursor
Create .cursor/mcp.json in your project root:
{
"mcpServers": {
"postpost": {
"type": "http",
"url": "https://mcp.postpost.dev",
"headers": {
"Authorization": "Bearer sk_YOUR_API_KEY"
}
}
}
}
Restart Cursor, and Postpost's 18 tools will appear in the AI chat.
Step 2: Like and React to Posts in Natural Language
Once connected, just talk to Claude or Cursor's AI chat:
You: Like this LinkedIn post urn:li:ugcPost:7429953213384187904
Claude: Done! I've added a LIKE reaction to the post.
You: React with "insightful" to my colleague's latest LinkedIn post
Claude: Done! I've added an INTEREST (lightbulb) reaction to the post.
Step 3: Comment on Posts Conversationally
You: Comment "Great insights! This is exactly what our team has been discussing." on this LinkedIn post urn:li:ugcPost:7429953213384187904
Claude: Done! I've posted your comment:
Post: Product announcement by Tech Company
Your comment: "Great insights! This is exactly what our team has been discussing."
Comment ID: 7434695495614312448
You: Reply to that comment with "Thanks for the detailed response!"
Claude: Done! Your reply has been posted as a nested comment.
Step 4: Mention People and Companies
You can @mention LinkedIn members and companies in posts created via MCP. The mention syntax is @{urn:li:person:ID|Display Name} for people and @{urn:li:organization:ID|Company Name} for companies.
You: Schedule a LinkedIn post for tomorrow at 9am thanking John Smith (urn:li:person:123456) for his help on our project
Claude: Done! I've scheduled the post with the mention:
Content: "Thanks to @John Smith for the amazing collaboration on this project!"
Scheduled: Tomorrow at 9:00 AM
The mention will appear as a clickable link to John's profile, and he'll receive a notification.
You: Post to LinkedIn announcing our partnership with Acme Corp (urn:li:organization:789012) and mention Jane Doe (urn:li:person:456789)
Claude: Posted! Both mentions will appear as clickable links:
• @Jane Doe → links to her profile
• @Acme Corp Inc → links to their company page
Important for mentions: The display name must exactly match the LinkedIn profile name (case-sensitive), including company suffixes like "Inc" or "LLC". If it doesn't match, the mention will render as plain text instead of a clickable link.
Why Use MCP Instead of Direct API Calls?
- No code required — just describe what you want in natural language
- Context-aware — Claude remembers previous posts, so you can say "reply to that comment" or "unlike that post"
- Multi-step workflows — "React with insightful and leave a comment" in a single message
- Works in your IDE — engage with LinkedIn without leaving Claude Code or Cursor
- 18 tools available — beyond reactions and comments, you can schedule posts, check analytics, manage connections, and more
What's Next?
- Full API Reference — All parameters and error codes
- LinkedIn Mentions Guide — Tag people and companies in posts
- MCP Integration — Use AI assistants to manage LinkedIn engagement
- LinkedIn Analytics — Track your engagement performance
Related Articles
Unlock advanced search twitter: Expert Tips & Tricks
Complete guide to X (Twitter) Advanced Search in 2026. Learn all 20+ search operators, Boolean logic, engagement filters, geo-targeting, and ready-to-use query templates for brand monitoring, content research, and competitive analysis.
8 Proven Strategies: Best Time to Post on Instagram 2025
Master Instagram timing with 8 proven strategies. Understand the algorithm and reach a wider audience with optimal post times.
Best Time to Post on LinkedIn in 2026 (Data From 2M+ Posts)
The best time to post on LinkedIn in 2026 is Tuesday through Thursday between 10:00 AM and 12:00 PM. Data from 2M+ posts reveals the optimal days, times, and content formats for maximum engagement — plus how LinkedIn's new Depth Score algorithm changes your posting strategy.
Discover the Best Time to Post on TikTok – Tips for 2025
Find the optimal posting times on TikTok to maximize reach and engagement based on your audience behavior.