# Publish a new post on the connected account's feed

**`POST https://myagentmail.com/linkedin/posts`**

Group: LinkedIn — Posts
Operation ID: `linkedinCreatePost`

Creates a feed post on the connected LinkedIn account. Text is
required; an inline image is optional. The endpoint handles the
underlying three-step LinkedIn upload flow (register upload → PUT bytes →
create share) so the customer just sends one JSON request.

**Visibility:**
- `ANYONE` (default) — public on the feed.
- `CONNECTIONS` — visible to 1st-degree connections only.

**Image:**
Pass an `image.dataUrl` (full data URL with embedded mime + base64) for
the simplest agent shape, OR a separate `image.base64` + `image.contentType`.
Accepts `image/png`, `image/jpeg`, `image/gif`, `image/webp` up to ~10 MB.

Quota: 1 `connection_request` slot per call (shared outbound-write
bucket).


## Request body

Content-Type: `application/json`

```json
{
  "sessionId": "string",
  "text": "string",
  "visibility": "ANYONE",
  "image": {
    "dataUrl": "string",
    "base64": "string",
    "contentType": "image/png",
    "altText": "string",
    "filename": "string"
  }
}
```

## Responses

### 200 — Post created.

```json
{
  "ok": false,
  "shareUrn": "urn:li:share:7455538267644641280",
  "shareId": "string",
  "postUrl": "https://example.com",
  "mediaUrn": "string"
}
```

### 400 — Validation error or LinkedIn rejected the post. Real LinkedIn

### 404 — Session not found.

### 429 — Daily quota exceeded for this session.

## Code samples

### TypeScript

```typescript
import { MyAgentMail } from "myagentmail";

const client = new MyAgentMail({ apiKey: process.env.MYAGENTMAIL_API_KEY! });

// POST /linkedin/posts
const result = await client.request("post", "/linkedin/posts", { body: {
  "sessionId": "string",
  "text": "string",
  "visibility": "ANYONE",
  "image": {
    "dataUrl": "string",
    "base64": "string",
    "contentType": "image/png",
    "altText": "string",
    "filename": "string"
  }
} });
```

### curl

```bash
curl -X POST 'https://myagentmail.com/linkedin/posts' \
  -H 'X-API-Key: $MYAGENTMAIL_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "sessionId": "string",
  "text": "string",
  "visibility": "ANYONE",
  "image": {
    "dataUrl": "string",
    "base64": "string",
    "contentType": "image/png",
    "altText": "string",
    "filename": "string"
  }
}'
```

### Python

```python
import os, requests

r = requests.post(
    "https://myagentmail.com/linkedin/posts",
    headers={"X-API-Key": os.environ["MYAGENTMAIL_API_KEY"]},
    json={
        "sessionId": "string",
        "text": "string",
        "visibility": "ANYONE",
        "image": {
            "dataUrl": "string",
            "base64": "string",
            "contentType": "image/png",
            "altText": "string",
            "filename": "string"
        }
    },
)
r.raise_for_status()
print(r.json())
```
