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

# Agent Documents

> List, upload, and delete agent knowledge-base documents through the frontend API.

## Agent Documents

Manages documents in an agent's knowledge base. This endpoint supports GET, POST, and DELETE operations.

### List Documents

**Method:** `GET`\
**Endpoint:** `/api/agent-documents`\
**Headers:**

* `X-Authorization`: Your API key (required)

**Query Parameters:**

* `uid` (string, required): Your user ID
* `agentId` (string, required): The ID of the agent

**Response:**

```json theme={null}
{
  "documents": [
    {
      "id": "string",
      "name": "string",
      "active": boolean,
      "fileUrl": "string",
      "lastUpdatedBy": "string",
      "lastUpdatedAt": "string"
    }
  ]
}
```

### Add Documents

**Method:** `POST`\
**Endpoint:** `/api/agent-documents`\
**Headers:**

* `X-Authorization`: Your API key (required)
* `Content-Type`: `multipart/form-data`

**Form Data:**

* `uid` (string, required): Your user ID
* `agentId` (string, required): The ID of the agent
* `files` (File\[], required): Array of files to upload (max 10 files, 10MB each)

**Supported File Types:**

* PDF (.pdf)
* Word documents (.docx)
* Text files (.txt)

**Response:**

```json theme={null}
{
  "documentIds": ["string"],
  "message": "Files uploaded successfully"
}
```

### Delete Document

**Method:** `DELETE`\
**Endpoint:** `/api/agent-documents`\
**Headers:**

* `X-Authorization`: Your API key (required)

**Query Parameters:**

* `uid` (string, required): Your user ID
* `agentId` (string, required): The ID of the agent
* `documentId` (string, required): The ID of the document to delete

**Response:**

```json theme={null}
{
  "message": "Document deleted successfully"
}
```

### Error Responses

* `400 Bad Request`: Invalid request parameters, too many files, file too large, or unsupported file type
* `401 Unauthorized`: Invalid or missing API key, or insufficient permissions
* `404 Not Found`: Document not found (for DELETE operations)
* `500 Internal Server Error`: Server error

### Examples

**List documents:**

```bash theme={null}
curl -X GET "https://app.phonely.ai/api/agent-documents?uid=user123&agentId=agent456" \
  -H "X-Authorization: your-api-key"
```

**Upload documents:**

```bash theme={null}
curl -X POST https://app.phonely.ai/api/agent-documents \
  -H "X-Authorization: your-api-key" \
  -F "uid=user123" \
  -F "agentId=agent456" \
  -F "files=@document1.pdf" \
  -F "files=@document2.docx"
```

**Delete document:**

```bash theme={null}
curl -X DELETE "https://app.phonely.ai/api/agent-documents?uid=user123&agentId=agent456&documentId=doc789" \
  -H "X-Authorization: your-api-key"
```


## OpenAPI

````yaml GET /agent-documents
openapi: 3.0.1
info:
  title: Phonely API
  description: API for Phonely services including agent management and call summaries
  version: 1.0.0
servers:
  - url: https://app.phonely.ai/api
security: []
paths:
  /agent-documents:
    get:
      summary: List agent documents
      description: Retrieve all documents associated with a specific agent
      parameters:
        - name: uid
          in: query
          required: true
          schema:
            type: string
          description: User ID
        - name: agentId
          in: query
          required: true
          schema:
            type: string
          description: Agent ID
      responses:
        '200':
          description: List of documents
          content:
            application/json:
              schema:
                type: object
                properties:
                  documents:
                    type: array
                    items:
                      $ref: '#/components/schemas/Document'
        '400':
          description: Invalid parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    Document:
      type: object
      properties:
        id:
          type: string
          description: Document ID
        agentId:
          type: string
          description: Associated agent ID
        name:
          type: string
          description: Document name
        active:
          type: boolean
          description: Document active status
        fileUrl:
          type: string
          description: URL to access the document
        lastUpdatedBy:
          type: string
          description: Who last updated the document
        lastUpdatedAt:
          type: string
          format: date-time
          description: When the document was last updated
    Error:
      type: object
      properties:
        error:
          type: string
          description: Error code or identifier
        message:
          type: string
          description: Detailed error message
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-Authorization

````