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.

Before polling, enable inbox monitoring once with syncInbox or nvSyncInbox.

typescript
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.

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 (st or nv).
    • threadId – identifier of the conversation thread. Pass it to sendMessage / nvSendMessage to reply into the thread.
    • personUrl – LinkedIn URL of the other participant.
    • 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.

Recommended flow for integrations:

  1. Leave since empty on the first request to retrieve everything captured so far.
  2. For subsequent requests, pass the timestamp of the most recent message you received as since to fetch only newer messages.
  3. Continue polling with an advancing since. Whenever new messages arrive, update since to the latest message time.

For push-based delivery instead of polling, subscribe to the linkedin.messageReceived / linkedin.messageSent webhook events.