# REST API Übersicht (aus Client-Calls im Projekt abgeleitet) - **Base URL**: `VITE_WEBHOOK_URL` (siehe `src/lib/config.ts -> getWebhookUrl()`) - **Auth**: - Cookies werden standardmäßig mitgesendet (`credentials: 'include'`) - Falls vorhanden wird `Authorization: Bearer ` gesetzt (siehe `apiFetch`) - Bei `401` wird automatisch Refresh versucht über `/auth/rnjwt` ## Auth - **POST /auth_login** - Headers: `Content-Type: application/json` - Body: ```json { "email": "string", "password": "string" } ``` - Response: ```json { "token": "string", "user": { ... } } ``` - **GET /auth/rnjwt** - Zweck: JWT Refresh - Response: ```json { "token": "string" } ``` ## Events - **POST /event/new_manual** - Headers: `Content-Type: application/json` - Body: ```json { "name": "string", "description": "string?", "location": "string?", "url": "string?", "image": "string?", "manager_name": "string?", "manager_email": "string?", "begin_date": "YYYY-MM-DD?", "end_date": "YYYY-MM-DD?" } ``` - Response: beliebiges Event-Objekt - **GET /events/get_current** - Response: `Event[]` oder ein einzelnes Event-Objekt - **GET /events** - Response: `Event[]` oder ein einzelnes Event-Objekt - **POST /event/new_fromurl** - Headers: `Content-Type: application/json` - Body: ```json { "url": "string", "command": "eventmodus_extract_from_url" } ``` - Response: `data.message_from_ai` oder Roh-Response ## Blog - **GET /blog/new_blog** - Response: ```json { "id": "string" } // oder { "blog_id": "string" } ``` - **POST /blog/publish** - Headers: `Content-Type: application/json` - Body: ```json { "blog_id": "string", "publish_date": "YYYY-MM-DD", "publish_socialmedia": true, "socialmedia_channels": ["string"], "socialmedia_languages": ["string"] } ``` - Response: beliebige Publikations-Infos - **POST /blog/update** - Headers: `Content-Type: application/json` - Body: ```json { "blog_id": "string", "content": { ... } } ``` - Response: Update-Ergebnis - **POST /blog/generate** - Headers: `Content-Type: application/json` - Body: ```json { "blog_Id": "string", "topic": "string", "tonality": "string", "languages": ["string"] } ``` - Response: generierter Blog-Content - **GET /blog/topic_suggestion** - Response: ```json { "topics": ["string", ...] } | ["string", ...] ``` ## Dateien & Medien - **POST /file_upload_blog** - Body (FormData): - `file`: File - `blog_id`: string - Response: ```json { "url": "string", ... } ``` - **POST /file_upload_event** - Body (FormData): - `file`: File - `event_id`: string - Response: ```json { "url": "string", ... } ``` - **POST /upload_tmp** - Body (FormData): - `file`: File - Response: ```json { "url": "string", ... } ``` - **POST /media/image_generator** - Headers: `Content-Type: application/json` - Body: ```json { "blog_id": "string", "title": "string" } ``` - Response: ```json { "url": "string" } // oder { "imageUrl": "string" } ``` - Hinweis: `generateAIImage` ruft aktuell - **POST /file_upload** - Headers: `Content-Type: application/json` - Body: ```json { "prompt": "string" } ``` - Response: ```json { "imageUrl": "string", ... } ``` - Anmerkung: Endpoint-Name wirkt untypisch für Image-Generation. ## Tools - **POST /tools/speech2text** - Body (FormData): - `file`: Audio-Datei - Response: ```json { "transcription": "string" } // oder "text", "result" ``` ## Social Media - **POST /socialmedia/post2event** - Headers: `Content-Type: application/json` - Body: frei, je nach Nutzungsfall (Payload für Generierung) - Response: generierte Posts - **POST /socialmedia/publish_post** - Headers: `Content-Type: application/json` - Body: ```json { "postId": "string", "posts": { ... }, "images": { ... }, "scheduledTime": "string" } ``` - Response: Veröffentlichungs-Ergebnis ## Gemeinsame Aspekte - **Headers** - `Content-Type: application/json` bei JSON-Requests - FormData-Uploads ohne explizites `Content-Type` (Browser setzt Multi‑Part) - **Auth** - Cookies via `credentials: 'include'` - Optionaler Bearer-Token via `Authorization` - Auto-Refresh bei 401 über `/auth/rnjwt`, danach Retry - **Statuscodes** - Client erwartet `response.ok === true` bei Erfolg, sonst Fehlerwurf - **Variabilität** - Einige Responses sind polymorph (Array oder Objekt). Umgang entsprechend im Client. # Beispiel: apiFetch Verhalten - Sendet automatisch Cookies - Fügt `Authorization: Bearer ` hinzu, wenn verfügbar - Bei 401: - versucht `GET /auth/rnjwt` - wiederholt Request mit neuem Token - bei erneutem 401: Logout und Fehlermeldung