Network Update Social Actions

Some shares may have social actions such as likes or comments attached to them. The socialActions API enables you to create and read likes and comments on shares.

Permissions

Permission Description
w_organization_social Post, comment and like posts on behalf of an organization. Restricted to organizations in which the authenticated member has one of the following company page roles.
  • ADMINISTRATOR
  • DIRECT_SPONSORED_CONTENT_POSTER
  • RECRUITING_POSTER
r_organization_social Retrieve organizations' posts, comments, and likes. Restricted to organizations in which the authenticated member has one of the following company page roles.
  • ADMINISTRATOR
  • DIRECT_SPONSORED_CONTENT_POSTER
w_member_social Post, comment and like posts on behalf of an authenticated member.
r_member_social Restricted Retrieve posts, comments, and likes on behalf of an authenticated member. This permission is granted to select developers only.

See Organization Access Control for more information on company page roles.

Note

You may never store profile information, other than person URNs retrieved from the shares API.

Social Action Types

The socialActions API allows access to both personal and organization social actions. The type of URN specified in the owner field of a social action indicates the type:

URN Type Social Action Type Description
urn:li:person Personal Social action was created by a member. The member is displayed as the publisher.
urn:li:organization urn:li:organizationBrand Organization Social action was created by a member on behalf of an organizational entity. The organization or brand is displayed as the publisher.

Retrieve Social Actions

Retrieve a Summary of Social Actions

GET https://api.linkedin.com/v2/socialActions/{shareUrn|ugcPostUrn|commentUrn}

Sample Response

{
    "commentsSummary": {
        "totalFirstLevelComments": 4,
        "aggregatedTotalComments": 9
    },
    "$URN": "urn:li:activity:6296748651834277888",
    "likesSummary": {
        "likedByCurrentUser": false,
        "totalLikes": 226
    }
}

Note

Shares without likes or comments do not show likesSummary or commentsSummary respectively. A share without any social action activity returns an empty JSON response.

Batch_GET Summary of Social Actions

Sample Request

GET https://api.linkedin.com/v2/socialActions?ids={shareUrn1|ugcPostUrn1|commentUrn1}&ids={shareUrn2|ugcPostUrn2|commentUrn2}

Sample Response

{
    "statuses": {},
    "results": {
        "urn:li:share:6297772917862207488": {
            "commentsSummary": {
                "totalFirstLevelComments": 9,
                "aggregatedTotalComments": 11
            },
            "$URN": "urn:li:activity:6297772917849616384",
            "likesSummary": {
                "likedByCurrentUser": false,
                "totalLikes": 287
            },
            "target": "urn:li:activity:6297772917849616384"
        },
        "urn:li:share:6296748651846864896": {
            "commentsSummary": {
                "totalFirstLevelComments": 4,
                "aggregatedTotalComments": 9
            },
            "$URN": "urn:li:activity:6296748651834277888",
            "likesSummary": {
                "likedByCurrentUser": false,
                "totalLikes": 226
            },
            "target": "urn:li:activity:6296748651834277888"
        }
    },
    "errors": {}
}

Retrieve Likes on Shares

Sample Request

GET https://api.linkedin.com/v2/socialActions/{shareUrn|ugcPostUrn|commentUrn}/likes

Sample Response

{
    "elements": [
        {
            "actor": "urn:li:person:ub1n1QYzp_",
            "created": {
                "actor": "urn:li:person:ub1n1QYzp_",
                "time": 1501914549125
            },
            "lastModified": {
                "actor": "urn:li:person:ub1n1QYzp_",
                "time": 1501914549125
            },
            "$URN": "urn:li:like:(urn:li:person:ub1n1QYzp_,urn:li:activity:6297772917849616384)",
            "object": "urn:li:activity:6297772917849616384"
        }
    ],
    "paging": {
        "total": 287,
        "count": 10,
        "start": 0,
        "links": [
            {
                "rel": "next",
                "href": "/v2/socialActions/urn:li:activity:6297772917849616384/likes?count=10&start=10",
                "type": "application/json"
            }
        ]
    }
}

Note

To prevent timeouts, set the page count to less than 600 when you fetch likes.

Retrieve Comments on Shares

Sample Request

GET https://api.linkedin.com/v2/socialActions/{shareUrn|ugcPostUrn|commentUrn}/comments

