> ## Documentation Index
> Fetch the complete documentation index at: https://docs.unleashx.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Knowledge Base Status

> Update the status of a knowledge base item linked to a campaign. Resets the trained state, requiring re-training.

Use this endpoint to **update the status of a knowledge base item** linked to a campaign.

## Endpoint

**POST** `/update-knowledgebase-status`

**Content-Type:** `application/json`
**Authentication:** Required (workspace auth)

## Request Body

```json theme={null}
{
  "knowledge_base_id": 7,
  "status": "active"
}
```

| Field               | Type   | Required | Description                     |
| ------------------- | ------ | -------- | ------------------------------- |
| `knowledge_base_id` | number | Yes      | ID of the knowledge base record |
| `status`            | string | Yes      | `active` or `inactive`          |

## Response

```json theme={null}
{
  "message": "Knowledge base status updated successfully",
  "data": {
    "id": 7,
    "name": "faq.pdf",
    "status": 1
  }
}
```

## Behavior

* Updates the knowledge base `STATUS` and resets `TRAINED` to `0` (untrained), requiring re-training.
* Validates that the knowledge base record exists and is not deleted.
* Validates that the associated agent exists and is not deleted.

## Error Cases

| Error                        | Cause                                            |
| ---------------------------- | ------------------------------------------------ |
| `Knowledge base not found`   | Invalid `knowledge_base_id` or record is deleted |
| `Associated agent not found` | The linked agent has been removed                |

## Example cURL

```bash theme={null}
curl -X POST https://www.tryunleashx.com/api/v1/global/update-knowledgebase-status \
  -H "Content-Type: application/json" \
  -H "token: <api_key>" \
  -d '{
    "knowledge_base_id": 7,
    "status": "active"
  }'
```


## OpenAPI

````yaml api-reference/openapi.json POST /update-knowledgebase-status
openapi: 3.1.0
info:
  title: >-
    UnleashX - Build human like conversations | Voice Agents | Automations | AI
    Workforce
  version: 1.0.0
  description: UnleashX - Your home for human like conversations
servers:
  - url: https://www.tryunleashx.com/api/v1/global/
security:
  - bearerAuth: []
paths:
  /update-knowledgebase-status:
    post:
      tags:
        - Campaigns
      summary: Update knowledge base status
      description: >-
        Update the status of a knowledge base item linked to a campaign. Resets
        the trained state, requiring re-training.
      parameters:
        - name: token
          in: header
          required: true
          description: API token for authentication
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - knowledge_base_id
                - status
              properties:
                knowledge_base_id:
                  type: integer
                  description: ID of the knowledge base record
                status:
                  type: string
                  enum:
                    - active
                    - inactive
                  description: >-
                    New status value to set. Use 'active' to enable or
                    'inactive' to disable.
      responses:
        '200':
          description: Knowledge base status updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      name:
                        type: string
                      status:
                        type: integer
        '400':
          description: Bad Request
        '404':
          description: Knowledge base not found or associated agent not found
      security: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````