> Documentation index: https://docs.zernio.com/llms.txt. Every page is also Markdown: add .md to its URL.

# Posts

Publish text, image, video, document, poll and repost posts to LinkedIn, post to several organizations, restrict by country and edit a published post.

A plain post becomes a text post. Media in `mediaItems` selects an image, video or document post.

Fields in `platformSpecificData` on the LinkedIn entry add polls, reposts, a first comment and organization targeting.

## Text post

Up to 3,000 characters. LinkedIn collapses the rest behind a "see more" fold, so put the hook first.

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="Node.js">
```typescript
import Zernio from '@zernio/node';

const zernio = new Zernio();

const { data: published } = await zernio.posts.createPost({
  body: {
    content: 'I spent 3 years building the wrong product.\n\nHere is what I learned about validating ideas before writing code.',
    platforms: [
      { platform: 'linkedin', accountId: '66b2e19d8c3f5a7e9d0b1c2d' }
    ],
    publishNow: true
  }
});

console.log(published.post.platforms[0].platformPostUrl);
```
</Tab>
<Tab value="Python">
```python
from zernio import Zernio

client = Zernio()

published = client.posts.create_post(
    content="I spent 3 years building the wrong product.\n\nHere is what I learned about validating ideas before writing code.",
    platforms=[
        {"platform": "linkedin", "accountId": "66b2e19d8c3f5a7e9d0b1c2d"}
    ],
    publish_now=True
)

print(published["post"]["platforms"][0]["platformPostUrl"])
```
</Tab>
<Tab value="curl">
```bash
curl -X POST https://zernio.com/api/v1/posts \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "I spent 3 years building the wrong product.\n\nHere is what I learned about validating ideas before writing code.",
    "platforms": [
      {"platform": "linkedin", "accountId": "66b2e19d8c3f5a7e9d0b1c2d"}
    ],
    "publishNow": true
  }'
```
</Tab>
</Tabs>

Response (`201`):

```json
{
  "post": {
    "_id": "65f1c0a9e2b5af0012ab34cd",
    "status": "published",
    "platforms": [
      {
        "platform": "linkedin",
        "status": "published",
        "platformPostUrl": "https://www.linkedin.com/feed/update/urn:li:share:..."
      }
    ]
  }
}
```

Every sample below changes only the `mediaItems` or the `platforms` entry of this request.

## Image post

One image, recommended 1200 x 627 px (landscape), or up to 20 images in one post. Images cannot share a post with a video or a document:

```json
"mediaItems": [
  { "type": "image", "url": "https://cdn.example.com/photo1.jpg" },
  { "type": "image", "url": "https://cdn.example.com/photo2.jpg" },
  { "type": "image", "url": "https://cdn.example.com/photo3.jpg" }
]
```

## Video post

One video per post. Personal profiles accept up to 10 minutes, organization pages up to 30 minutes, in MP4, MOV or AVI:

```json
"mediaItems": [
  { "type": "video", "url": "https://cdn.example.com/demo.mp4" }
]
```

## Document post

A PDF, PPT, PPTX, DOC or DOCX displays as a swipeable carousel. At most 100 MB and 300 pages, one per post, with no images or videos alongside it.

LinkedIn requires a title. Set `documentTitle`, or Zernio falls back to the media item `title`, then the filename:

```json
"mediaItems": [
  { "type": "document", "url": "https://cdn.example.com/report.pdf" }
],
"platforms": [
  {
    "platform": "linkedin",
    "accountId": "66b2e19d8c3f5a7e9d0b1c2d",
    "platformSpecificData": { "documentTitle": "2027 Industry Report" }
  }
]
```

The first page is the cover. Password-protected PDFs do not work.

## Poll

`poll` creates a LinkedIn poll:

- A question of 1 to 140 characters.
- 2 to 4 options of 1 to 30 characters each.
- A `duration` of `ONE_DAY`, `THREE_DAYS`, `SEVEN_DAYS` (default) or `FOURTEEN_DAYS`.

A poll cannot be combined with `mediaItems` or `reshareUrl`, and cannot be edited after publishing.

API-created polls are non-sponsored only (they cannot be promoted as ads):

```json
{
  "platform": "linkedin",
  "accountId": "66b2e19d8c3f5a7e9d0b1c2d",
  "platformSpecificData": {
    "poll": {
      "question": "Which feature should we build next?",
      "options": ["API keys", "Webhooks", "SDKs"],
      "duration": "SEVEN_DAYS"
    }
  }
}
```

## Repost

`reshareUrl` reposts an existing LinkedIn post. It takes the post's link (its "Copy link to post" action) or a `urn:li:share`, `urn:li:ugcPost` or `urn:li:groupPost` URN.

The published post is always a reshare authored by your account, with the original embedded underneath:

- With `content` or `customContent`, your text is the commentary ("repost with your thoughts").
- With no text, it publishes as a text-free reshare.

