# Upload article attachments

URL: https://docs.dixa.io/openapi/dixa-api/beta/knowledge/postknowledgearticlesattachments

Upload one or more image files to be used as attachments in knowledge articles. Supported formats: image/png, image/jpeg, image/gif, image/webp. Maximum 5 files per request, 4 MB per file, with a total request payload limit of 10 MB. Supports partial success.

## POST /beta/knowledge/articles/attachments

- Server: https://dev.dixa.io
- Auth: `Authorization: <API token>` header

### Request example

_Generated from the schema; the spec has no example._

```bash
curl -X POST 'https://dev.dixa.io/beta/knowledge/articles/attachments' \
  -H 'Authorization: <API token>' \
  -F 'files=@<file>'
```

### Response examples

#### 200 The uploaded attachments, with partial errors if any

Every uploaded file was accepted:

```json
{
  "data": [
    {
      "originalFilename": "logo.png",
      "url": "https://cdn.example.com/images/org-id/uuid.png"
    },
    {
      "originalFilename": "banner.jpg",
      "url": "https://cdn.example.com/images/org-id/uuid2.jpg"
    }
  ],
  "partialErrors": []
}
```

Some files succeeded; others failed validation (400) or upload (500):

```json
{
  "data": [
    {
      "originalFilename": "logo.png",
      "url": "https://cdn.example.com/images/org-id/uuid.png"
    }
  ],
  "partialErrors": [
    {
      "originalFilename": "note.txt",
      "message": "Unsupported MIME type 'text/plain'. Allowed: image/gif, image/jpeg, image/png, image/webp",
      "code": 400
    },
    {
      "originalFilename": "huge.png",
      "message": "File exceeds 4 MB size limit",
      "code": 400
    },
    {
      "originalFilename": "hero.png",
      "message": "Upload failed due to unexpected error",
      "code": 500
    }
  ]
}
```

#### 400

```json
{
  "message": "Decoding failure in request"
}
```

#### 500 Internal failure during request processing

```json
{
  "message": "There was an internal server error while processing the request"
}
```

## OpenAPI definition

The operation and the schemas used, from the full spec at https://docs.dixa.io/openapi-specs/dixa-beta.yaml. Request and response examples are above.

```yaml
openapi: 3.0.3
info:
  title: Dixa API
  version: beta
servers:
  - url: https://dev.dixa.io
security:
  - ApiKeyAuth: []
paths:
  /beta/knowledge/articles/attachments:
    post:
      tags:
        - Knowledge
      summary: Upload article attachments
      description: "Upload one or more image files to be used as attachments in
        knowledge articles. Supported formats: image/png, image/jpeg, image/gif,
        image/webp. Maximum 5 files per request, 4 MB per file, with a total
        request payload limit of 10 MB. Supports partial success."
      operationId: postKnowledgeArticlesAttachments
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: "#/components/schemas/UploadAttachmentsInput"
        required: true
      responses:
        "200":
          description: The uploaded attachments, with partial errors if any
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UploadAttachmentsOutput"
        "400":
          description: ""
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BadRequest"
        "500":
          description: Internal failure during request processing
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ServerError"
      security:
        - ApiKeyAuth:
            - knowledge.content:w
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      name: Authorization
      in: header
  schemas:
    UploadAttachmentsInput:
      title: UploadAttachmentsInput
      type: object
      properties:
        files:
          description: One or more image files to upload as article attachments. Each part
            must be a supported image format.
          type: array
          items:
            type: string
            format: binary
    UploadAttachmentsOutput:
      title: UploadAttachmentsOutput
      type: object
      properties:
        data:
          description: Successfully uploaded attachments
          type: array
          items:
            $ref: "#/components/schemas/AttachmentResult"
        partialErrors:
          description: Errors for attachments that failed
          type: array
          items:
            $ref: "#/components/schemas/AttachmentError"
    AttachmentResult:
      title: AttachmentResult
      type: object
      required:
        - originalFilename
        - url
      properties:
        originalFilename:
          description: Original filename of the uploaded file
          type: string
        url:
          description: Public URL of the uploaded file
          type: string
    AttachmentError:
      title: AttachmentError
      type: object
      required:
        - originalFilename
        - message
        - code
      properties:
        originalFilename:
          description: Original filename of the failed file
          type: string
        message:
          description: Error message describing the failure
          type: string
        code:
          description: "HTTP-style status code: 400 for client-side errors, 500 for
            server-side errors"
          type: integer
          format: int32
    BadRequest:
      title: BadRequest
      type: object
      required:
        - message
      properties:
        message:
          type: string
    ServerError:
      title: ServerError
      type: object
      required:
        - message
      properties:
        message:
          type: string
```
