LinkedIn messaging API: how to send a message to a user
By Benjamin · Founder of Lempile · Updated
Checked against the official sources listed at the end.
LinkedIn has a Messages API, but only approved partners can use it, and only for messages a member chooses to send to their own connections. Page messaging and Sales Navigator are partner-only too. Outside those programs, apps send from the member's own account through an unofficial API. Here is each route, what it allows, and the code for the last.
Table of contents
- Does LinkedIn have a messaging API?
- How do I send a LinkedIn message to a user with an API?
- Who can you message on LinkedIn through an API?
- Can you send InMail through an API?
- How many LinkedIn messages can you send per day?
- Is it allowed to send LinkedIn messages through an API?
- Frequently asked questions
- Official sources checked
Does LinkedIn have a messaging API?
Yes, but none an ordinary app can sign up for. LinkedIn's Messages API sends a member's messages to their first-degree connections, and its documentation says its use is restricted to approved partners. The two other official routes are partner-only as well:
Swipe the table sideways to see every column →
| Route | What it covers | Who can use it |
|---|---|---|
| Messages API | A member's messages to one or more first-degree connections, or a reply in an existing conversation | Approved partners only |
| Page Messaging | A Company Page's messages, through the Community Management APIs | Marketing apps LinkedIn approves |
| Sales Navigator (SNAP) | Connecting and messaging leads, InMail included, inside a CRM | Approved partners; no new partners accepted |
Connection invitations follow the same pattern: LinkedIn's Invitations API carries the same “restricted to approved partners” note. See Does LinkedIn have an API? for everything else that is open.
What LinkedIn's Messages API requires
Even approved partners can only send what the member chose to send:
- Each message comes from a specific member action. LinkedIn says an automated or scheduled event doesn't count.
- The member opts in. A pre-written message is shown as a draft they can edit, and they send it themselves.
- The message is posted at, or around, the time of that action.
- No reward for the sender or the recipients, and no HTML in the message.
So it suits a “share with a connection” button, not a sequence of follow-ups.
How do I send a LinkedIn message to a user with an API?
Outside the partner programs, through an API that acts from the member's own LinkedIn account, such as Lempile or Unipile. The member connects the account once, through a hosted link, and your code then starts conversations and replies as them. Lempile answers Unipile's paths, so the same code works with both (see Lempile vs Unipile).
1. Connect the account
Create a hosted auth link (POST /api/v1/hosted/accounts/link), send it to your user, and keep the account_id you get back. Details in Authentication and accounts.
2. Start a conversation
curl -X POST "https://direct.lempile.com/api/v1/chats" \
-H "X-API-KEY: $LEMPILE_KEY" \
-H "Idempotency-Key: first-message-bob" \
-H "Content-Type: application/json" \
-d '{
"account_id": "'"$ACCOUNT_ID"'",
"attendees_ids": ["https://www.linkedin.com/in/bob-buyer"],
"text": "Hi Bob, quick question about your post."
}'
# 201 { "object": "ChatStarted", "chat_id": "2-QUFB…", "message_id": "2-_vpt…" }attendees_ids takes one person, as a profile URL, a public identifier or LinkedIn's member id. The Idempotency-Key means a retry never sends the message twice. Add ?dry_run=true to see exactly what LinkedIn would receive, without sending it.
import os
import requests
res = requests.post(
"https://direct.lempile.com/api/v1/chats",
headers={
"X-API-KEY": os.environ["LEMPILE_KEY"],
"Idempotency-Key": "first-message-bob",
},
json={
"account_id": os.environ["ACCOUNT_ID"],
"attendees_ids": ["https://www.linkedin.com/in/bob-buyer"],
"text": "Hi Bob, quick question about your post.",
},
timeout=60,
)
print(res.status_code, res.json()["chat_id"]) # 201 2-QUFB…3. Reply in a conversation
curl -X POST "https://direct.lempile.com/api/v1/chats/$CHAT_ID/messages" \
-H "X-API-KEY: $LEMPILE_KEY" \
-H "Idempotency-Key: reply-42" \
-H "Content-Type: application/json" \
-d '{ "account_id": "'"$ACCOUNT_ID"'", "text": "Thanks, Tuesday works for me." }'
# 201 { "object": "MessageSent", "message_id": "2-_vpt…" }4. Get replies as they arrive
Register a messaging webhook: Lempile keeps LinkedIn's own live connection open for the account and posts each new message, read receipt, reaction, edit or deletion to your URL within seconds. See Webhooks.
Who can you message on LinkedIn through an API?
The same people the member could message by hand. LinkedIn's Help Center lists them: 1st-degree connections and LinkedIn Pages for free; Premium members who turned on Open Profile; members of the same group or current coworkers, by message request; anyone else only by InMail, which takes a paid subscription. Lempile reads the profile's “Message” option first, as LinkedIn's own page does:
Swipe the table sideways to see every column →
| Case | What happens |
|---|---|
| A connection, an open profile, or someone who wrote first | The message is sent |
| Anyone else | 422 no_connection_with_recipient, unless you ask for an InMail |
| An InMail LinkedIn doesn't offer for this person | 422 not_allowed_inmail |
| An InMail with no credit left for this person | 422 insufficient_credits |
| The account itself | 422 invalid_recipient |
Can you send InMail through an API?
Officially, through Sales Navigator's Display Services, whose modules let approved partners' users message leads, InMail included; LinkedIn isn't accepting new Sales Navigator partners. Through Lempile, set linkedin[inmail]=true on a new chat: if LinkedIn offers an InMail to that person and the account has credit, it goes out as an InMail with your subject. Lempile's docs say the InMail send is built from LinkedIn's own web code and tested, but not yet confirmed with a real InMail.
An InMail takes a subject of up to 200 characters, which is required, and a body of up to 1,900, according to LinkedIn. Every other limit is in LinkedIn character limits.
How many LinkedIn messages can you send per day?
LinkedIn doesn't publish a number. Its Help Center says only that it limits how many messages a member can send in a certain time period, and that nobody can message a member who blocked them. Lempile's own pacing, per connected account:
Swipe the table sideways to see every column →
| Limit | Value |
|---|---|
| Calls at a time | One; the next waits up to 60 seconds for its turn |
| Gap between calls | 1.5 to 3 seconds |
| Writes (messages, invitations, posts, comments) | 150 in any 24 hours |
| LinkedIn calls of any kind | 1,500 in any 24 hours |
| After LinkedIn answers “too many” | 15 minutes of rest |
- A message takes up to 8,000 characters.
- Files go up to 20 MB each; a voice note up to 60 seconds, sent on its own.
- The limits belong to the account, never the key: two apps using one account share them.
- Every newly connected account starts with writes off; Lempile turns them on per account, and dry runs work meanwhile.
Details in Errors and limits. For invitations, see LinkedIn connection limits.
Is it allowed to send LinkedIn messages through an API?
LinkedIn's User Agreement asks members not to use bots or other unauthorized automated methods to send or redirect messages, and lets LinkedIn restrict accounts. Its own Messages API goes further: each message must come from a member's action, never an automated or scheduled event. Sending from a member's own account carries that risk, with Lempile as with any other tool, and no API can remove it.
Frequently asked questions
Does LinkedIn have a messaging API?
How do I send a LinkedIn message to a user with an API?
Can I message anyone on LinkedIn through an API?
Can I send a LinkedIn InMail with an API?
How many messages can you send on LinkedIn per day?
How do I receive LinkedIn replies in my app?
Is it allowed to send LinkedIn messages through an API?
Official sources checked
Read on 3 December 2026.
- Microsoft Learn: LinkedIn Messages API: https://learn.microsoft.com/en-us/linkedin/shared/integrations/communications/messages
- Microsoft Learn: LinkedIn Invitations API: https://learn.microsoft.com/en-us/linkedin/shared/integrations/communications/invitations
- Sales Navigator Application Platform: https://learn.microsoft.com/en-us/linkedin/sales/
- LinkedIn Marketing Developer Terms (Page Messaging): https://www.linkedin.com/legal/l/marketing-api-terms
- LinkedIn Help: Send messages on LinkedIn: https://www.linkedin.com/help/linkedin/answer/a554575
- LinkedIn Help: InMail character limits: https://www.linkedin.com/help/linkedin/answer/a411986
- LinkedIn User Agreement: https://www.linkedin.com/legal/user-agreement