LinkedIn's API cannot create the one-click "Repost" feed treatment where the original author stays the author.

`reshareUrl` is mutually exclusive with `mediaItems`, and works on personal profiles and organization pages:

```json
{
  "platform": "linkedin",
  "accountId": "66b2e19d8c3f5a7e9d0b1c2d",
  "platformSpecificData": {
    "reshareUrl": "https://www.linkedin.com/posts/someone_some-post-id"
  }
}
```

## First comment

`firstComment` posts a comment right after publishing. Put external links there, because LinkedIn suppresses posts with a URL in the caption:

```json
{
  "platform": "linkedin",
  "accountId": "66b2e19d8c3f5a7e9d0b1c2d",
  "platformSpecificData": {
    "firstComment": "Read the full guide here: https://example.com/api-guide"
  }
}
```

## Link preview

A text post with a URL and no media gets an automatic preview card. `disableLinkPreview: true` suppresses it:

```json
{
  "platform": "linkedin",
  "accountId": "66b2e19d8c3f5a7e9d0b1c2d",
  "platformSpecificData": { "disableLinkPreview": true }
}
```

## Post to several organizations

One connected account can post to every organization page the member administers. List them with [LinkedIn organizations](/connect/get-linkedin-organizations):

```bash
curl "https://zernio.com/api/v1/accounts/66b2e19d8c3f5a7e9d0b1c2d/linkedin-organizations" \
  -H "Authorization: Bearer $ZERNIO_API_KEY"
```

Response (`200`):

```json
{
  "organizations": [
    { "id": "111111111", "name": "Example Corp", "vanityName": "example-corp", "localizedName": "Example Corp" },
    { "id": "222222222", "name": "Example Labs", "vanityName": "example-labs", "localizedName": "Example Labs" }
  ]
}
```

Then repeat the `platforms` entry with the same `accountId` and a different `organizationUrn` (`urn:li:organization:` followed by the organization id).

Omit it to post to the account's default organization or personal profile:

```json
"platforms": [
  {
    "platform": "linkedin",
    "accountId": "66b2e19d8c3f5a7e9d0b1c2d",
    "platformSpecificData": { "organizationUrn": "urn:li:organization:111111111" }
  },
  {
    "platform": "linkedin",
    "accountId": "66b2e19d8c3f5a7e9d0b1c2d",
    "platformSpecificData": { "organizationUrn": "urn:li:organization:222222222" }
  }
]
```

## Geo-restriction

`geoRestriction.countries` limits who sees the post: only followers in the listed countries.

Organization pages only. LinkedIn rejects the post unless the targeted audience exceeds 300 followers:

```json
{
  "platform": "linkedin",
  "accountId": "66b2e19d8c3f5a7e9d0b1c2d",
  "platformSpecificData": {
    "geoRestriction": { "countries": ["US", "ES"] }
  }
}
```

`countries` takes up to 25 uppercase ISO 3166-1 alpha-2 codes.

Zernio resolves them to LinkedIn geo URNs. 45 countries are mapped, and unsupported codes are skipped silently.

## Edit a published post

[Edit post](/posts/edit-post) replaces the text of a LinkedIn post that is already published, on member profiles and organization pages alike.

- Edits are text-only and capped at the same 3,000 characters as publishing.
- There is no time window and no limit on the number of edits.
- The post keeps its id, and LinkedIn shows an "edited" marker on it.
- Mentions and hashtags in the new text are preserved.
- Media, polls, articles and reshare targets cannot be changed.

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="Node.js">
```typescript
const { data: edited } = await zernio.posts.editPost({
  path: { postId: '65f1c0a9e2b5af0012ab34cd' },
  body: {
    platform: 'linkedin',
    content: 'Updated post text with corrected information',
    accountId: '66b2e19d8c3f5a7e9d0b1c2d'
  }
});

console.log(edited.url);
```
</Tab>
<Tab value="Python">
```python
edited = client.posts.edit_post(
    post_id="65f1c0a9e2b5af0012ab34cd",
    platform="linkedin",
    content="Updated post text with corrected information",
    account_id="66b2e19d8c3f5a7e9d0b1c2d"
)

print(edited["url"])
```
</Tab>
<Tab value="curl">
```bash
curl -X POST https://zernio.com/api/v1/posts/65f1c0a9e2b5af0012ab34cd/edit \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "platform": "linkedin",
    "content": "Updated post text with corrected information",
    "accountId": "66b2e19d8c3f5a7e9d0b1c2d"
  }'
```
</Tab>
</Tabs>

Response (`200`):

```json
{
  "success": true,
  "id": "urn:li:share:7200000000000000000",
  "url": "https://www.linkedin.com/feed/update/urn:li:share:7200000000000000000"
}
```

`accountId` picks which copy to edit when the post went to several LinkedIn accounts. Without it, the first `linkedin` entry on the post is edited.