
# Procurize.AI REST API Reference

**Programmatically access your knowledge base – documents, questionnaires, RAG, and reports – using your API token.**

> **Applies to:** Procurize.AI API v1  
> **Authentication:** API key via `X-API-Key` header (see [API Tokens](/api-tokens/) for token management)  
> **Base URL:** `https://api.procurize.com`

## Overview

The Procurize.AI REST API provides programmatic access to key platform features. It enables you to integrate Procurize.AI with your internal systems, automate knowledge base management, and build custom workflows.

**Supported modules (token‑authenticated):**

- [**RagArticle**](#ragarticle) – manage documents
- [**RagFaq**](#ragfaq) – manage FAQ entries
- [**RagQuery**](#ragquery) – execute RAG queries

## Authentication

All authenticated endpoints require an API token passed in the request header.

| Header | Value |
|--------|-------|
| `X-API-Key` | `<YOUR_API_TOKEN>` |

**Example:**
```bash
curl -X GET "https://api.procurize.com/v1/..." \
  -H "X-API-Key: your-api-token-here"
```

> 💡 Tokens are bound to your organization – you do not need to specify an organization ID in the request .

## Base URL

All REST API endpoints are served under:
```
https://api.procurize.com
```

## Error Handling

The API uses standard HTTP status codes.

| Code | Meaning |
|------|---------|
| `200 OK` | Request successful |
| `201 Created` | Resource created successfully |
| `204 No Content` | Request successful, no response body |
| `400 Bad Request` | Invalid parameters or malformed request |
| `401 Unauthorized` | Missing or invalid API token |
| `403 Forbidden` | Token does not have permission for this action |
| `404 Not Found` | Resource does not exist |
| `500 Internal Server Error` | Unexpected server error |

Error responses include a machine‑readable error code and a human‑readable message.

## Module Reference

### RagArticle

#### GET /questionnaire/rag/articles/summary

**Summary:** Summary for Home page

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| proj | query | string (uuid) | No | Project ID. |

**Response (200):**
```json
{
  "active": 5
}
```

---

#### GET /questionnaire/rag/articles/total

**Summary:** Number of articles

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| q | query | string | No | Filter on article name or code. |
| state | query | array | No | Filter on states. |
| project | query | array | No | Filter on projects. |
| type | query | array | No | Filter on document types. |

**Response (200):**
```json
42
```

---

#### GET /questionnaire/rag/articles/list

**Summary:** Get list of articles

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| q | query | string | No | Filter on article name or code. |
| state | query | array | No | Filter on states. |
| project | query | array | No | Filter on projects. |
| type | query | array | No | Filter on document types. |
| s | query | string | No | Sort field. |
| asc | query | boolean | No | Ascending sort. |
| ps | query | integer (int32) | No | Page size. |
| p | query | integer (int32) | No | 1-based page number. |

**Response (200):**
```json
{
  "paging": {
    "pageNumber": 1,
    "pageSize": 10,
    "total": 42,
    "totalPages": 5
  },
  "items": [
    {
      "code": "ART-001",
      "org": "00000000-0000-0000-0000-000000000000",
      "id": "00000000-0000-0000-0000-000000000000",
      "name": "Article Title",
      "description": "Article description",
      "documentTypes": [
        {
          "id": "00000000-0000-0000-0000-000000000000",
          "name": "Type Name",
          "plural": "Type Names",
          "count": 5
        }
      ],
      "size": 150,
      "revision": {
        "id": "00000000-0000-0000-0000-000000000000",
        "collectionId": "00000000-0000-0000-0000-000000000000",
        "rev": 3,
        "date": "2025-01-15T10:30:00Z",
        "author": {
          "id": "user123",
          "name": "John Doe",
          "email": "john.doe@example.com",
          "login": "johndoe",
          "ra": true
        },
        "authorName": "John Doe",
        "analysisSummary": {
          "id": "00000000-0000-0000-0000-000000000000",
          "initiator": {
            "id": "user123",
            "name": "John Doe",
            "email": "john.doe@example.com",
            "login": "johndoe",
            "ra": true
          },
          "created": "2025-01-15T10:30:00Z",
          "state": "Completed",
          "stateDate": "2025-01-15T10:35:00Z",
          "stateDetails": "Analysis completed successfully",
          "operationId": "op-12345"
        }
      },
      "type": "Article",
      "state": "Active",
      "projects": [
        "00000000-0000-0000-0000-000000000000"
      ],
      "items": [
        "00000000-0000-0000-0000-000000000000"
      ],
      "isShared": false
    }
  ]
}
```

---

#### POST /questionnaire/rag/file-to-md

**Summary:** Returns Markdown content from the file

**Request Body (multipart/form-data):**
```json
{
  "url": "https://example.com/file.pdf",
  "file": "binary"
}
```

**Response (200):**
```json
"Markdown content from file"
```

---

#### POST /questionnaire/rag/article/create

**Summary:** Create an article

**Request Body (multipart/form-data):**
```json
{
  "code": "ART-001",
  "name": "Article Title",
  "description": "Article description",
  "content": "# Article Content\n\nThis is the article content.",
  "url": "https://example.com/file.pdf",
  "file": "binary"
}
```

**Response (200):**
```json
{
  "code": "ART-001",
  "org": "00000000-0000-0000-0000-000000000000",
  "id": "00000000-0000-0000-0000-000000000000",
  "name": "Article Title",
  "description": "Article description",
  "documentTypes": null,
  "size": 150,
  "revision": null,
  "type": "Article",
  "state": "Active",
  "projects": null,
  "items": null,
  "isShared": false
}
```

---

#### GET /questionnaire/rag/article/check

**Summary:** Check existence of article.

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| code | query | string | Yes | Code of the article. |

**Response (200):**
```json
true
```

---

#### GET /questionnaire/rag/article-info

**Summary:** Get article info by code.

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| code | query | string | Yes | Code of the article. |

**Response (200):**
```json
{
  "code": "ART-001",
  "org": "00000000-0000-0000-0000-000000000000",
  "id": "00000000-0000-0000-0000-000000000000",
  "name": "Article Title",
  "description": "Article description",
  "documentTypes": null,
  "size": 150,
  "revision": null,
  "type": "Article",
  "state": "Active",
  "projects": null,
  "items": null,
  "isShared": false
}
```

---

#### GET /questionnaire/rag/article

**Summary:** Get article content by code

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| code | query | string | Yes | Code of the article. |
| format | query | string | No | If true, returns HTML content in the response body. Otherwise returns the article content in Markdown format. |
| split | query | boolean | No | If true, returns the content separated by RAG elements. |
| css | query | boolean | No | If true, returns the HTML/PDF content with CSS. |

**Response (200):**
```json
"# Article Title\n\nThis is the article content in Markdown format."
```

#### POST /questionnaire/rag/article

**Summary:** Update article metadata

**Request Body:**
```json
{
  "code": "ART-001",
  "name": "Updated Article Title",
  "description": "Updated description",
  "projects": [
    "00000000-0000-0000-0000-000000000000"
  ],
  "documentTypes": [
    {
      "id": "00000000-0000-0000-0000-000000000000",
      "name": "Type Name",
      "plural": "Type Names"
    }
  ],
  "isShared": true,
  "state": "Active"
}
```

**Response (200):**
```json
{}
```

#### DELETE /questionnaire/rag/article

**Summary:** Delete article

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| code | query | string | Yes | Code of the article. |

---

#### GET /questionnaire/rag/article/pdf

**Summary:** Get article as PDF by code

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| code | query | string | Yes | Code of the article. |

**Response (200):**
```json
(pdf binary)
```

---

#### GET /questionnaire/rag/article/content

**Summary:** Get article content

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| code | query | string | Yes | Code of the article. |

**Response (200):**
```json
{
  "content": "# Article Title\n\nContent here."
}
```

---

#### POST /questionnaire/rag/article/content

**Summary:** Update article content

**Request Body (multipart/form-data):**
```json
{
  "code": "ART-001",
  "content": "# Updated Content",
  "file": "binary"
}
```

---

#### POST /questionnaire/rag/plural

**Summary:** Get plural form of the noun

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| noun | query | string | No | Noun to pluralize. |

**Response (200):**
```json
{
  "plural": "Articles"
}
```

---

#### POST /questionnaire/rag/article/find-types

**Summary:** Analyze article with AI and return their types

**Request Body (multipart/form-data):**
```json
{
  "code": "ART-001",
  "content": "# Article Content"
}
```

**Response (200):**
```json
[
  {
    "plural": "Types"
  }
]
```

---

#### POST /questionnaire/rag/article/format-with-ai

**Summary:** Format article content with AI

**Request Body (multipart/form-data):**
```json
{
  "code": "ART-001",
  "content": "# Article Content"
}
```

**Response (200):**
```json
{
  "formattedContent": "# Formatted Article Content"
}
```

---

#### POST /questionnaire/rag/article/improve-on-suggestions

**Summary:** Improve the document based on suggestions

**Request Body (multipart/form-data):**
```json
{
  "suggestions": [
    {
      "sectionTitle": "Introduction",
      "suggestion": "Add more details here."
    }
  ],
  "code": "ART-001",
  "content": "# Article Content"
}
```

**Response (200):**
```json
{
  "improvedContent": "# Improved Content"
}
```

---

#### GET /questionnaire/rag/article/parts

**Summary:** Returns list of article parts

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| id | query | array | Yes | List of article parts. |

**Response (200):**
```json
[
  {
    "id": "00000000-0000-0000-0000-000000000000",
    "code": "part-1",
    "title": "Introduction",
    "orderNumber": 1,
    "content": "Introduction content."
  }
]
```

---

#### GET /questionnaire/rag/article/revisions

**Summary:** Returns list of article revisions

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| code | query | string | Yes | Code of the article. |

**Response (200):**
```json
[
  {
    "id": "00000000-0000-0000-0000-000000000000",
    "collectionId": "00000000-0000-0000-0000-000000000000",
    "rev": 1,
    "date": "2025-01-15T10:30:00Z",
    "author": {
      "id": "user123",
      "name": "John Doe",
      "email": "john.doe@example.com",
      "login": "johndoe",
      "ra": true
    },
    "authorName": "John Doe",
    "analysisSummary": {
      "id": "00000000-0000-0000-0000-000000000000",
      "initiator": {
        "id": "user123",
        "name": "John Doe",
        "email": "john.doe@example.com",
        "login": "johndoe",
        "ra": true
      },
      "created": "2025-01-15T10:30:00Z",
      "state": "Completed",
      "stateDate": "2025-01-15T10:35:00Z",
      "stateDetails": "Analysis completed",
      "operationId": "op-12345"
    }
  }
]
```

---

#### GET /questionnaire/rag/article/revisions/info/{id}

**Summary:** Get article revision info

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| id | path | string (uuid) | Yes | Revision ID. |

**Response (200):**
```json
{
  "id": "00000000-0000-0000-0000-000000000000",
  "collectionId": "00000000-0000-0000-0000-000000000000",
  "rev": 1,
  "date": "2025-01-15T10:30:00Z",
  "author": {
    "id": "user123",
    "name": "John Doe",
    "email": "john.doe@example.com",
    "login": "johndoe",
    "ra": true
  },
  "authorName": "John Doe",
  "analysisSummary": {
    "id": "00000000-0000-0000-0000-000000000000",
    "initiator": {
      "id": "user123",
      "name": "John Doe",
      "email": "john.doe@example.com",
      "login": "johndoe",
      "ra": true
    },
    "created": "2025-01-15T10:30:00Z",
    "state": "Completed",
    "stateDate": "2025-01-15T10:35:00Z",
    "stateDetails": "Analysis completed",
    "operationId": "op-12345"
  }
}
```

---

#### GET /questionnaire/rag/article/revisions/{id}

**Summary:** Get article revision content

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| id | path | string (uuid) | Yes | Revision ID. |

**Response (200):**
```json
"# Article Revision Content\n\nPrevious version."
```

---

#### GET /questionnaire/rag/article/analyze

**Summary:** Analyze article content with AI

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| code | query | string | Yes | Code of the article. |
| rev | query | integer (int32) | No | Revision number. |
| force | query | boolean | No | Force create new analysis and delete previous incomplete analysis result if exists. |

**Response (200):**
```json
{
  "id": "00000000-0000-0000-0000-000000000000",
  "initiator": {
    "id": "user123",
    "name": "John Doe",
    "email": "john.doe@example.com",
    "login": "johndoe",
    "ra": true
  },
  "created": "2025-01-15T10:30:00Z",
  "state": "Completed",
  "stateDate": "2025-01-15T10:35:00Z",
  "stateDetails": "Analysis completed",
  "operationId": "op-12345"
}
```

---

#### GET /questionnaire/rag/article/analyze/{id}

**Summary:** Get article analysis result

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| id | path | string (uuid) | Yes | Analysis ID. |

**Response (200):**
```json
{
  "id": "00000000-0000-0000-0000-000000000000",
  "initiator": {
    "id": "user123",
    "name": "John Doe",
    "email": "john.doe@example.com",
    "login": "johndoe",
    "ra": true
  },
  "created": "2025-01-15T10:30:00Z",
  "state": "Completed",
  "stateDate": "2025-01-15T10:35:00Z",
  "stateDetails": "Analysis completed",
  "operationId": "op-12345",
  "fragments": [
    "fragment-1",
    "fragment-2"
  ],
  "ownInconcies": "Own inconsistencies found",
  "ragInconcies": "RAG inconsistencies found",
  "proposals": "Improvement proposals"
}
```

---

#### GET /questionnaire/rag/messages/list

**Summary:** List all messages

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| id | query | string (uuid) | Yes | RAG Collection ID. |
| item | query | string (uuid) | No | RAG Item ID. |
| message | query | string (uuid) | No | Message ID. |
| asc | query | boolean | No | Ascending sort. |
| ps | query | integer (int32) | No | Page size. |
| p | query | integer (int32) | No | 1-based page number. |

**Response (200):**
```json
{
  "paging": {
    "pageNumber": 1,
    "pageSize": 10,
    "total": 5,
    "totalPages": 1
  },
  "items": [
    {
      "id": "00000000-0000-0000-0000-000000000000",
      "replyTo": null,
      "questionnaire": null,
      "section": null,
      "question": null,
      "ragCollection": "00000000-0000-0000-0000-000000000000",
      "ragItem": "00000000-0000-0000-0000-000000000000",
      "targetId": "00000000-0000-0000-0000-000000000000",
      "targetType": "Question",
      "targetNum": 1,
      "author": {
        "id": "user123",
        "name": "John Doe",
        "email": "john.doe@example.com",
        "login": "johndoe",
        "ra": true
      },
      "text": "Message content",
      "created": "2025-01-15T10:30:00Z",
      "updated": "2025-01-15T10:30:00Z",
      "replies": 0
    }
  ]
}
```

---

#### POST /questionnaire/rag/messages/add

**Summary:** Add new message

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| id | query | string (uuid) | Yes | RAG Collection ID. |
| item | query | string (uuid) | No | RAG Item ID. |
| message | query | string (uuid) | No | Message ID to reply. |

**Request Body:**
```json
{
  "text": "New message content"
}
```

**Response (200):**
```json
{
  "id": "00000000-0000-0000-0000-000000000000",
  "replyTo": null,
  "questionnaire": null,
  "section": null,
  "question": null,
  "ragCollection": "00000000-0000-0000-0000-000000000000",
  "ragItem": "00000000-0000-0000-0000-000000000000",
  "targetId": "00000000-0000-0000-0000-000000000000",
  "targetType": "Question",
  "targetNum": 1,
  "author": {
    "id": "user123",
    "name": "John Doe",
    "email": "john.doe@example.com",
    "login": "johndoe",
    "ra": true
  },
  "text": "New message content",
  "created": "2025-01-15T10:30:00Z",
  "updated": "2025-01-15T10:30:00Z",
  "replies": 0
}
```

---

#### POST /questionnaire/rag/message

**Summary:** Update existing message

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| c | query | string (uuid) | Yes | RAG Collection ID. |
| id | query | string (uuid) | Yes | Message ID. |

**Request Body:**
```json
{
  "text": "Updated message content"
}
```

**Response (200):**
```json
{
  "id": "00000000-0000-0000-0000-000000000000",
  "replyTo": null,
  "questionnaire": null,
  "section": null,
  "question": null,
  "ragCollection": "00000000-0000-0000-0000-000000000000",
  "ragItem": "00000000-0000-0000-0000-000000000000",
  "targetId": "00000000-0000-0000-0000-000000000000",
  "targetType": "Question",
  "targetNum": 1,
  "author": {
    "id": "user123",
    "name": "John Doe",
    "email": "john.doe@example.com",
    "login": "johndoe",
    "ra": true
  },
  "text": "Updated message content",
  "created": "2025-01-15T10:30:00Z",
  "updated": "2025-01-15T10:45:00Z",
  "replies": 0
}
```

#### DELETE /questionnaire/rag/message

**Summary:** Delete existing message

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| id | query | string (uuid) | Yes | Message ID. |

**Response (200):**
```json
{}
```

---

### RagFaq

#### GET /questionnaire/rag/faq-collections/summary

**Summary:** Summary for Home page

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| proj | query | string (uuid) | No | Project ID. |

**Response (200):**
```json
{
  "active": 3
}
```

---

#### GET /questionnaire/rag/faq-collections/total

**Summary:** Number of FAQ collections.

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| q | query | string | No | Filter on collection name or code. |
| state | query | array | No | Filter on states. |
| project | query | array | No | Filter on projects. |

**Response (200):**
```json
3
```

---

#### GET /questionnaire/rag/faq-collections/list

**Summary:** Get list of FAQ collections.

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| q | query | string | No | Filter on collection name or code. |
| state | query | array | No | Filter on states. |
| project | query | array | No | Filter on projects. |
| s | query | string | No | Sort field. |
| asc | query | boolean | No | Ascending sort. |
| ps | query | integer (int32) | No | Page size. |
| p | query | integer (int32) | No | 1-based page number. |

**Response (200):**
```json
{
  "paging": {
    "pageNumber": 1,
    "pageSize": 10,
    "total": 3,
    "totalPages": 1
  },
  "items": [
    {
      "code": "FAQ-001",
      "org": "00000000-0000-0000-0000-000000000000",
      "id": "00000000-0000-0000-0000-000000000000",
      "name": "FAQ Collection",
      "description": "FAQ collection description",
      "documentTypes": null,
      "size": 5,
      "revision": null,
      "type": "Faq",
      "state": "Active",
      "projects": null,
      "items": null,
      "isShared": false
    }
  ]
}
```

---

#### GET /questionnaire/rag/faq-collections/find-items

**Summary:** Find FAQ items.

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| q | query | string | Yes | Filter on question. |
| project | query | string (uuid) | No | Filter on project. |
| ps | query | integer (int32) | No | Page size. |
| p | query | integer (int32) | No | 1-based page number. |

**Response (200):**
```json
{
  "paging": {
    "pageNumber": 1,
    "pageSize": 10,
    "total": 5,
    "totalPages": 1
  },
  "items": [
    {
      "index": 0,
      "question": "What is this product?",
      "answer": "This is a great product.",
      "comment": "Product FAQ",
      "state": "Active"
    }
  ]
}
```

---

#### POST /questionnaire/rag/faq-collection/create

**Summary:** Create new FAQ collection.

**Request Body (multipart/form-data):**
```json
{
  "code": "FAQ-001",
  "name": "FAQ Collection",
  "description": "FAQ collection description",
  "content": "Content here",
  "file": "binary"
}
```

**Response (200):**
```json
{
  "code": "FAQ-001",
  "id": "00000000-0000-0000-0000-000000000000",
  "name": "FAQ Collection",
  "description": "FAQ collection description",
  "documentTypes": null,
  "size": 5,
  "revision": null,
  "type": "Faq",
  "state": "Active",
  "projects": null,
  "items": null,
  "isShared": false
}
```

---

#### POST /questionnaire/rag/faq-collection

**Summary:** Update FAQ collection metadata.

**Request Body:**
```json
{
  "code": "FAQ-001",
  "name": "Updated FAQ Collection",
  "description": "Updated description",
  "projects": null,
  "documentTypes": null,
  "isShared": false,
  "state": "Active"
}
```

#### DELETE /questionnaire/rag/faq-collection

**Summary:** Delete FAQ collection.

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| code | query | string | Yes | Code of the article. |

#### GET /questionnaire/rag/faq-collection

**Summary:** Get FAQ collection.

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| code | query | string | Yes | Code of the collection. |

**Response (200):**
```json
{
  "code": "FAQ-001",
  "org": "00000000-0000-0000-0000-000000000000",
  "id": "00000000-0000-0000-0000-000000000000",
  "name": "FAQ Collection",
  "description": "FAQ collection description",
  "documentTypes": null,
  "size": 5,
  "revision": null,
  "type": "Faq",
  "state": "Active",
  "projects": null,
  "items": null,
  "isShared": false
}
```

---

#### GET /questionnaire/rag/faq-collection/check

**Summary:** Check existence of FAQ collection.

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| code | query | string | Yes | Code of the collection. |

**Response (200):**
```json
true
```

---

#### GET /questionnaire/rag/faq-collection/items-total

**Summary:** Number of FAQ items.

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| code | query | string | Yes | Code of the collection. |
| q | query | string | No | Filter on FAQ item content. |

**Request Body:**
```json
["Active", "Default"]
```

**Response (200):**
```json
5
```

---

#### GET /questionnaire/rag/faq-collection/items

**Summary:** Get list of FAQ items.

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| code | query | string | Yes | Code of the collection. |
| q | query | string | No | Filter on FAQ item content. |
| state | query | array | No | Filter on states. |
| s | query | string | No | Sort field. |
| asc | query | boolean | No | Ascending sort. |
| ps | query | integer (int32) | No | Page size. |
| p | query | integer (int32) | No | 1-based page number. |

**Response (200):**
```json
{
  "paging": {
    "pageNumber": 1,
    "pageSize": 10,
    "total": 5,
    "totalPages": 1
  },
  "items": [
    {
      "index": 0,
      "question": "What is this product?",
      "answer": "This is a great product.",
      "comment": "Product FAQ",
      "state": "Active"
    }
  ]
}
```

---

#### POST /questionnaire/rag/faq-collection/item/create

**Summary:** Create new FAQ item.

**Request Body:**
```json
{
  "code": "FAQ-001",
  "index": 0,
  "question": "What is this product?",
  "answer": "This is a great product.",
  "comment": "Product FAQ",
  "state": "Active"
}
```

**Response (200):**
```json
{
  "index": 0,
  "question": "What is this product?",
  "answer": "This is a great product.",
  "comment": "Product FAQ",
  "state": "Active"
}
```

---

#### GET /questionnaire/rag/faq-collection/item

**Summary:** Get FAQ item.

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| code | query | string | Yes | Code of the collection. |
| index | query | integer (int32) | Yes | Zero-based index of the FAQ item in the collection. |

**Response (200):**
```json
{
  "index": 0,
  "question": "What is this product?",
  "answer": "This is a great product.",
  "comment": "Product FAQ",
  "state": "Active"
}
```

#### POST /questionnaire/rag/faq-collection/item

**Summary:** Update FAQ item.

**Request Body:**
```json
{
  "code": "FAQ-001",
  "index": 0,
  "newIndex": 1,
  "question": "Updated question?",
  "answer": "Updated answer.",
  "comment": "Updated comment",
  "state": "Active"
}
```

#### DELETE /questionnaire/rag/faq-collection/item

**Summary:** Delete FAQ item.

**Parameters:**
| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| code | query | string | Yes | Code of the collection. |
| index | query | integer (int32) | Yes | Zero-based index of the FAQ item in the collection. |

---

### RagQuery

#### POST /questionnaire/rag/query

**Summary:** Do query in RAG Knowledge Base

**Request Body:**
```json
{
  "project": "00000000-0000-0000-0000-000000000000",
  "excludeCollections": [
    "00000000-0000-0000-0000-000000000000"
  ],
  "question": "What is this product?",
  "yourCompanyName": "Acme Corp",
  "yourCompanyAlias": "Acme",
  "customerName": "John Doe",
  "options": [
    "option1",
    "option2"
  ],
  "multiselect": false,
  "nArticles": 5,
  "nFaqs": 3,
  "threshold": 0.5,
  "debug": false,
  "withJustification": true,
  "withConfidenceLevel": true,
  "withFragments": true,
  "nAttempts": 3
}
```

**Response (200):**
```json
{
  "attempt": 1,
  "preparedQuery": {
    "original": "What is this product?",
    "enhanced": "What is this product and its features?"
  },
  "ragItems": [
    {
      "id": "00000000-0000-0000-0000-000000000000",
      "distance": 0.25
    }
  ],
  "question": "What is this product?",
  "generalInstructions": "Based on the knowledge base, here is the answer:",
  "text": "This product is a great solution for your needs.",
  "explanation": "The answer was found in multiple sources with high confidence."
}
```

---

#### POST /questionnaire/rag/query-stream

**Summary:** Do query in RAG Knowledge Base

**Request Body:**
```json
{
  "project": "00000000-0000-0000-0000-000000000000",
  "excludeCollections": [
    "00000000-0000-0000-0000-000000000000"
  ],
  "question": "What is this product?",
  "yourCompanyName": "Acme Corp",
  "yourCompanyAlias": "Acme",
  "customerName": "John Doe",
  "options": [
    "option1",
    "option2"
  ],
  "multiselect": false,
  "nArticles": 5,
  "nFaqs": 3,
  "threshold": 0.5,
  "debug": false,
  "withJustification": true,
  "withConfidenceLevel": true,
  "withFragments": true,
  "nAttempts": 3
}
```

**Response (200):**
```json
[
  {
    "text": "This product is a great solution",
    "fragments": [
      {
        "id": "00000000-0000-0000-0000-000000000000",
        "part": 1,
        "distance": 0.25,
        "type": "Article",
        "code": "ART-001",
        "title": "Product Title",
        "fragment": "Product content fragment"
      }
    ]
  },
  {
    "text": " for your needs.",
    "fragments": []
  }
]
```

---

#### POST /questionnaire/rag/query-fragments

**Summary:** Do query in RAG Knowledge Base

**Request Body:**
```json
{
  "project": "00000000-0000-0000-0000-000000000000",
  "exclude_documents": [
    "00000000-0000-0000-0000-000000000000"
  ],
  "query": "What is this product?",
  "top_k": 5,
  "similarity_threshold": 0.5,
  "prepare_query": true
}
```

**Response (200):**
```json
{
  "results": [
    {
      "document_id": "00000000-0000-0000-0000-000000000000",
      "document_code": "ART-001",
      "document_title": "Product Title",
      "revision": 3,
      "chunk_index": 0,
      "content": "Product content fragment",
      "metadata": {
        "author": "John Doe",
        "created_at": "2025-01-15T10:30:00Z",
        "last_updated_at": "2025-01-15T10:35:00Z",
        "doc_categories": [
          "Product",
          "Information"
        ]
      },
      "similarity_score": 0.85
    }
  ]
}
```

## Related Articles

- [API Tokens – Generation & Management](/api-tokens/) – how to create and manage tokens
- [Ask AI with your knowledge base](/ask-ai-with-your-knowledge-base/) – using RAG queries
