
# Procurize.AI REST API-referentie

**Programmeert toegang tot je kennisbank – documenten, vragenlijsten, RAG en rapporten – met je API-token.**

> **Van toepassing op:** Procurize.AI API v1  
> **Authenticatie:** API-sleutel via `X-API-Key` header (zie [API Tokens](/api-tokens/) voor tokenbeheer)  
> **Basis-URL:** `https://api.procurize.com`

## Overzicht

De Procurize.AI REST API biedt programmatische toegang tot belangrijke platformfuncties. Het stelt je in staat om Procurize.AI te integreren met je interne systemen, beheer van de kennisbank te automatiseren en aangepaste workflows te bouwen.

**Ondersteunde modules (token‑geauthenticeerd):**

- [**RagArticle**](#ragarticle) – beheer documenten
- [**RagFaq**](#ragfaq) – beheer FAQ‑items
- [**RagQuery**](#ragquery) – voer RAG‑queries uit

## Authenticatie

Alle geauthenticeerde eindpunten vereisen een API-token dat wordt meegegeven in de request-header.

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

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

> 💡 Tokens zijn gekoppeld aan je organisatie – je hoeft geen organisatie‑ID op te geven in het verzoek.

## Basis-URL

Alle REST API‑eindpunten worden geserveerd onder:
```
https://api.procurize.com
```

## Foutafhandeling

De API gebruikt standaard HTTP‑statuscodes.

| Code | Betekenis |
|------|-----------|
| `200 OK` | Verzoek geslaagd |
| `201 Created` | Resource succesvol aangemaakt |
| `204 No Content` | Verzoek geslaagd, geen responsinhoud |
| `400 Bad Request` | Ongeldige parameters of verkeerd gevormd verzoek |
| `401 Unauthorized` | Ontbrekende of ongeldige API-token |
| `403 Forbidden` | Token heeft geen toestemming voor deze actie |
| `404 Not Found` | Resource bestaat niet |
| `500 Internal Server Error` | Onverwachte serverfout |

Foutreacties bevatten een machinaal leesbare foutcode en een menselijk leesbaar bericht.

## Module-referentie

### RagArticle

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

**Samenvatting:** Samenvatting voor startpagina

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| proj | query | string (uuid) | Nee | Project‑ID. |

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

---

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

**Samenvatting:** Aantal artikelen

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| q | query | string | Nee | Filter op artikeltitel of -code. |
| state | query | array | Nee | Filter op statussen. |
| project | query | array | Nee | Filter op projecten. |
| type | query | array | Nee | Filter op documenttypes. |

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

---

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

**Samenvatting:** Lijst van artikelen ophalen

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| q | query | string | Nee | Filter op artikeltitel of -code. |
| state | query | array | Nee | Filter op statussen. |
| project | query | array | Nee | Filter op projecten. |
| type | query | array | Nee | Filter op documenttypes. |
| s | query | string | Nee | Sorteerveld. |
| asc | query | boolean | Nee | Oplopende sortering. |
| ps | query | integer (int32) | Nee | Pagina‑grootte. |
| p | query | integer (int32) | Nee | Pagina‑nummer (beginnend bij 1). |

**Respons (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

**Samenvatting:** Retourneert Markdown‑inhoud van het bestand

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

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

---

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

**Samenvatting:** Een artikel aanmaken

**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"
}
```

**Respons (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

**Samenvatting:** Controleer of een artikel bestaat.

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| code | query | string | Ja | Code van het artikel. |

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

---

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

**Samenvatting:** Haal artikel‑informatie op via code.

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| code | query | string | Ja | Code van het artikel. |

**Respons (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

**Samenvatting:** Haal artikel‑inhoud op via code

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| code | query | string | Ja | Code van het artikel. |
| format | query | string | Nee | Indien `true`, retourneert HTML‑inhoud; anders Markdown. |
| split | query | boolean | Nee | Indien `true`, retourneert de inhoud gesplitst per RAG‑element. |
| css | query | boolean | Nee | Indien `true`, retourneert HTML/PDF‑inhoud met CSS. |

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

#### POST /questionnaire/rag/article

**Samenvatting:** Metagegevens van artikel bijwerken

**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"
}
```

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

#### DELETE /questionnaire/rag/article

**Samenvatting:** Artikel verwijderen

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| code | query | string | Ja | Code van het artikel. |

---

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

**Samenvatting:** Artikel als PDF ophalen via code

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| code | query | string | Ja | Code van het artikel. |

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

---

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

**Samenvatting:** Artikelinhoud ophalen

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| code | query | string | Ja | Code van het artikel. |

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

---

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

**Samenvatting:** Artikelinhoud bijwerken

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

---

#### POST /questionnaire/rag/plural

**Samenvatting:** Meervoudsvorm van een zelfstandig naamwoord ophalen

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| noun | query | string | Nee | Zelfstandig naamwoord om te meervoudigen. |

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

---

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

**Samenvatting:** Analyseer artikel met AI en retourneer hun types

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

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

---

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

**Samenvatting:** Artikelinhoud formatteren met AI

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

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

---

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

**Samenvatting:** Document verbeteren op basis van suggesties

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

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

---

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

**Samenvatting:** Lijst van artikelonderdelen retourneren

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| id | query | array | Ja | Lijst van artikelonderdelen. |

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

---

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

**Samenvatting:** Lijst van artikelrevisies retourneren

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| code | query | string | Ja | Code van het artikel. |

**Respons (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}

**Samenvatting:** Revisie‑informatie van artikel ophalen

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| id | path | string (uuid) | Ja | Revisie‑ID. |

**Respons (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}

**Samenvatting:** Revisie‑inhoud van artikel ophalen

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| id | path | string (uuid) | Ja | Revisie‑ID. |

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

---

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

**Samenvatting:** Artikelinhoud analyseren met AI

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| code | query | string | Ja | Code van het artikel. |
| rev | query | integer (int32) | Nee | Revisienummer. |
| force | query | boolean | Nee | Forceer het aanmaken van een nieuwe analyse en verwijder eventueel onvoltooide resultaten. |

**Respons (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}

**Samenvatting:** Analyse‑resultaat van artikel ophalen

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| id | path | string (uuid) | Ja | Analyse‑ID. |

**Respons (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

**Samenvatting:** Alle berichten opsommen

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| id | query | string (uuid) | Ja | RAG‑collectie‑ID. |
| item | query | string (uuid) | Nee | RAG‑item‑ID. |
| message | query | string (uuid) | Nee | Bericht‑ID. |
| asc | query | boolean | Nee | Oplopende sortering. |
| ps | query | integer (int32) | Nee | Pagina‑grootte. |
| p | query | integer (int32) | Nee | Pagina‑nummer (beginnend bij 1). |

**Respons (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

**Samenvatting:** Nieuw bericht toevoegen

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| id | query | string (uuid) | Ja | RAG‑collectie‑ID. |
| item | query | string (uuid) | Nee | RAG‑item‑ID. |
| message | query | string (uuid) | Nee | Bericht‑ID om op te antwoorden. |

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

**Respons (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

**Samenvatting:** Bestaand bericht bijwerken

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| c | query | string (uuid) | Ja | RAG‑collectie‑ID. |
| id | query | string (uuid) | Ja | Bericht‑ID. |

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

**Respons (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

**Samenvatting:** Bestaand bericht verwijderen

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| id | query | string (uuid) | Ja | Bericht‑ID. |

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

---

### RagFaq

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

**Samenvatting:** Samenvatting voor startpagina

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| proj | query | string (uuid) | Nee | Project‑ID. |

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

---

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

**Samenvatting:** Aantal FAQ‑collecties.

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| q | query | string | Nee | Filter op collectienaam of -code. |
| state | query | array | Nee | Filter op statussen. |
| project | query | array | Nee | Filter op projecten. |

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

---

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

**Samenvatting:** Lijst van FAQ‑collecties ophalen.

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| q | query | string | Nee | Filter op collectienaam of -code. |
| state | query | array | Nee | Filter op statussen. |
| project | query | array | Nee | Filter op projecten. |
| s | query | string | Nee | Sorteerveld. |
| asc | query | boolean | Nee | Oplopende sortering. |
| ps | query | integer (int32) | Nee | Pagina‑grootte. |
| p | query | integer (int32) | Nee | Pagina‑nummer (beginnend bij 1). |

**Respons (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

**Samenvatting:** FAQ‑items zoeken.

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| q | query | string | Ja | Filter op vraag. |
| project | query | string (uuid) | Nee | Filter op project. |
| ps | query | integer (int32) | Nee | Pagina‑grootte. |
| p | query | integer (int32) | Nee | Pagina‑nummer (beginnend bij 1). |

**Respons (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

**Samenvatting:** Nieuwe FAQ‑collectie aanmaken.

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

**Respons (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

**Samenvatting:** Metagegevens van FAQ‑collectie bijwerken.

**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

**Samenvatting:** FAQ‑collectie verwijderen.

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| code | query | string | Ja | Code van de collectie. |

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

**Samenvatting:** FAQ‑collectie ophalen.

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| code | query | string | Ja | Code van de collectie. |

**Respons (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

**Samenvatting:** Controleer of FAQ‑collectie bestaat.

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| code | query | string | Ja | Code van de collectie. |

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

---

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

**Samenvatting:** Aantal FAQ‑items.

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| code | query | string | Ja | Code van de collectie. |
| q | query | string | Nee | Filter op FAQ‑item‑inhoud. |

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

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

---

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

**Samenvatting:** Lijst van FAQ‑items ophalen.

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| code | query | string | Ja | Code van de collectie. |
| q | query | string | Nee | Filter op FAQ‑item‑inhoud. |
| state | query | array | Nee | Filter op statussen. |
| s | query | string | Nee | Sorteerveld. |
| asc | query | boolean | Nee | Oplopende sortering. |
| ps | query | integer (int32) | Nee | Pagina‑grootte. |
| p | query | integer (int32) | Nee | Pagina‑nummer (beginnend bij 1). |

**Respons (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

**Samenvatting:** Nieuw FAQ‑item aanmaken.

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

**Respons (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

**Samenvatting:** FAQ‑item ophalen.

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| code | query | string | Ja | Code van de collectie. |
| index | query | integer (int32) | Ja | Nul‑gebaseerde index van het FAQ‑item in de collectie. |

**Respons (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

**Samenvatting:** FAQ‑item bijwerken.

**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

**Samenvatting:** FAQ‑item verwijderen.

**Parameters:**
| Naam | In | Type | Verplicht | Beschrijving |
|------|----|------|-----------|--------------|
| code | query | string | Ja | Code van de collectie. |
| index | query | integer (int32) | Ja | Nul‑gebaseerde index van het FAQ‑item in de collectie. |

---

### RagQuery

#### POST /questionnaire/rag/query

**Samenvatting:** Query uitvoeren in RAG‑kennisbank

**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
}
```

**Respons (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

**Samenvatting:** Query uitvoeren in RAG‑kennisbank (streaming)

**Request Body:** *(identiek aan bovenstaande)*

```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
}
```

**Respons (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

**Samenvatting:** Query uitvoeren in RAG‑kennisbank (fragmenten)

**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
}
```

**Respons (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
    }
  ]
}
```

## Gerelateerde artikelen

- [API Tokens – Generatie & Beheer](/api-tokens/) – hoe tokens te maken en beheren  
- [Vraag AI met je kennisbank](/ask-ai-with-your-knowledge-base/) – RAG‑queries gebruiken