APILinkedIn Messaging

Get Recent Messages

Get recent messages from LinkedIn for the specified account. The profileUrn is automatically derived from the account's profile information.

GET/linkedin/messaging/recent-messages

Get Recent Messages

Get recent messages from LinkedIn for the specified account. The profileUrn is automatically derived from the account's profile information.

Authentication requiredLinkedIn Messaging

Code Examples

curl -X GET 'https://api.connectsafely.ai/linkedin/messaging/recent-messages?count=20' \
-H 'Authorization: Bearer <your_api_key>'

Parameters

NameInRequiredTypeDescription
accountIdqueryNostringLinkedIn account ID. If not provided, uses the default account (most recently used).
nextCursorqueryNostringCursor token for pagination. Use the nextCursor value from the previous response to fetch the next page of conversations.
countqueryNointegerNumber of conversations to return (default: 20, max: 100).

Request Body

No request body.

Responses

StatusDescription
200Successful response
500Error response

200 Example

{
  "success": true,
  "accountId": "507f1f77bcf86cd799439011",
  "profileUrn": "urn:li:fsd_profile:ACoAABcn...",
  "total": 3,
  "nextCursor": "xqS2pdVm4vDq0NZmLnVybjpsaTpmYWJyaWM6cHJvZC1sb3IxAA==",
  "conversations": [
    {
      "conversationId": "urn:li:messagingThread:...",
      "conversationUrn": "urn:li:msg_conversation:...",
      "participants": [
        {
          "profileId": "123456",
          "name": "John Doe",
          "headline": "Software Engineer",
          "profilePicture": "https://..."
        }
      ],
      "unreadCount": 2,
      "lastActivityAt": 1704067200000,
      "latestMessage": {
        "text": "Hello, how are you?",
        "sentAt": 1704067200000,
        "senderName": "John Doe",
        "hasAttachment": false
      }
    }
  ]
}

Note: The nextCursor field in the response can be used for pagination. Pass it as a query parameter in the next request to fetch the next page of conversations. If nextCursor is null, there are no more pages available.

500 Example

{
  "success": false,
  "error": "Failed to get recent messages"
}