# Create collection

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

Create a knowledge collection

## POST /beta/knowledge/collections

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

### Request example

```bash
curl -X POST 'https://dev.dixa.io/beta/knowledge/collections' \
  -H 'Authorization: <API token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "title": "Test Collection",
  "description": "This is a test collection",
  "internalKbEnabled": true
}'
```

### Response examples

#### 200 The created knowledge collection

```json
{
  "data": {
    "id": "78dfb531-2e1e-4ffc-bd18-fdad68cd2419",
    "title": "Test Collection",
    "description": "This is a test collection",
    "internalKbEnabled": true,
    "restrictions": {
      "isRestricted": true,
      "inheritedRestrictions": [
        {
          "fromCollection": "78dfb531-2e1e-4ffc-bd18-fdad68cd2419"
        }
      ]
    }
  }
}
```

#### 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/collections:
    post:
      tags:
        - Knowledge
      summary: Create collection
      description: Create a knowledge collection
      operationId: postKnowledgeCollections
      requestBody:
        description: The knowledge collection to create
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateKnowledgeCollectionInput"
        required: true
      responses:
        "200":
          description: The created knowledge collection
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CreateKnowledgeCollectionOutput"
        "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.collections:w
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      name: Authorization
      in: header
  schemas:
    CreateKnowledgeCollectionInput:
      title: CreateKnowledgeCollectionInput
      type: object
      required:
        - title
      properties:
        title:
          description: Title of the collection
          type: string
        description:
          description: Description of the collection
          type: string
        internalKbEnabled:
          description: Whether the collection is available to browse in the internal
            knowledge base. Defaults to true
          type: boolean
    CreateKnowledgeCollectionOutput:
      title: CreateKnowledgeCollectionOutput
      type: object
      required:
        - data
      properties:
        data:
          $ref: "#/components/schemas/Collection"
          description: The created collection
    Collection:
      title: Collection
      type: object
      required:
        - id
        - title
        - internalKbEnabled
        - restrictions
      properties:
        id:
          type: string
        title:
          type: string
        description:
          type: string
        internalKbEnabled:
          type: boolean
        restrictions:
          $ref: "#/components/schemas/Restrictions"
    Restrictions:
      title: Restrictions
      type: object
      required:
        - isRestricted
      properties:
        isRestricted:
          description: "Whether a restriction is set directly on this item. The only
            restriction is internal use: the content is available only to
            logged-in users"
          type: boolean
        inheritedRestrictions:
          description: Restrictions inherited from parent collections or categories. When
            several parents have the same restriction, only the top-most parent
            is listed
          type: array
          items:
            $ref: "#/components/schemas/InheritedRestriction"
    InheritedRestriction:
      title: InheritedRestriction
      type: object
      properties:
        fromCollection:
          description: ID of the collection the restriction is inherited from. Empty if it
            comes from a category
          type: string
        fromCategory:
          description: ID of the category the restriction is inherited from. Empty if it
            comes from a collection
          type: string
    BadRequest:
      title: BadRequest
      type: object
      required:
        - message
      properties:
        message:
          type: string
    ServerError:
      title: ServerError
      type: object
      required:
        - message
      properties:
        message:
          type: string
```