If your request exceeds the maximum length requirement, please utilize query tunneling:

curl -X POST 'https://api.linkedin.com/v2/socialActions/{shareUrn|ugcPostUrn|commentUrn}/comments \
-H 'X-HTTP-Method-Override: GET' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Authorization: Bearer redacted' \
-H 'X-Restli-Protocol-Version: 2.0.0' \
--data 'projection=(...)'

Sample Response

{
   "actor":"urn:li:person:A8xe03Qt10",
   "created":{
      "actor":"urn:li:person:A8xe03Qt10",
      "time":1582160678569
   },
   "id":"6636062862760562688",
   "lastModified":{
      "actor":"urn:li:person:A8xe03Qt10",
      "time":1582160678569
   },
   "message":{
      "attributes":[

      ],
      "text":"Comment with comment-image media"
   },
   "$URN":"urn:li:comment:(urn:li:activity:6631349431612559360,6636062862760562688)",
   "content":[
      {
         "type":"IMAGE",
         "entity":{
            "digitalmediaAsset":"urn:li:digitalmediaAsset:C552CAQGu16obsGZENQ"
         },
         "url":"https://media.licdn-ei.com/dms/image/C552CAQGu16obsGZENQ/comment-image-shrink_8192_800/0?e=1584576000&v=beta&t=RkJykQ1pLG-3I5ojq0TGWR7NbHq76XPcRkb_HZDx4iE"
      }
   ],
   "object":"urn:li:activity:6631349431612559360"
}

If a top level comment has nested comments, the commentsSummary.selectedComments array provides a preview of the two most recent nested comments.

Note

