createRepost

This method allows you to repost a post, either as is or with your own commentary.

typescript
try {
  const workflow = await linkedapi.createRepost.execute({
    postUrl: "https://www.linkedin.com/posts/username_activity-id",
    text: "Worth reading, especially the part on onboarding."
  });

  const { data, errors } = await linkedapi.createRepost.result(workflow.workflowId);

  // 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}`);
    });
  }

  // The structure of the 'data' object is below
  if (data) {
    console.log('Workflow completed successfully. Data:', data);
  }
} 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

  • postUrl – LinkedIn URL of the post to repost.
  • postUrn (optional) – LinkedIn URN of the post, accepted instead of postUrl. When both are provided, the URL must contain that same URN.
  • text (optional) – your own commentary, up to 3000 characters. Without it the post is reposted as is.
  • mentions (optional) – people and companies to mention in the text. Same structure as in createPost.

Data

  • postUrl – URL of the repost. A repost is a post of your own account, so this is not the URL of the post you reposted.
  • postUrn – LinkedIn URN of the repost. It can be used as the postUrn input for any post method.

Both fields are null when the repost was published but LinkedIn did not return its address. Do not retry: the repost is already live.

Errors

  • postNotFound – provided URL is not an existing LinkedIn post.
  • repostNotAllowed – LinkedIn offers no repost control for this post.
  • alreadyReposted – the account has already reposted this post and LinkedIn declined to repost it again.
  • mentionNotResolved – a person or company the text mentions was not among the options LinkedIn offered for that name.