Managing KB Article Attachments Using BoldDesk REST API
This article provides a comprehensive guide to managing Knowledge Base (KB) article attachments using the BoldDesk REST API. It covers authentication, testing via Swagger, and implementation of key endpoints for uploading, retrieving, deleting, and embedding attachments.
API Authentication
To securely access BoldDesk APIs, authentication via OAuth 2.0 is required. You must obtain an access token using your Client ID and Client Secret, and include it in the Authorization header of each request.
Header Format:
Authorization: Bearer {access_token}
For detailed steps, refer to: BoldDesk API Authentication
Testing With Swagger
We recommend testing API endpoints using Swagger before integrating them into your application. Swagger provides an interactive interface to validate request formats and responses.
Access Swagger UI at: https://{yourdomain}/api/help/index.html
For a step-by-step guide, refer to: How to Test the BoldDesk REST API Using Swagger
KB Attachment API Endpoints
Below are the available endpoints for managing KB article attachments:
1. Upload Attachment
Use this endpoint to attach files such as images, documents, or other resources to a specific KB article. This helps enrich the article with supporting materials.
Endpoint:
POST /api/v1/kb/attachment
Query Parameter:
articleId(integer): ID of the target article.
Request Body:
multipart/form-datauploadFiles(binary): File to be uploaded.
Curl Example:
curl -X 'POST' 'https://{yourdomain}/api/v1/kb/attachment?articleId=1' -H 'accept: text/plain' -H 'x-api-key: {your_api_key}' -H 'Content-Type: multipart/form-data' -F '[email protected];type=image/png'
2. Get Article Attachments
This endpoint allows you to retrieve a list of all attachments linked to a KB article. It is useful for displaying or managing existing files.
Endpoint:
GET /api/v1/kb/{articleId}/attachments
Curl Example:
curl -X 'GET' 'https://{yourdomain}/api/v1/kb/77/attachments' -H 'accept: text/plain' -H 'x-api-key: {your_api_key}'
3. Delete Attachment
Use this endpoint to remove an attachment from a KB article. This is helpful for maintaining a clean and up-to-date knowledge base.
Endpoint:
DELETE /api/v1/kb/attachment/{id}
Curl Example:
curl -X 'DELETE' 'https://{yourdomain}/api/v1/kb/attachment/1' -H 'accept: text/plain' -H 'x-api-key: {your_api_key}'
4. Upload Inline Attachment
This endpoint enables you to embed images or files directly within the article content. It is ideal for adding visual elements that enhance readability.
Endpoint:
POST /api/v1/kb/attachment/inline
Query Parameters:
articleId(integer): ID of the target article.isInlineImage(boolean): Set totrueto mark as inline image.
Request Body:
multipart/form-datauploadFiles(binary): File to be uploaded.
Curl Example:
curl -X 'POST' 'https://{yourdomain}/api/v1/kb/attachment/inline?articleId=1&isInlineImage=true' -H 'accept: text/plain' -H 'x-api-key: {your_api_key}' -H 'Content-Type: multipart/form-data' -F 'uploadFiles=@Version_history.PNG;type=image/png'
Frequently Asked Questions (FAQs)
Q1: Which file types are supported for KB attachments?
BoldDesk supports common formats including PNG, JPG, and JPEG.
Q2: Can multiple files be uploaded at once?
Yes. The uploadFiles field accepts multiple file values in multipart form.
Q3: What is the difference between a regular attachment and an inline attachment?
- Attachment: Downloadable file listed under the article
- Inline Attachment: File embedded directly in the article body
Q4: Do I need OAuth authentication if I am using an API key?
BoldDesk supports both authentication methods depending on configuration. Check your account’s API settings.