We recommend:

  • Getting a summary of social actions before attempting to fetch comments or likes for a share directly. If no comments or likes are available for a share, a request to fetch comments or shares returns `404 - Not Found`.
  • Setting the page `count` to less than 200 when you fetch shares to prevent timeouts.
  • Retrieve Comments on Comments

    To resolve nested comments for a given parent comment, provide a parent commentUrn as the target in the request URL. A commentUrn is a composite URN constructed using a comment ID and activityUrn.

    Sample Request

    GET https://api.linkedin.com/v2/socialActions/urn:li:comment:(activity:6273189577469632512,6275822846992351232)/comments
    

    If your request exceeds the maximum length requirement, please utilize query tunneling:

    curl -X POST 'https://api.linkedin.com/v2/socialActions/urn:li:comment:(activity:6273189577469632512,6275822846992351232)/comments \
    -H 'X-HTTP-Method-Override: GET' \
    -H 'Content-Type: application/x-www-form-urlencoded' \
    -H 'Authorization: Bearer redacted' \
    -H 'X-Restli-Protocol-Version: 2.0.0' \
    --data 'projection=(...)'
    

    Sample Response

    {
       "elements":[
          {
             "actor":"urn:li:person:f49f2kf0",
             "created":{
                "actor":"urn:li:person:f49f2kf0",
                "time":1582160678569
             },
             "id":"6636062862760562688",
             "lastModified":{
                "actor":"urn:li:person:f49f2kf0",
                "time":1582160678569
             },
             "message":{
                "attributes":[
    
                ],
                "text":"Comment with comment-image media"
             },
             "$URN":"urn:li:comment:(urn:li:activity:6631349431612559360,6636062862760562688)",
             "content":[
                {
                   "type":"IMAGE",
                   "entity":{
                      "digitalmediaAsset":"urn:li:digitalmediaAsset:C552CAQGu16obsGZENQ"
                   },
                   "url":"https://media.licdn-ei.com/dms/image/C552CAQGu16obsGZENQ/comment-image-shrink_8192_800/0?e=1584576000&v=beta&t=RkJykQ1pLG-3I5ojq0TGWR7NbHq76XPcRkb_HZDx4iE"
                }
             ],
             "object":"urn:li:activity:6631349431612559360"
          }
          
    

    Retrieve Commenters' Profile Information

    Using Response Decoration, the profile name and picture of commenters can be retrieved. This profile information may never be stored.

    Sample Request

    GET https://api.linkedin.com/v2/socialActions/{shareUrn|ugcPostUrn|commentUrn}/comments?projection=(elements(*(*,actor~(*,profilePicture(displayImage~:playableStreams)))))
    

    If your request exceeds the maximum length requirement, please utilize query tunneling:

    curl -X POST 'https://api.linkedin.com/v2/socialActions/{shareUrn|ugcPostUrn|commentUrn}/comments \
    -H 'X-HTTP-Method-Override: GET' \
    -H 'Content-Type: application/x-www-form-urlencoded' \
    -H 'Authorization: Bearer redacted' \
    -H 'X-Restli-Protocol-Version: 2.0.0' \
    --data 'projection=(elements(*(*,actor~(*,profilePicture(displayImage~:playableStreams)))))'
    

    Sample Response

    {
        "elements": [
            {
                "actor~": {
                    "localizedLastName": "Tester",
                    "lastName": {
                        "localized": {
                            "en_US": "Tester"
                        },
                        "preferredLocale": {
                            "country": "US",
                            "language": "en"
                        }
                    },
                    "vanityName": "test-person",
                    "localizedHeadline": "Test Profile at Acme Corp",
                    "profilePicture": {
                        "displayImage": "urn:li:digitalmediaAsset:C5603AQEuebSM6NP8wq",
                        "displayImage~": {
                            "paging": {
                                "count": 10,
                                "start": 0,
                                "links": []
                            },
                            "elements": [
                                {
                                    "artifact": "urn:li:digitalmediaMediaArtifact:(urn:li:digitalmediaAsset:C5603AQEuebSM6NP8wq,urn:li:digitalmediaMediaArtifactClass:profile-displayphoto-shrink_800_800)",
                                    "authorizationMethod": "PUBLIC",
                                    "data": {
                                        "com.linkedin.digitalmedia.mediaartifact.StillImage": {
                                            "mediaType": "image/jpeg",
                                            "rawCodecSpec": {
                                                "name": "jpeg",
                                                "type": "image"
                                            },
                                            "displaySize": {
                                                "width": 800.0,
                                                "uom": "PX",
                                                "height": 800.0
                                            },
                                            "storageSize": {
                                                "width": 800,
                                                "height": 800
                                            },
                                            "storageAspectRatio": {
                                                "widthAspect": 1.0,
                                                "heightAspect": 1.0,
                                                "formatted": "1.00:1.00"
                                            },
                                            "displayAspectRatio": {
                                                "widthAspect": 1.0,
                                                "heightAspect": 1.0,
                                                "formatted": "1.00:1.00"
                                            }
                                        }
                                    },
                                    "identifiers": [
                                        {
                                            "identifier": "https://example.com/image.jpg",
                                            "index": 0,
                                            "mediaType": "image/jpeg",
                                            "file": "urn:li:digitalmediaFile:(urn:li:digitalmediaAsset:C5603AQEuebSM6NP8wq,urn:li:digitalmediaMediaArtifactClass:profile-displayphoto-shrink_800_800,0)",
                                            "identifierType": "EXTERNAL_URL",
                                            "identifierExpiresInSeconds": 1609372800
                                        }
                                    ]
                                }
                            ]
                        }
                    },
                    "firstName": {
                        "localized": {
                            "en_US": "Tester"
                        },
                        "preferredLocale": {
                            "country": "US",
                            "language": "en"
                        }
                    },
                    "id": "j8924gj82",
                    "headline": {
                        "localized": {
                            "en_US": "Test Profile at Acme Corp"
                        },
                        "preferredLocale": {
                            "country": "US",
                            "language": "en"
                        }
                    },
                    "localizedFirstName": "Tester"
                },
                "created": {
                    "actor": "urn:li:person:j8924gj82",
                    "time": 1603870852695
                },
                "message": {
                    "attributes": [],
                    "text": "Test Comment!"
                },
                "actor": "urn:li:person:j8924gj82",
                "commentsSummary": {
                    "totalFirstLevelComments": 1,
                    "selectedComments": [
                        "urn:li:comment:(urn:li:activity:1234,567)"
                    ],
                    "aggregatedTotalComments": 1
                },
                "id": "789",
                "lastModified": {
                    "actor": "urn:li:person:j8924gj82",
                    "time": 1603870852695
                },
                "$URN": "urn:li:comment:(urn:li:activity:1234,789)",
                "likesSummary": {
                    "selectedLikes": [
                        "urn:li:like:(urn:li:person:j8924gj82,urn:li:comment:(urn:li:activity:1234,789))"
                    ],
                    "likedByCurrentUser": false,
                    "aggregatedTotalLikes": 1,
                    "totalLikes": 1
                },
                "object": "urn:li:activity:1234"
            }
        ]
    }
    

    Common Retrieval Errors

    The table below lists commonly encountered errors retrieving social actions. It is not meant to be a comprehensive list of all possible social action retrieval errors.

    Code Message Description
    400 Invalid query parameters passed to request Occurs when using Restli 2.0 and the query parameters are not encoded properly. See Protocol Version for more on Restli 2.0 encoding. Calls with Postman and some other HTTP clients can trigger this error. Try using curl or another client when testing.
    400 Syntax exception in path variables Indicates an invalid URN was requested. Try again with a share or ugcPost URN.

    Create and Delete Social Actions

    Create Comment

    Request Body Fields

    Field Description Format Required
    actor Entity which authored the comment organization URN or person URN Yes
    message Text of the comment. May contain attributes such as links to people and organizations. Text Yes
    parentComment For nested comments, this is the urn of the parent comment. This is not available for first-level comments. Composite URN No

    Use the object field in the request body to specify the share or the ugcPost which contains the comment. Specify the share or the ugcPost in the request URL, and represent it as an URN.

    Use the ID returned in the response header to take further action on the newly created comment. The following response body also contains a comment URN which can be used as parent comment for creating nested comments.

    Sample Request

    POST https://api.linkedin.com/v2/socialActions/{shareUrn|ugcPostUrn|commentUrn}/comments
    
    {
       "actor":"urn:li:person:A8xe03Qt10",
       "object":"urn:li:activity:6631349431612559360",
       "message":{
          "text":"commentV2 with image entity"
       },
       "content":[
          {
             "entity":{
                "digitalmediaAsset":"urn:li:digitalmediaAsset:C552CAQGu16obsGZENQ"
             },
             "type":"IMAGE"
          }
       ]
    }
    

    Sample Response Header

    X-LinkedIn-Id: 6643206422739898368
    

    Sample Response Body

    {
        "actor": "urn:li:organization:5637409",
        "agent": "urn:li:person:CnpTkB7V70",
        "created": {
            "actor": "urn:li:organization:5637409",
            "impersonator": "urn:li:person:CnpTkB7V70",
            "time": 1583863835990
        },
        "id": "6643206422739898368",
        "lastModified": {
            "actor": "urn:li:organization:5637409",
            "impersonator": "urn:li:person:CnpTkB7V70",
            "time": 1583863835990
        },
        "message": {
            "attributes": [],
            "text": "commentV2 with image urn"
        },
        "$URN": "urn:li:comment:(urn:li:activity:6641861161010679808,6643206422739898368)",
        "content": [
            {
                "type": "IMAGE",
                "url": "https://media.licdn-ei.com/dms/image/C552CAQGu16obsGZENQ/comment-image-shrink_8192_800/0?e=1585180800&v=beta&t=d8E35ZP3x0_Lrk0utXbn3YPw9_5ybihj2AWXWb8xHdc",
                "entity": {
                    "digitalmediaAsset": "urn:li:digitalmediaAsset:C552CAQGu16obsGZENQ"
                }
            }
        ],
        "object": "urn:li:activity:6641861161010679808"
    }
    

    Common Creation Errors

    The table below lists commonly encountered errors creating comments. It is not meant to be a comprehensive list of all possible comment creation errors.

    Code Message Description
    403 Unpermitted fields present in REQUEST_BODY: Data Processing Exception while processing fields [/content] Occurs when attempting to include an image in an inline comment which is not currently not supported by the API.
    429 Comment create throttled: creation rate limit exceeded for member Indicates member has hit the short term 1 minute rate limit for common creation.

    Delete Comment from Share

    Query Parameters

    Field Description Format Required
    actor Entity deleting the comment organization URN Only when deleting comment as an organization

    Sample Request

    DELETE https://api.linkedin.com/v2/socialActions/{shareUrn|ugcPostUrn}/comments/{comment ID}
    

    Additional Comment Features

    Create a Comment on a Comment

    To create a nested comment, add a parentComment field to your request body. The value is a composite URN, which is comprised of the activityUrn and parent comment ID.

    Sample Request

    POST https://api.linkedin.com/v2/socialActions/urn:li:comment:(urn:li:activity:6305471423192264704,6308007194273021952)/comments
    
    {
        "actor": "urn:li:organization:2414183",
        "message": {
            "text": "Dunder Mifflin's Dundie Award goes to Dwight Schrute!"
        },
        "object": "urn:li:share:6305471423242596352",
        "parentComment": "urn:li:comment:(urn:li:activity:6305471423192264704,6308007194273021952)"
    }
    

    Comment Mentioning

    Comment text may contain attributes, which are links to other LinkedIn entities such as people or organizations. Mentioning requires knowledge of the URN for the referenced entity. You must also specify the part of the comment text that should be rendered as a link to the entity.

    Schema

    Field Description Format Required
    length The length of the annotation link integer yes
    start The starting character index beginning the annotation link integer yes
    value An object that includes the URN of the organization or member you want to mention in the comment. URN no

    Sample Request Body

    {
        "actor": "urn:li:organization:2414183",
        "message": {
            "attributes": [
                {
                    "length": 17,
                    "start": 0,
                    "value": {
                        "com.linkedin.common.CompanyAttributedEntity": {
                            "company": "urn:li:organization:2414183"
                        }
                    }
                },
                {
                    "length": 14,
                    "start": 38,
                    "value": {
                        "com.linkedin.common.MemberAttributedEntity": {
                            "member": "urn:li:person:uOeeiwWoxO"
                        }
                    }
                }
            ],
            "text": "Dunder Mifflin's Dundie Award goes to Dwight Schrute!"
        },
        "object": "urn:li:share:6305471423242596352"
    }
    

    Comments with Images

    An entity field is now part of the content field in a comment, replacing the url field. When creating a comment with an image, specify the image as a digitalmediaAsset URN (obtained when uploading an image to the Vector API) within the entity field instead of the URL field. Learn more.

    Schema

    Field Description Format Required
    entity The Digitalmedia Asset URN of the image you want to include in the comment. URN yes
    type The type of the content, in this case, use "IMAGE". string yes
    url The URL of the content. (This read-only field and should not be provided for comment creates.) URL no

    Sample Request Body

    {
       "actor":"urn:li:person:f49f2kf0",
       "object":"urn:li:activity:6631349431612559360",
       "message":{
          "text":"commentV2 with image entity"
       },
       "content":[
          {
             "entity":{
                "digitalmediaAsset":"urn:li:digitalmediaAsset:C552CAQGu16obsGZENQ"
             },
             "type":"IMAGE"
          }
       ]
    }'
    

    Create a Like on a Share

    Sample Request

    Use the object field in the request body to specify the URN of the entity to which the like belongs. This object should be a sub-entity of the top-level share indicated in the request URL, and should be represented as a URN of format urn:li:share:{id}.

    The actor field in the request body is used to specify the entity performing the action. It should be represented by a urn:li:person:{id} or urn:li:organization:{id} URN.

    POST https://api.linkedin.com/v2/socialActions/{shareUrn|ugcPostUrn|commentUrn}/likes
    
    {
        "actor": "urn:li:person:0XV6h162Ub",
        "object": "urn:li:share:6280442346811207680"
    }
    

    Sample Response

    {
        "$URN": "urn:li:like:(urn:li:person:0XV6h162Ub,urn:li:activity:6280442346165280768)",
        "actor": "urn:li:person:0XV6h162Ub",
        "agent": "urn:li:person:0XV6h162Ub",
        "created": {
            "actor": "urn:li:person:0XV6h162Ub",
            "time": 1497380688598
        },
        "lastModified": {
            "actor": "urn:li:person:0XV6h162Ub",
            "time": 1497380688598
        },
        "object": "urn:li:activity:6280442346165280768"
    }
    

    Create a Like on a Comment

    Likes can be created on comments by using the comment URN as the target key in the request URL. Similar to liking a share, the object value should be set to the top level share URN.

    Sample Request

    POST https://api.linkedin.com/v2/socialActions/{commentUrn}/likes
    
    {
        "actor": "urn:li:person:0XV6h162Ub",
        "object": "urn:li:share:6280442346811207680"
    }
    

    Delete a Like

    Sample Request

    DELETE https://api.linkedin.com/v2/socialActions/{shareUrn|ugcPostUrn|commentUrn}/likes/{actor URN}?actor={actor URN}
    

    Query Parameters

    Field Description Format Required
    actor Entity deleting the like. Must supply the entity that created the like. organization URN or person URN Yes