LinkedIn DM API: send direct messages from code
Swarmhit's LinkedIn DM API sends a direct message from a connected sender to one of its 1st-degree connections with a single POST to /accounts/{id}/messages. The same message can run as a step in a campaign, where the sequencer schedules it, rotates senders, stops on reply and A/B tests up to five variants. Every send counts against the sender's daily message cap, enforced on the server.
Endpoints
POST/accounts/{id}/messages
Message a connection
GET/accounts/{id}/connections/{identifier}
Check that the sender can message the profile
POST/inbox/chats/{id}/messages
Reply inside an existing conversation
/accounts/{id}/messages
api/v1curl -X POST https://app.swarmhit.com/api/v1/accounts/acc_123/messages \
-H "Authorization: Bearer $SWARMHIT_API_KEY" \
-H "Idempotency-Key: 6f1c2f3e-msg-ana" \
-H "Content-Type: application/json" \
-d '{
"profileUrl": "https://www.linkedin.com/in/ana-lopez",
"text": "Thanks for connecting, Ana. Quick question about your outbound stack."
}'How the LinkedIn DM API works
- The recipient must be a 1st-degree connection of the sender. Check first with GET /accounts/{id}/connections/{identifier}: it returns the connection status and degree without registering a profile view or using any cap.
- Pass the optional providerId (the recipient's stable LinkedIn id, delivered in connection.accepted and message.received webhooks) and the send skips the profile lookup, the slow round trip on this path.
- To answer a lead who already replied, write into the conversation with POST /inbox/chats/{id}/messages instead. That route also takes attachments and voice notes, and can pause or stop the lead's sequence in the same call.
As a campaign step
The same action runs inside sequences as the message step: one POST /campaigns sets up the whole sequence, and the engine schedules each step per sender and mailbox, inside the sending window, with rotation across senders.
- In a campaign, the message step takes text and fallbackText, so a missing {{variable}} never ships a broken sentence. It usually sits on the Accepted branch of an invite step.
- Up to five variants per step are rotated evenly across leads, and each variant can carry its own attachments or voice note for A/B tests. A message step ends on a reply: the Replied branch is terminal, so nobody gets a follow-up after answering.
Limits and safety
- Each send counts against the sender's daily message cap. Past it, the API answers 429 with details { limit, used, scope, resetAt }, so your code knows exactly when to retry.
- A sender that is paused or not connected to the profile gets a 409 or 422 instead of a silent failure.
- Every sender runs on its own dedicated proxy with managed warmup and health checks, behind 250+ safeguards monitored 24/7.
LinkedIn senders cost $16.90 a month each for the first 50, tiered down to $6.90, with no minimum. See pricing.
Webhooks
Events to subscribe to: message.sent, message.received. Deliveries are signed and retried. How LinkedIn webhooks work
Going deeper: LinkedIn messaging API guide.
LinkedIn DM API, answered
Can I message someone who is not a connection?
Not with this endpoint: it only reaches the sender's 1st-degree connections. For anyone else, send a connection request first and message once it is accepted, or send an InMail with POST /accounts/{id}/inmails if the sender has a premium LinkedIn plan.
Does Swarmhit use LinkedIn's official messaging API?
No. LinkedIn's own messaging APIs are limited to approved partners and specific use cases, not prospecting. Swarmhit sends through LinkedIn accounts that your users own and connect themselves, behind 250+ safeguards. Swarmhit is not affiliated with or endorsed by LinkedIn, and no LinkedIn automation is ever zero-risk.
How many LinkedIn messages can a sender send per day?
Each sender has a daily message cap that Swarmhit enforces on the server, alongside managed warmup for newer accounts. When the cap is reached the API returns a 429 with the limit, the count used and the UTC time the window resets, so your product can queue the message instead of guessing.
Can I send attachments or voice notes with a LinkedIn message?
Yes. Inside a conversation, POST /inbox/chats/{id}/messages takes attachments fetched from public URLs, up to 15 MB each, and a voice message of about one minute that is transcoded to LinkedIn's format on the server. In campaigns, message variants can carry attachments or a voice note too.
How do I avoid sending the same message twice?
Send an Idempotency-Key header with every send. If your code retries after a timeout, Swarmhit replays the first answer instead of sending again, so a network blip never becomes a double message in the lead's inbox.
More LinkedIn API endpoints
LinkedIn connection request API
Send a connection request
ReadLinkedIn InMail API
Send an InMail
ReadLinkedIn inbox API
Read and reply
ReadLinkedIn voice message API
Send a voice note
Read- Sequencer built in
- 250+ safeguards monitored 24/7
- REST API and signed webhooks