pollInbox
This method polls your monitored inbox to retrieve captured messages and receive new ones across every conversation, for both standard and Sales Navigator inboxes. With personUrl, it returns the whole conversation with one person instead.
This is the default way to read messages. Before polling, enable inbox monitoring once with
syncInboxornvSyncInbox.
try {
const { data, errors } = await linkedapi.pollInbox({
since: "2024-01-01T00:00:00Z", // Optional: only messages after this timestamp
type: "st", // Optional: "st" | "nv"; omit for both
threadId: "2-abc123..." // Optional: restrict to a single thread
});
// The list of possible execution errors is below
if (errors && errors.length > 0) {
console.warn('Workflow completed with execution errors:');
errors.forEach(error => {
console.warn(` - Type: ${error.type}, Message: ${error.message}`);
});
}
if (data) {
console.log(`Retrieved ${data.messages.length} messages`);
data.messages.forEach(message => {
const sender = message.sender === 'us' ? 'You' : 'Them';
console.log(`[${message.type}] ${sender} (${message.time}): ${message.text}`);
});
}
} catch (e) {
// A list of all critical errors can be found here:
// https://linkedapi.io/sdks/handling-results-and-errors/#handling-critical-errors
if (e instanceof LinkedApiError) {
console.error(`Critical Error - Type: ${e.type}, Message: ${e.message}`);
} else {
console.error('An unexpected, non-API error occurred:', e);
}
}Params
All fields are optional:
since– timestamp indicating the starting point for retrieving messages. If not provided, all captured messages are returned.type– enum to filter by inbox type; omit for both:st– standard inbox messages only.nv– Sales Navigator inbox messages only.
threadId– restrict the result to a single conversation thread.personUrl– return the conversation with one person instead of the whole inbox. See Polling one person for how this changes the result.
The inbox only captures messages that arrive after monitoring is enabled – unless you ask for one person with personUrl, which also returns history loaded for that person. If inbox monitoring is not enabled on the account, the call still succeeds with an empty messages array.
Data
messages– flat array of messages across all threads, ordered newest first.id– unique identifier for the message.type– inbox type the message belongs to (stornv).threadId– identifier of the conversation thread. Pass it tosendMessage/nvSendMessageto reply into the thread.personUrn– URN of the other participant, ornullif LinkedIn does not expose it.personHashedUrl– hashed LinkedIn URL of the other participant. This is the form the inbox exposes; every method that takes a person URL accepts it.personPublicUrl– public LinkedIn URL of the other participant, ornullif it has not been resolved. It can benullon any message, including the first one in a thread.personUrl– deprecated, replaced bypersonHashedUrl, which carries the same value. Still returned so existing integrations keep working; do not use it in new code.sender– enum indicating who sent the message. Possible values:us– message was sent by you (through the LinkedIn UI or the Linked API).them– message was sent by the other person.
text– message text.time– timestamp when the message was sent or received.
A person is resolved by the periodic sync, and only when their thread produces a message after monitoring was enabled by
syncInbox.personPublicUrlis thereforenullfor everyone you have not heard from yet, and some people are never resolvable at all – so always handlenullrather than assuming a message carries a public URL. Messages captured before this field existed, and people whose resolution did not succeed, staynulluntil that person sends another message or Linked API learns their public URL another way, for example throughfetchPerson.personHashedUrlis always present and is the safe input for follow-up methods.
Recommended flow for integrations:
- Leave
sinceempty on the first request to retrieve everything captured so far. - For subsequent requests, pass the timestamp of the most recent message you received as
sinceto fetch only newer messages. - Continue polling with an advancing
since. Whenever new messages arrive, updatesinceto the latest message time.
since is inclusive and message times are whole minutes, so the messages at the latest time come back on the next request. Remember their ids and skip them, so you never process – or reply to – the same message twice.
For push-based delivery instead of polling, subscribe to the inbox webhook events.
Polling one person
Pass personUrl to read the whole known conversation with one person. Besides the messages the inbox captured, the result includes that person's earlier history if it was loaded with syncConversation or nvSyncConversation – a message present in both appears once. Loaded history is returned even if inbox monitoring is not enabled on the account.
try {
const { data, errors } = await linkedapi.pollInbox({
personUrl: "https://www.linkedin.com/in/john-doe",
since: "2024-01-01T00:00:00Z" // Optional: omit to get the full conversation
});
// The list of possible execution errors is below
if (errors && errors.length > 0) {
console.warn('Workflow completed with execution errors:');
errors.forEach(error => {
console.warn(` - Type: ${error.type}, Message: ${error.message}`);
});
}
if (data) {
data.threads.forEach(thread => {
console.log(`[${thread.type}] thread ${thread.threadId ?? '(unknown)'}, history from ${thread.historyFrom}, complete: ${thread.historyComplete}`);
});
data.messages.forEach(message => {
const sender = message.sender === 'us' ? 'You' : 'Them';
console.log(`${sender} (${message.time}): ${message.text}`);
});
}
} catch (e) {
// A list of all critical errors can be found here:
// https://linkedapi.io/sdks/handling-results-and-errors/#handling-critical-errors
if (e instanceof LinkedApiError) {
console.error(`Critical Error - Type: ${e.type}, Message: ${e.message}`);
} else {
console.error('An unexpected, non-API error occurred:', e);
}
}Params
personUrl– public or hashed LinkedIn URL of the person. A hashed URL, standard or Sales Navigator, always matches. A public URL matches only once Linked API knows this person's public URL; if inbox messages from this person carrypersonPublicUrl: null, pass theirpersonHashedUrlinstead. In Python, pass it throughInboxPersonPollRequest, so the result is typed as the person view below.since,typeandthreadId(optional) – work as described above and narrow the messages further. Leavesinceempty to get the full conversation.
Data
With personUrl, the method returns a different shape:
messages– messages exchanged with this person across all their threads, ordered newest first. Each message carries the same fields as above, plusinboxMessageId:id– identifier of the message in this view. It stays the same between calls, including after new messages arrive, but it can differ from theidthe same message has withoutpersonUrl.inboxMessageId–idof the same message in the result withoutpersonUrl, which is alsomessageIdin inbox webhook events, ornullif the inbox did not capture this message – for example, history from before monitoring was enabled. Use it to match this view against the messages you have already received from the inbox.threadId– may benullin this view: a thread whose history was loaded through the person's profile keepsthreadId: nulluntil Linked API discovers the thread during the syncing period. AftersyncUntil, the same conversation can appear twice inthreads– once withthreadId: null(the loaded history, which tells you how far back it goes) and once with the inbox'sthreadId. To reply to such a person, passpersonUrltosendMessage.
threads– every thread with this person that Linked API knows about, listed regardless ofsince.threadId– identifier of the thread, ornullas described above.type– inbox type of the thread (stornv).personUrn– URN of the person, ornullif LinkedIn does not expose it.historyFrom– time of the earliest message Linked API has in this thread, ornullif it has none.historyComplete–trueonly when Linked API has read this thread back to its very first message, sohistoryFromis where the conversation starts.falsemeans earlier messages may exist that Linked API has not read; load them once withsyncConversationornvSyncConversation.
If Linked API has no messages with this person, messages is empty; threads can still list a known thread with historyFrom: null.
Messages from the inbox and from the loaded history are matched by sender, minute and text within the same thread, so two identical messages sent in the same minute stay two messages. In rare cases the two copies of one message are recorded with a different minute, and then the message appears twice.
Did this lead reply? Enable inbox monitoring before you send: it captures only messages that arrive after it is turned on. Then call
pollInboxwith the person'spersonUrlandsinceset a few minutes before you sent your message. Message times are whole minutes, so a reply sent in the same minute can carry a time earlier than the exact moment you sent yours. Pass thetypeof your message (stornv) and take the earliest message withsenderusin the result – the one you sent; later messages of yours, such as follow-ups, must not move this point. Treat a message whosesenderisthemand whosetimeis not earlier than it as the reply. If your message is not in the result yet, the periodic sync has not captured it, and the answer is not known yet – not "no reply". Athemmessage in the same minute as yours is ambiguous: with minute precision it may have been sent just before yours. A reply appears only after the periodic sync captures it, so an empty result means there is no reply yet.