
# Procurize.AI REST-API-Referenz

**Greifen Sie programmgesteuert auf Ihre Wissensdatenbank – Dokumente, Fragebögen, RAG und Berichte – mit Ihrem API‑Token zu.**

> **Gilt für:** Procurize.AI API v1  
> **Authentifizierung:** API‑Schlüssel über den Header `X-API-Key` (siehe [API‑Tokens](/api-tokens/) für die Token‑Verwaltung)  
> **Basis‑URL:** `https://api.procurize.com`

## Überblick

Die Procurize.AI REST‑API bietet programmgesteuerten Zugriff auf zentrale Plattform‑Funktionen. Sie ermöglicht die Integration von Procurize.AI in Ihre internen Systeme, die Automatisierung der Wissensdatenbank‑Verwaltung und den Aufbau individueller Workflows.

**Unterstützte Module (token‑authentifiziert):**

- [**RagArticle**](#ragarticle) – Dokumente verwalten
- [**RagFaq**](#ragfaq) – FAQ‑Einträge verwalten
- [**RagQuery**](#ragquery) – RAG‑Abfragen ausführen

## Authentifizierung

Alle authentifizierten Endpunkte benötigen ein API‑Token, das im Request‑Header übergeben wird.

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

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

> 💡 Tokens sind an Ihre Organisation gebunden – Sie müssen keine Organisations‑ID im Request angeben.

## Basis‑URL

Alle REST‑API‑Endpunkte werden unter folgender URL bereitgestellt:
```
https://api.procurize.com
```

## Fehlerbehandlung

Die API verwendet die üblichen HTTP‑Statuscodes.

| Code | Bedeutung |
|------|-----------|
| `200 OK` | Anfrage erfolgreich |
| `201 Created` | Ressource erfolgreich erstellt |
| `204 No Content` | Anfrage erfolgreich, kein Antwort‑Body |
| `400 Bad Request` | Ungültige Parameter oder fehlerhafte Anfrage |
| `401 Unauthorized` | Fehlendes oder ungültiges API‑Token |
| `403 Forbidden` | Token hat keine Berechtigung für diese Aktion |
| `404 Not Found` | Ressource existiert nicht |
| `500 Internal Server Error` | Unerwarteter Server‑Fehler |

Fehlerantworten enthalten einen maschinenlesbaren Fehlercode und eine menschenlesbare Meldung.

## Modul‑Referenz

### RagArticle

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

**Zusammenfassung:** Zusammenfassung für die Startseite

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| proj | query | string (uuid) | Nein | Projekt‑ID. |

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

---

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

**Zusammenfassung:** Anzahl der Artikel

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| q | query | string | Nein | Filter nach Artikelnamen oder -code. |
| state | query | array | Nein | Filter nach Zuständen. |
| project | query | array | Nein | Filter nach Projekten. |
| type | query | array | Nein | Filter nach Dokument‑Typen. |

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

---

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

**Zusammenfassung:** Liste der Artikel abrufen

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| q | query | string | Nein | Filter nach Artikelnamen oder -code. |
| state | query | array | Nein | Filter nach Zuständen. |
| project | query | array | Nein | Filter nach Projekten. |
| type | query | array | Nein | Filter nach Dokument‑Typen. |
| s | query | string | Nein | Sortierfeld. |
| asc | query | boolean | Nein | Aufsteigende Sortierung. |
| ps | query | integer (int32) | Nein | Seitengröße. |
| p | query | integer (int32) | Nein | 1‑basierte Seitennummer. |

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

**Zusammenfassung:** Gibt Markdown‑Inhalt aus der Datei zurück

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

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

---

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

**Zusammenfassung:** Artikel erstellen

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

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

**Zusammenfassung:** Existenz des Artikels prüfen.

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| code | query | string | Ja | Code des Artikels. |

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

---

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

**Zusammenfassung:** Artikelinformationen nach Code abrufen.

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| code | query | string | Ja | Code des Artikels. |

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

**Zusammenfassung:** Artikelinhalt nach Code abrufen

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| code | query | string | Ja | Code des Artikels. |
| format | query | string | Nein | Wenn `true`, wird HTML‑Inhalt im Antwort‑Body zurückgegeben. Andernfalls wird der Artikelinhalt im Markdown‑Format zurückgegeben. |
| split | query | boolean | Nein | Wenn `true`, wird der Inhalt nach RAG‑Elementen getrennt zurückgegeben. |
| css | query | boolean | Nein | Wenn `true`, wird der HTML/PDF‑Inhalt mit CSS zurückgegeben. |

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

#### POST /questionnaire/rag/article

**Zusammenfassung:** Metadaten des Artikels aktualisieren

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

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

#### DELETE /questionnaire/rag/article

**Zusammenfassung:** Artikel löschen

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| code | query | string | Ja | Code des Artikels. |

---

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

**Zusammenfassung:** Artikel als PDF nach Code abrufen

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| code | query | string | Ja | Code des Artikels. |

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

---

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

**Zusammenfassung:** Artikelinhalt abrufen

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| code | query | string | Ja | Code des Artikels. |

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

---

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

**Zusammenfassung:** Artikelinhalt aktualisieren

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

---

#### POST /questionnaire/rag/plural

**Zusammenfassung:** Pluralform des Substantivs erhalten

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| noun | query | string | Nein | Substantiv, das pluralisiert werden soll. |

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

---

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

**Zusammenfassung:** Artikel mit KI analysieren und deren Typen zurückgeben

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

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

---

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

**Zusammenfassung:** Artikelinhalt mit KI formatieren

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

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

---

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

**Zusammenfassung:** Dokument basierend auf Vorschlägen verbessern

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

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

---

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

**Zusammenfassung:** Liste der Artikelteile zurückgeben

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| id | query | array | Ja | Liste der Artikelteile. |

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

---

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

**Zusammenfassung:** Liste der Artikelrevisionen zurückgeben

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| code | query | string | Ja | Code des Artikels. |

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

**Zusammenfassung:** Artikelrevisionsinformationen abrufen

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| id | path | string (uuid) | Ja | Revisions‑ID. |

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

**Zusammenfassung:** Artikelrevisionsinhalt abrufen

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| id | path | string (uuid) | Ja | Revisions‑ID. |

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

---

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

**Zusammenfassung:** Artikelinhalt mit KI analysieren

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| code | query | string | Ja | Code des Artikels. |
| rev | query | integer (int32) | Nein | Revisions‑Nummer. |
| force | query | boolean | Nein | Erzwungenes Erstellen einer neuen Analyse und Löschen eines vorherigen unvollständigen Analyse‑Ergebnisses, falls vorhanden. |

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

**Zusammenfassung:** Artikelanalyseergebnis abrufen

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| id | path | string (uuid) | Ja | Analyse‑ID. |

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

**Zusammenfassung:** Alle Nachrichten auflisten

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| id | query | string (uuid) | Ja | RAG‑Collection‑ID. |
| item | query | string (uuid) | Nein | RAG‑Item‑ID. |
| message | query | string (uuid) | Nein | Nachrichten‑ID. |
| asc | query | boolean | Nein | Aufsteigende Sortierung. |
| ps | query | integer (int32) | Nein | Seitengröße. |
| p | query | integer (int32) | Nein | 1‑basierte Seitennummer. |

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

**Zusammenfassung:** Neue Nachricht hinzufügen

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| id | query | string (uuid) | Ja | RAG‑Collection‑ID. |
| item | query | string (uuid) | Nein | RAG‑Item‑ID. |
| message | query | string (uuid) | Nein | Nachrichten‑ID zum Antworten. |

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

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

**Zusammenfassung:** Bestehende Nachricht aktualisieren

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| c | query | string (uuid) | Ja | RAG‑Collection‑ID. |
| id | query | string (uuid) | Ja | Nachrichten‑ID. |

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

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

**Zusammenfassung:** Bestehende Nachricht löschen

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| id | query | string (uuid) | Ja | Nachrichten‑ID. |

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

### RagFaq

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

**Zusammenfassung:** Zusammenfassung für die Startseite

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| proj | query | string (uuid) | Nein | Projekt‑ID. |

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

---

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

**Zusammenfassung:** Anzahl der FAQ‑Sammlungen.

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| q | query | string | Nein | Filter nach Sammlungs‑Name oder -Code. |
| state | query | array | Nein | Filter nach Zuständen. |
| project | query | array | Nein | Filter nach Projekten. |

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

---

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

**Zusammenfassung:** Liste der FAQ‑Sammlungen abrufen.

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| q | query | string | Nein | Filter nach Sammlungs‑Name oder -Code. |
| state | query | array | Nein | Filter nach Zuständen. |
| project | query | array | Nein | Filter nach Projekten. |
| s | query | string | Nein | Sortierfeld. |
| asc | query | boolean | Nein | Aufsteigende Sortierung. |
| ps | query | integer (int32) | Nein | Seitengröße. |
| p | query | integer (int32) | Nein | 1‑basierte Seitennummer. |

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

**Zusammenfassung:** FAQ‑Elemente finden.

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| q | query | string | Ja | Filter nach Frage. |
| project | query | string (uuid) | Nein | Filter nach Projekt. |
| ps | query | integer (int32) | Nein | Seitengröße. |
| p | query | integer (int32) | Nein | 1‑basierte Seitennummer. |

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

**Zusammenfassung:** Neue FAQ‑Sammlung erstellen.

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

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

**Zusammenfassung:** Metadaten der FAQ‑Sammlung aktualisieren.

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

**Zusammenfassung:** FAQ‑Sammlung löschen.

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| code | query | string | Ja | Code der Sammlung. |

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

**Zusammenfassung:** FAQ‑Sammlung abrufen.

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| code | query | string | Ja | Code der Sammlung. |

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

**Zusammenfassung:** Existenz der FAQ‑Sammlung prüfen.

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| code | query | string | Ja | Code der Sammlung. |

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

---

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

**Zusammenfassung:** Anzahl der FAQ‑Elemente.

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| code | query | string | Ja | Code der Sammlung. |
| q | query | string | Nein | Filter nach FAQ‑Element‑Inhalt. |

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

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

---

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

**Zusammenfassung:** Liste der FAQ‑Elemente abrufen.

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| code | query | string | Ja | Code der Sammlung. |
| q | query | string | Nein | Filter nach FAQ‑Element‑Inhalt. |
| state | query | array | Nein | Filter nach Zuständen. |
| s | query | string | Nein | Sortierfeld. |
| asc | query | boolean | Nein | Aufsteigende Sortierung. |
| ps | query | integer (int32) | Nein | Seitengröße. |
| p | query | integer (int32) | Nein | 1‑basierte Seitennummer. |

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

**Zusammenfassung:** Neues FAQ‑Element erstellen.

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

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

**Zusammenfassung:** FAQ‑Element abrufen.

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| code | query | string | Ja | Code der Sammlung. |
| index | query | integer (int32) | Ja | Null‑basierter Index des FAQ‑Elements in der Sammlung. |

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

**Zusammenfassung:** FAQ‑Element aktualisieren.

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

**Zusammenfassung:** FAQ‑Element löschen.

**Parameter:**
| Name | Ort | Typ | Erforderlich | Beschreibung |
|------|-----|-----|--------------|--------------|
| code | query | string | Ja | Code der Sammlung. |
| index | query | integer (int32) | Ja | Null‑basierter Index des FAQ‑Elements in der Sammlung. |

### RagQuery

#### POST /questionnaire/rag/query

**Zusammenfassung:** Abfrage im RAG‑Wissensbasis durchführen

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

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

**Zusammenfassung:** Abfrage im RAG‑Wissensbasis durchführen (Streaming)

**Request Body:** *(identisch zum vorherigen Beispiel)*

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

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

**Zusammenfassung:** Abfrage im RAG‑Wissensbasis durchführen (Fragment‑Suche)

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

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

## Verwandte Artikel

- [API‑Tokens – Erzeugung & Verwaltung](/api-tokens/) – wie man Tokens erstellt und verwaltet  
- [KI mit Ihrer Wissensbasis befragen](/ask-ai-with-your-knowledge-base/) – Nutzung von RAG‑Abfragen