# st.createPost

> The API Reference is also the SDK and CLI reference. Consecutive code fences marked `tab=HTTP`, `tab=Node`, `tab=Python` and `tab=CLI` are the same call on each surface (a fence marked `tab=HTTP,CLI` is the same text for both), and a block between `:::surface <names>` and `:::` applies only to the surfaces it names. Identifiers in the text are written as in Node and in HTTP JSON (camelCase); the Python SDK spells methods, parameters and result attributes in snake_case (`sendMessage` → `send_message`, `reconnectionLink` → `reconnection_link`), while names inside HTTP JSON stay camelCase.

This action allows you to create a post on LinkedIn. You can post as yourself or on behalf of a company page you have admin access to. The action supports text content with optional mentions of people and companies, and media attachments including images, videos, and documents.

:::surface node,python
In the SDK this is the `createPost` method. It takes the parameters below except `label` and `then`, which exist only in workflow JSON, and returns the result below in `data`.
:::

:::surface cli
In the CLI this is `linkedin post create` – the command is below, under [Parameters](#parameters).
:::

## Constraints

> ⏺️ **Root Start:** allowed.

> ⬆️ **Parent Actions:** N/A.

> ⬇️ **Child Actions:** [st.openPost](/docs/action-st-open-post).

## Parameters

```json tab=HTTP
{
  "actionType": "st.createPost",
  "label": "post1",
  "text": "Excited to share my latest insights on building scalable APIs, together with @[teammate]!",
  "mentions": [
    {
      "key": "teammate",
      "name": "Example Person",
      "personHashedUrl": "https://www.linkedin.com/in/ACwAAAxxxxxxxxx"
    }
  ],
  "attachments": [
    {
      "url": "https://example.com/images/team-photo.jpg",
      "type": "image"
    }
  ],
  "companyUrl": "https://www.linkedin.com/company/microsoft"
}
```

```typescript tab=Node
const workflow = await linkedapi.createPost.execute({
  text: "Excited to share my latest insights on building scalable APIs, together with @[teammate]!",
  mentions: [
    {
      key: "teammate",
      name: "Example Person",
      personHashedUrl: "https://www.linkedin.com/in/ACwAAAxxxxxxxxx"
    }
  ],
  attachments: [
    {
      url: "https://example.com/images/team-photo.jpg",
      type: "image"
    }
  ],
  companyUrl: "https://www.linkedin.com/company/microsoft"
});

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

```python tab=Python
from linkedapi import CreatePostParams

workflow = linkedapi.create_post.execute(
    CreatePostParams(
        text="Excited to share my latest insights on building scalable APIs, together with @[teammate]!",
        mentions=[
            {
                "key": "teammate",
                "name": "Example Person",
                "person_hashed_url": "https://www.linkedin.com/in/ACwAAAxxxxxxxxx",
            },
        ],
        attachments=[
            {
                "url": "https://example.com/images/team-photo.jpg",
                "type": "image",
            },
        ],
        company_url="https://www.linkedin.com/company/microsoft",
    )
)

result = linkedapi.create_post.result(workflow.workflow_id)
```

```bash tab=CLI
linkedin post create \
  'Excited to share my latest insights on building scalable APIs, together with @[teammate]!' \
  --company-url https://www.linkedin.com/company/microsoft \
  --mention "teammate:Example Person:https://www.linkedin.com/in/ACwAAAxxxxxxxxx" \
  --attachments https://example.com/images/team-photo.jpg:image
```

In AI assistants, the MCP server runs this action as the `create_post` tool.

:::surface cli
In the CLI this is `linkedin post create`:

```bash
linkedin post create <text> [flags]
```

| Arg | Required | Description |
| --- | --- | --- |
| `text` | yes | Post text (up to 3000 characters) |

| Flag | Type | Description |
| --- | --- | --- |
| `--company-url` | string | Post on behalf of a company page (requires admin access) |
| `--attachments` | string | Attachments as `url:type` or `url:type:name`. Types: `image`, `video`, `document`. Can be specified multiple times. |
| `--mention` | string | One mention, bound to `@[key]` in the text. Can be specified multiple times, up to 20. |

> Attachment limits: up to 9 images, or 1 video, or 1 document. Cannot mix types.

**Passing mentions**

Write `@[key]` in the post text where the mention should appear, then describe that key with `--mention`. The value takes one of two forms:

```
key:name
key:name:identifier
```

- `key` – the placeholder name used in the text as `@[key]`. Letters, digits, `_` or `-`.
- `name` – the name to find the person or company by. Always required.
- `identifier` – optional. One of a member URN, an organization URN, a hashed profile URL, or a hashed company URL.

Everything after the second `:` is the identifier, so its own colons and `://` need no escaping. Quote the whole value, because names contain spaces.

```bash
# Name only – LinkedIn's first suggestion for that name is used
linkedin post create 'Thanks @[author]!' \
  --mention "author:Example Person"

# Pinned by member URN
linkedin post create 'Thanks @[author]!' \
  --mention "author:Example Person:urn:li:member:123456789"

# Pinned by hashed profile URL
linkedin post create 'Thanks @[author]!' \
  --mention "author:Example Person:https://www.linkedin.com/in/ACwAAAxxxxxxxxx"

# A company, and two mentions at once
linkedin post create 'Great work @[author] and everyone at @[company]!' \
  --mention "author:Example Person:urn:li:member:123456789" \
  --mention "company:Example Company:urn:li:organization:1234567"
```

> Without an identifier, LinkedIn's first suggestion for `name` is used, which may not be the entity you meant. The published mention shows LinkedIn's own name for the entity, which can differ from the `name` you passed. Every `@[key]` in the text must have a matching `--mention` and vice versa, and keys cannot repeat – otherwise the command fails before anything is published.

The post's `postUrl` and `postUrn` are printed on success (use `--json` for the full object).
:::

- `label` (optional) – custom label for tracking this action in workflow completion.
- `text` (required) – post text, must be up to **3000** characters.
- `mentions` (optional) – people and companies to mention in `text`. Write `@[key]` where the mention should appear, and describe that `key` here. Maximum **20** items.
  - `key` (required) – placeholder name used in the text as `@[key]`. From **1** to **30** characters: letters, digits, `_` or `-`.
  - `name` (required) – name to find the person or company by, from **1** to **100** characters.
  - `urn` (optional) – [URN](/docs/data-conventions#linkedin-urns) of the entity: `urn:li:member:<id>` for a person, `urn:li:organization:<id>` for a company.
  - `personHashedUrl` (optional) – hashed LinkedIn profile URL of the person.
  - `companyHashedUrl` (optional) – hashed LinkedIn company page URL.
- `attachments` (optional) – array of media attachments. Maximum **9** items.
  - `url` (required) – publicly accessible URL of the file to attach.
  - `type` (required) – type of attachment: `image`, `video`, or `document`.
  - `name` (required when type is `document`) – display name for the document.
- `companyUrl` (optional) – LinkedIn company page URL. When provided, the post will be published on behalf of the company. Requires content admin access to the company page.
- `then` (optional) – object or array of child actions to be executed on the created post.

### Mention rules

- Provide at most one of `urn`, `personHashedUrl` and `companyHashedUrl` per mention.
- Every `@[key]` in the text must have a matching mention, and every mention must appear in the text.
- Two mentions cannot share the same `key`.
- `name` is required even when an identifier is given, because LinkedIn resolves a mention through its own name suggestions. The identifier only decides which of the offered namesakes is taken. See [publishing posts](/docs/publishing-posts) for the full explanation.

### Attachment limits

- Maximum **9 images** per post (JPEG, PNG, GIF, WebP, max 8mb).
- Maximum **1 video** per post (MP4, MOV, WebM, max 200 mb).
- Maximum **1 document** per post (PDF, max 100 mb).
- Cannot mix different attachment types (e.g., images and video together).

## Result options

1. **Successful post creation:**

```json
{
  "actionType": "st.createPost",
  "label": "post1",
  "success": true,
  "data": {
    "postUrl": "https://www.linkedin.com/feed/update/urn:li:activity:1234567890123456789",
    "postUrn": "urn:li:activity:1234567890123456789",
    "then": { ... }
  }
}
```

- `label` – included only if specified in the action parameters.
- `data.postUrl` – URL of the created post.
- `data.postUrn` – [URN](/docs/data-conventions#linkedin-urns) of the created post.
- `data.then` – results of child actions execution.

> `postUrl` and `postUrn` are `null` when the post was published but LinkedIn did not return its address. In that case the child actions in `then` did not run. Do not retry: the post is already live.

2. **Failed post creation:**

```json
{
  "actionType": "st.createPost",
  "label": "weeklyUpdate1",
  "success": false,
  "error": {
    "type": "companyNotFound",
    "message": "Provided URL is not an existing LinkedIn company."
  }
}
```

- `label` – included only if specified in the action parameters.
- `error.type` – enum with the following possible values:
  - `textTooLong` – post text exceeds 3000 characters limit.
  - `companyNotFound` – specified company page was not found on LinkedIn.
  - `noPostingPermission` – no permission to post on behalf of this company.
  - `mentionNotResolved` – a person or company the post text mentions was not among the options LinkedIn offered for that name. Nothing was published.
  - `unsupportedAttachmentType` – attachment type is not supported. Use `image`, `video`, or `document`.
  - `missingDocumentName` – document attachment requires a `name` field.
  - `urlNotAccessible` – attachment URL is not publicly accessible or returned an error.
  - `fileTooLarge` – attachment file exceeds the maximum allowed size.
  - `unsupportedMimeType` – file's MIME type is not supported by LinkedIn.
  - `tooManyAttachments` – more than 9 attachments were provided.
  - `mixingNotAllowed` – cannot mix different attachment types (e.g., images with video).
