Upload message attachment
Upload a file to attach to a LinkedIn message (used with POST /conversations/send). Send the file as the RAW binary request body — do NOT use multipart/form-data. Set the request `Content-Type` header to the file's actual MIME type, and pass `accountId` and `filename` in the query string. To make an image render inline as a photo in the conversation, the `Content-Type` MUST be an image type (`image/png`, `image/jpeg`, `image/gif`, `image/webp`) — this uploads it as a LinkedIn photo asset. Any other content type is stored as a downloadable file attachment. The response's `attachment` object must then be passed to POST /conversations/send wrapped in a `file` key: `{ "attachments": [{ "file": <attachment> }] }`. Example: `curl -X POST "https://api.connectsafely.ai/linkedin/conversations/upload-attachment?accountId=acc_123&filename=photo.png" -H "Authorization: Bearer <api_key>" -H "Content-Type: image/png" --data-binary @photo.png`
/conversations/upload-attachmentCode Examples
curl -X POST 'https://api.connectsafely.ai/linkedin/conversations/upload-attachment?accountId=acc_12345&filename=photo.png' \ -H 'Authorization: Bearer <your_api_key>' \ -H 'Content-Type: image/png' \ --data-binary @/path/to/photo.pngUpload a file to attach to a LinkedIn message (used with POST /conversations/send). Send the file as the RAW binary request body — do NOT use multipart/form-data. Set the request Content-Type header to the file's actual MIME type, and pass accountId and filename in the query string. To make an image render inline as a photo in the conversation, the Content-Type MUST be an image type (image/png, image/jpeg, image/gif, image/webp) — this uploads it as a LinkedIn photo asset. Any other content type is stored as a downloadable file attachment. The response's attachment object must then be passed to POST /conversations/send wrapped in a file key: { "attachments": [{ "file": <attachment> }] }. Example: curl -X POST "https://api.connectsafely.ai/linkedin/conversations/upload-attachment?accountId=acc_123&filename=photo.png" -H "Authorization: Bearer <api_key>" -H "Content-Type: image/png" --data-binary @photo.png
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
accountId | query | No | string | LinkedIn account ID. If omitted, resolved from the authenticated user's default account. |
filename | query | No | string | Original file name including extension (e.g. "photo.png"). Defaults to "attachment" if omitted. |
Request Body
Content type: application/octet-stream — the raw file bytes. Set the request Content-Type header to the file's MIME type.
Raw file bytes. The request Content-Type header must be the file's MIME type (e.g. image/png, image/jpeg, application/pdf). NOT multipart/form-data.
Responses
| Status | Description |
|---|---|
| 200 | File uploaded |
| 400 | Upload failed |
| 401 | Unauthorized |
| 404 | Account not found |
| 500 | Server error |
200 Response Parameters
| Name | Type | Description |
|---|---|---|
success | boolean | |
attachment | object | Pass this back to POST /conversations/send as { attachments: [{ file: <this> }] }. |
200 Example
{
"success": true,
"attachment": {}
}400 Response Parameters
| Name | Type | Description |
|---|---|---|
error | string |
400 Example
{
"error": "example_value"
}401 Response Parameters
| Name | Type | Description |
|---|---|---|
error | string |
401 Example
{
"error": "example_value"
}404 Response Parameters
| Name | Type | Description |
|---|---|---|
error | string |
404 Example
{
"error": "example_value"
}500 Response Parameters
| Name | Type | Description |
|---|---|---|
error | string |
500 Example
{
"error": "example_value"
}Send message (with channel selection)
Send a LinkedIn message. By default, messagingChannel is "auto" which auto-detects whether to use Sales Navigator or standard LinkedIn inbox based on the account premium status. Users can explicitly control the messaging channel by setting messagingChannel to: "sales_navigator" — forces the message through the Sales Navigator API (returns a 400 error if the account does not have an active Sales Navigator subscription), or "linkedin_inbox" — forces standard LinkedIn messaging even if the account has Sales Navigator. Example: to send via standard inbox on a Sales Nav account, pass { "messagingChannel": "linkedin_inbox" }. To explicitly use Sales Navigator, pass { "messagingChannel": "sales_navigator" }. If omitted or set to "auto", the system decides automatically. File attachments: first upload each file via POST /conversations/upload-attachment, then pass each returned attachment object in the `attachments` array, each wrapped in a `file` key — `{ "attachments": [{ "file": { "assetUrn": "...", "byteSize": 123, "mediaType": "image/png", "name": "photo.png" } }] }`. An attachment whose file was uploaded with an image/* content type renders inline as a photo; anything else renders as a downloadable file.
Download media from message
Download media (images, files, videos, audio) from a LinkedIn messaging URL. Uses account session cookies for authentication. No proxy is used — media is fetched directly from LinkedIn CDN. Supports URLs from www.linkedin.com/dms/prv/ (private messaging media) and media.licdn.com (CDN-hosted media).
