|
| 1 | +# LinkedIn Messages API |
| 2 | + |
| 3 | +Retrieve and send LinkedIn messages for a given conversation. |
| 4 | + |
| 5 | +## Get Messages |
| 6 | + |
| 7 | +Retrieve the messages in a LinkedIn conversation. `viewer_id` is required. |
| 8 | + |
| 9 | +<aside class="notice">Uses 1 Standard Credit.</aside> |
| 10 | + |
| 11 | +### HTTP Request |
| 12 | + |
| 13 | +`GET https://api.lix-it.com/v1/li/messages` |
| 14 | + |
| 15 | +### URL Parameters |
| 16 | + |
| 17 | +#### Required Parameters |
| 18 | + |
| 19 | +Parameter | Description |
| 20 | +--------- | ----------- |
| 21 | +viewer_id | The Lix viewer id of the account you would like to view this conversation as. |
| 22 | +conversation_id **or** conversation_urn | The Lix conversation id or the full LinkedIn conversation URN. You must provide exactly one of these two parameters. |
| 23 | + |
| 24 | +#### Optional Parameters |
| 25 | + |
| 26 | +Parameter | Default | Description |
| 27 | +--------- | ------- | ----------- |
| 28 | +sequence_id | | A Lix sequence id returned from a previous request. Pass it back to load the next page of messages. |
| 29 | +delivered_at | | A timestamp anchor for pagination around a specific message. |
| 30 | +count_before | 0 | Number of messages to load before the anchor. |
| 31 | +count_after | 0 | Number of messages to load after the anchor. |
| 32 | + |
| 33 | +```shell |
| 34 | +curl "https://api.lix-it.com/v1/li/messages?viewer_id=YOUR_VIEWER_ID&conversation_id=YOUR_CONVERSATION_ID" \ |
| 35 | + -H "Authorization: lixApiKey" |
| 36 | +``` |
| 37 | + |
| 38 | +```python |
| 39 | +import requests |
| 40 | + |
| 41 | +url = "https://api.lix-it.com/v1/li/messages?viewer_id=YOUR_VIEWER_ID&conversation_id=YOUR_CONVERSATION_ID" |
| 42 | + |
| 43 | +headers = { |
| 44 | + 'Authorization': 'lixApiKey' |
| 45 | +} |
| 46 | + |
| 47 | +response = requests.request("GET", url, headers=headers) |
| 48 | +print(response.json()) |
| 49 | +``` |
| 50 | + |
| 51 | +> The above command returns JSON structured like this: |
| 52 | +
|
| 53 | +```json |
| 54 | +{ |
| 55 | + "messages": [ |
| 56 | + { |
| 57 | + "backendUrn": "urn:li:messagingMessage:2-...", |
| 58 | + "conversationUrn": "urn:li:msg_conversation:(...)", |
| 59 | + "backendConversationUrn": "urn:li:messagingThread:...", |
| 60 | + "deliveredAt": "1784478668446", |
| 61 | + "bodyText": "Hey, we launched a new version of our product...", |
| 62 | + "originToken": "f7f4fe26-31b1-483b-b82d-a7f0533a4a56", |
| 63 | + "senderHostIdentityUrn": "urn:li:fsd_profile:YOUR_VIEWER_ID", |
| 64 | + "senderFirstName": "Jane", |
| 65 | + "senderLastName": "Doe", |
| 66 | + "senderHeadline": "CEO at Example", |
| 67 | + "senderProfileUrl": "https://www.linkedin.com/in/YOUR_PUBLIC_ID", |
| 68 | + "senderPublicIdentifier": "your-public-id", |
| 69 | + "senderProfilePictureUrl": "https://media.licdn.com/dms/image/..." |
| 70 | + } |
| 71 | + ], |
| 72 | + "sequenceId": "YOUR_SEQUENCE_ID" |
| 73 | +} |
| 74 | +``` |
| 75 | + |
| 76 | +## Send Message |
| 77 | + |
| 78 | +Send a message to an existing LinkedIn conversation. `viewer_id` is required. |
| 79 | + |
| 80 | +<aside class="notice">Uses 1 Standard Credit.</aside> |
| 81 | + |
| 82 | +### HTTP Request |
| 83 | + |
| 84 | +`POST https://api.lix-it.com/v1/li/messages` |
| 85 | + |
| 86 | +### URL Parameters |
| 87 | + |
| 88 | +#### Required Parameters |
| 89 | + |
| 90 | +Parameter | Description |
| 91 | +--------- | ----------- |
| 92 | +viewer_id | The Lix viewer id of the account you would like to send the message as. |
| 93 | + |
| 94 | +### Body Parameters |
| 95 | + |
| 96 | +Parameter | Description |
| 97 | +--------- | ----------- |
| 98 | +conversation_id **or** conversation_urn | The Lix conversation id or the full LinkedIn conversation URN. You must provide exactly one of these two parameters. |
| 99 | +body | The message text to send. Maximum 8,000 characters. |
| 100 | + |
| 101 | +```shell |
| 102 | +curl -X POST "https://api.lix-it.com/v1/li/messages?viewer_id=YOUR_VIEWER_ID" \ |
| 103 | + -H "Authorization: lixApiKey" \ |
| 104 | + -H "Content-Type: application/json" \ |
| 105 | + -d '{ |
| 106 | + "conversation_id": "YOUR_CONVERSATION_ID", |
| 107 | + "body": "Hey, we launched a new version of our product." |
| 108 | + }' |
| 109 | +``` |
| 110 | + |
| 111 | +```python |
| 112 | +import requests |
| 113 | + |
| 114 | +url = "https://api.lix-it.com/v1/li/messages?viewer_id=YOUR_VIEWER_ID" |
| 115 | + |
| 116 | +payload = { |
| 117 | + "conversation_id": "YOUR_CONVERSATION_ID", |
| 118 | + "body": "Hey, we launched a new version of our product." |
| 119 | +} |
| 120 | + |
| 121 | +headers = { |
| 122 | + 'Authorization': 'lixApiKey', |
| 123 | + 'Content-Type': 'application/json' |
| 124 | +} |
| 125 | + |
| 126 | +response = requests.request("POST", url, headers=headers, json=payload) |
| 127 | +print(response.json()) |
| 128 | +``` |
| 129 | + |
| 130 | +> The above command returns JSON structured like this: |
| 131 | +
|
| 132 | +```json |
| 133 | +{ |
| 134 | + "message": { |
| 135 | + "backendUrn": "urn:li:messagingMessage:2-...", |
| 136 | + "conversationUrn": "urn:li:msg_conversation:(...)", |
| 137 | + "backendConversationUrn": "urn:li:messagingThread:...", |
| 138 | + "deliveredAt": "1784478668446", |
| 139 | + "bodyText": "Hey, we launched a new version of our product.", |
| 140 | + "originToken": "f7f4fe26-31b1-483b-b82d-a7f0533a4a56", |
| 141 | + "senderHostIdentityUrn": "urn:li:fsd_profile:YOUR_VIEWER_ID" |
| 142 | + } |
| 143 | +} |
| 144 | +``` |
0 commit comments