---
title: "Upload Knowledge Base Images"
url: "https://help.productfruits.com/en/article/knowledge-base-api-upload-images-endpoint"
language: "en"
last_updated: "2026-09-17T11:35:22.881Z"
---

# Upload Knowledge Base Images

## POST /upload-image - Upload Knowledge Base Images

Upload images for use in knowledge base articles. The uploaded images are stored on CDN and can be referenced in article content.

## Endpoint

```
POST /v1/knowledgebase/upload-image
```

## Request Headers

| Header | Value | Required |
| --- | --- | --- |
| `Authorization` | `Bearer YOUR_API_TOKEN` | Yes |
| `Content-Type` | `multipart/form-data` | Yes |

## Request Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `file` | `file` | Yes | The image file to upload |

### File Requirements

| Requirement | Value |
| --- | --- |
| **Supported Formats** | JPG, JPEG, PNG, GIF, WEBP |
| **Maximum File Size** | 10 MB |
| **Content Types** | `image/jpeg`, `image/jpg`, `image/png`, `image/gif`, `image/webp` |

## Response Format

### Success Response (200 OK)

```json
{
  "imageId": "123e4567-e89b-12d3-a456-426614174000",
  "imageUrl": "https://cdn-assets.productfruits.com/123e4567-e89b-12d3-a456-426614174000"
}
```

| Field | Type | Description |
| --- | --- | --- |
| `imageId` | `string` | Unique identifier of the uploaded image |
| `imageUrl` | `string` | Public CDN URL where the image can be accessed |

## Examples

### Example 1: Upload Image with cURL

```bash
curl -X POST "https://api.productfruits.com/v1/knowledgebase/upload-image" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -F "file=@/path/to/your/image.jpg"
```

**Response:**

```json
{
  "imageId": "550e8400-e29b-41d4-a716-446655440000",
  "imageUrl": "https://cdn-assets.productfruits.com/550e8400-e29b-41d4-a716-446655440000"
}
```

### Example 2: Error Handling Example

```bash
# Attempt to upload invalid file type
curl -X POST "https://api.productfruits.com/v1/knowledgebase/upload-image" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -F "file=@/path/to/document.pdf"
```

**Response (400 Bad Request):**

```json
{
  "error": "Invalid file type"
}
```

### Example 3: Upload and Use in Article Content

```javascript
// Step 1: Upload the image
const uploadResponse = await fetch('{base}/v1/knowledgebase/upload-image', {
  method: 'POST',
  headers: { 'Authorization': 'Bearer YOUR_API_TOKEN' },
  body: formData
});

const { imageUrl } = await uploadResponse.json();

// Step 2: Use the image in article content
const articleContent = `
# Tutorial with Screenshots

Here's how to complete the task:

![Step 1 Screenshot](${imageUrl})

Follow these steps to complete the process...
`;

// Step 3: Import the article with the image reference
const importResponse = await fetch('{base}/v1/knowledgebase/import', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    articles: [{
      correlationId: 'tutorial-001',
      contents: [{
        lang: 'en',
        title: 'Tutorial with Screenshots',
        content: articleContent,
        format: 'markdown',
        publishStatus: 'published'
      }]
    }]
  })
});
```

## Using Uploaded Images

### In Markdown Content

```markdown
# Article Title

Here's an embedded image:

![Alt text description](https://cdn-assets.productfruits.com/IMAGE_ID)

You can also use reference-style links:

[image]: https://cdn-assets.productfruits.com/IMAGE_ID "Image title"

![Alt text][image]
```

### In HTML Content

```html
<h1>Article Title</h1>

<p>Here's an embedded image:</p>

<img src="https://cdn-assets.productfruits.com/IMAGE_ID" 
     alt="Alt text description" 
     title="Image title" />

<p>You can also use responsive images:</p>

<img src="https://cdn-assets.productfruits.com/IMAGE_ID" 
     alt="Alt text description"
     style="max-width: 100%; height: auto;" />
```

## Best Practices

-   **Optimize Images**: Compress images before uploading to reduce file size and improve loading times
-   **Use Descriptive Alt Text**: Always provide meaningful alt text when using images in content
-   **Store Image References**: Save the `imageId` and `imageUrl` for future reference and content updates
-   **Validate Before Upload**: Check file type and size on the client side before uploading
-   **Handle Errors Gracefully**: Implement proper error handling for upload failures
-   **Use Appropriate Formats**:
-   PNG for images with transparency or sharp edges
-   JPG for photographs and complex images
-   WebP for modern browsers (best compression)
-   GIF for simple animations
-   **Consider Mobile**: Ensure images display well on mobile devices by using responsive sizing

## Image Management

### Image Lifecycle

-   **Upload**: Image is stored on CDN with unique ID
-   **Reference**: Use the returned URL in article content
-   **Usage**: Image is served from CDN when articles are viewed
-   **Persistence**: Images remain available as long as they're referenced

### Image URLs

-   All uploaded images are served from [`https://cdn-assets.productfruits.com/`](https://cdn-assets.productfruits.com/)
-   URLs are permanent and can be cached
-   Images are served with appropriate caching headers for optimal performance

### Security

-   Only authenticated users can upload images
-   File type validation prevents malicious uploads
-   File size limits prevent abuse
-   All uploads are scanned for security threats

## Video Support

⚠️ **Video uploads are not currently supported through the API.**

**Supported video embedding options:**

-   **YouTube**: Use YouTube video URLs or embed codes in your content
-   **Vimeo**: Use Vimeo video URLs or embed codes in your content
-   **Loom**: Use Loom video URLs or embed codes in your content

For direct video hosting, use external platforms and reference them in your article content.

### Error Response Examples

#### 400 Bad Request - No File Provided

```json
{
  "error": "No file provided"
}
```

#### 400 Bad Request - Invalid File Type

```json
{
  "error": "Invalid file type"
}
```

#### 400 Bad Request - File Too Large

```json
{
  "error": "File too large. Maximum size is 10MB"
}
```

#### 401 Unauthorized

```json
{
  "error": "Authentication required or invalid API token"
}
```

#### 500 Internal Server Error

```json
{
  "error": "Internal server error occurred while uploading image"
}
```

## Rate Limiting

Please see this [article](https://help.productfruits.com/en/article/rest-api-rate-limiting) detailed information about API limits and optimization strategies.
