# Upload post image

> Upload a cover or inline content image for an existing post with an account API key.

HTML version: https://blogizi.com/docs/api-upload-image
Markdown version: https://blogizi.com/docs/api-upload-image.md

Upload a **cover** (hero/listing) or **content** (inline markdown) image for an existing post using your account API key. Logo/favicon uploads remain dashboard-only.

## Request

```http
POST /api/upload
Authorization: Bearer YOUR_ACCOUNT_API_KEY
X-Blogizi-Project: your-project-slug
Content-Type: multipart/form-data
```

Multipart fields:

| Field | Required | Notes |
| --- | --- | --- |
| `file` | Yes | PNG, JPG, WebP, or SVG |
| `type` | Yes | `cover` or `content` (API key). Dashboard session also allows `logo` / `favicon`. |
| `projectId` or `projectSlug` | Yes* | *Optional when the account has exactly one project |
| `postId` or `postSlug` | Yes | Post must already exist — create a draft first |

Limits: cover max **2MB**, content max **5MB**. Recommended cover size: **1200×630 px**.

## Response

```json
{
  "data": {
    "url": "https://media.blogizi.com/content/…/….png",
    "markdown": "![](https://media.blogizi.com/content/…/….png)"
  }
}
```

`markdown` is returned for `type=content` so you can paste it into the post body. For `type=cover`, the URL is saved on the post immediately (no second request required).

## Insert into a post

1. `POST /api/posts` with `status: "draft"` (get `data._id` / slug)
2. `POST /api/upload` with `type=content` (or `cover`)
3. For content: `POST /api/posts` with `upsert: true` and the markdown image in `content`

CLI shortcut: `blogizi upload ./diagram.png --slug my-post --type content --alt "Diagram"`. MCP: [upload_post_image](/docs/mcp-upload-post-image).
