# Attach files to agent (/docs/api-reference/knowledge-base/attachKnowledgeBaseFiles)

> Attach multiple knowledge-base files to an agent.



**POST** `/knowledge_base/attach`

Attach multiple knowledge-base files to an agent.

```yaml
operationId: attachKnowledgeBaseFiles
requestBody:
  required: true
  content:
    application/json:
      schema:
        type: object
        required:
          - file_ids
          - agent_id
        properties:
          file_ids:
            type: array
            minItems: 1
            items:
              type: integer
            description: List of knowledge-base file IDs to attach.
            example:
              - 17686
          agent_id:
            type: integer
            description: ID of the agent to attach files to.
            example: 158910
          when_to_use:
            type: string
            description: Instruction to the agent on when to consult these files.
            example: Use these documents to answer billing-related questions.
responses:
  '200':
    description: Files attached.
    content:
      application/json:
        schema:
          type: object
          properties:
            success:
              type: boolean
            message:
              type: string
        example:
          success: true
          message: 1 files attached to agent successfully
```

**Python SDK**

```python
# Attach files to an agent
file_ids = [123, 456]  # Replace with your file IDs
agent_id = 789  # Replace with your agent ID

response = client.knowledge_base.attach(
  file_ids,
  agent_id,
  when_to_use="Use KB When User ask for pricing"
)
print(response)
```

**curl**

```bash
curl -X POST "https://backend.omnidim.io/api/v1/knowledge_base/attach" \
  -H "Authorization: Bearer $OMNIDIM_API_KEY"
```
