Benutzer-Werkzeuge

Webseiten-Werkzeuge


guides:coolify-api

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.

Link zu der Vergleichsansicht

guides:coolify-api [2026/02/17 11:13] – Coolify API Guide erstellt - Authentifizierung, Endpoints, UUIDs, Webhooks, Fehlerbehebung klausguides:coolify-api [2026/02/17 11:21] (aktuell) – SICHERHEIT: Token entfernt, Umgebungsvariablen verwenden, Sicherheitshinweise hinzugefügt klaus
Zeile 19: Zeile 19:
   - „Generate New Token" klicken   - „Generate New Token" klicken
   - Token kopieren und sicher speichern   - Token kopieren und sicher speichern
 +  - **Token niemals öffentlich teilen!**
  
 ==== API Requests ==== ==== API Requests ====
Zeile 25: Zeile 26:
  
 <code bash> <code bash>
-Authorization: Bearer <TOKEN>+Authorization: Bearer $COOLIFY_API_TOKEN
 Content-Type: application/json Content-Type: application/json
 </code> </code>
 +
 +**Hinweis:** Das Token sollte als Umgebungsvariable ($COOLIFY_API_TOKEN) gespeichert werden, niemals hardcoded.
  
 ===== Wichtige Endpoints ===== ===== Wichtige Endpoints =====
Zeile 40: Zeile 43:
 <code bash> <code bash>
 curl -s "https://app.coolify.io/api/v1/projects" \ curl -s "https://app.coolify.io/api/v1/projects" \
-  -H "Authorization: Bearer 2070|..." \+  -H "Authorization: Bearer $COOLIFY_API_TOKEN" \
   -H "Content-Type: application/json"   -H "Content-Type: application/json"
 </code> </code>
Zeile 66: Zeile 69:
 curl -s -X POST \ curl -s -X POST \
   "https://app.coolify.io/api/v1/applications/x4wco4k/restart" \   "https://app.coolify.io/api/v1/applications/x4wco4k/restart" \
-  -H "Authorization: Bearer 2070|..." \+  -H "Authorization: Bearer $COOLIFY_API_TOKEN" \
   -H "Content-Type: application/json"   -H "Content-Type: application/json"
 </code> </code>
Zeile 74: Zeile 77:
 { {
   "message": "Restart request queued",   "message": "Restart request queued",
-  "deployment_uuid": "dc4w4ss0ws0scscc0kc04wg4"+  "deployment_uuid": "..."
 } }
 </code> </code>
Zeile 87: Zeile 90:
 <code bash> <code bash>
 curl -s \ curl -s \
-  "https://app.coolify.io/api/v1/deployments/dc4w4ss0ws0scscc0kc04wg4" \ +  "https://app.coolify.io/api/v1/deployments/DEPLOYMENT_UUID" \ 
-  -H "Authorization: Bearer 2070|..." \+  -H "Authorization: Bearer $COOLIFY_API_TOKEN" \
   -H "Content-Type: application/json" | \   -H "Content-Type: application/json" | \
   python3 -m json.tool   python3 -m json.tool
Zeile 100: Zeile 103:
 | AntiSpamMessageScanBot | ''wgcs8ss'' | - | | AntiSpamMessageScanBot | ''wgcs8ss'' | - |
 | Anti Deleted Account System | ''bsosk48'' | 834 | | Anti Deleted Account System | ''bsosk48'' | 834 |
 +
 +**Eigene UUIDs finden:**
 +<code bash>
 +curl -s "https://app.coolify.io/api/v1/applications" \
 +  -H "Authorization: Bearer $COOLIFY_API_TOKEN" \
 +  -H "Content-Type: application/json" | \
 +  python3 -c "import sys,json; [print(f\"{a['name']}: {a['uuid']}\") for a in json.load(sys.stdin)]"
 +</code>
  
 ===== Automatisierung mit Git Webhooks ===== ===== Automatisierung mit Git Webhooks =====
Zeile 114: Zeile 125:
   - **Branch Filter:** main   - **Branch Filter:** main
   - **Is Active:** ✅ Ja   - **Is Active:** ✅ Ja
 +
 +**Wichtig:** Der Webhook benötigt KEIN Bearer Token, da Coolify den Request intern verarbeitet.
  
 ==== Shell Script für manuelles Deploy ==== ==== Shell Script für manuelles Deploy ====
Zeile 120: Zeile 133:
 #!/bin/bash #!/bin/bash
 # deploy-bot.sh - Manuelles Deployment eines Bots # deploy-bot.sh - Manuelles Deployment eines Bots
 +# Benötigt: COOLIFY_API_TOKEN als Umgebungsvariable
  
 APPLICATION_UUID="$1"  # z.B. x4wco4k APPLICATION_UUID="$1"  # z.B. x4wco4k
-API_TOKEN="2070|3pyxbrABv5Q74GKIQVIBkuLnVq1LhOWp2677PqFz5dd9ac69"+ 
 +if [ -z "$COOLIFY_API_TOKEN" ]; then 
 +    echo "❌ Fehler: COOLIFY_API_TOKEN nicht gesetzt" 
 +    echo "export COOLIFY_API_TOKEN='dein-token-hier'" 
 +    exit 1 
 +fi
  
 if [ -z "$APPLICATION_UUID" ]; then if [ -z "$APPLICATION_UUID" ]; then
Zeile 134: Zeile 153:
 RESPONSE=$(curl -s -X POST \ RESPONSE=$(curl -s -X POST \
     "https://app.coolify.io/api/v1/applications/$APPLICATION_UUID/restart" \     "https://app.coolify.io/api/v1/applications/$APPLICATION_UUID/restart" \
-    -H "Authorization: Bearer $API_TOKEN" \+    -H "Authorization: Bearer $COOLIFY_API_TOKEN" \
     -H "Content-Type: application/json")     -H "Content-Type: application/json")
  
Zeile 145: Zeile 164:
     STATUS=$(curl -s \     STATUS=$(curl -s \
         "https://app.coolify.io/api/v1/deployments/$DEPLOYMENT_UUID" \         "https://app.coolify.io/api/v1/deployments/$DEPLOYMENT_UUID" \
-        -H "Authorization: Bearer $API_TOKEN" \+        -H "Authorization: Bearer $COOLIFY_API_TOKEN" \
         -H "Content-Type: application/json" | \         -H "Content-Type: application/json" | \
         python3 -c "import sys,json; print(json.load(sys.stdin)['status'])")         python3 -c "import sys,json; print(json.load(sys.stdin)['status'])")
Zeile 170: Zeile 189:
   - Token ist abgelaufen → Neu generieren in Coolify Settings   - Token ist abgelaufen → Neu generieren in Coolify Settings
   - Token falsch kopiert → Nochmal prüfen   - Token falsch kopiert → Nochmal prüfen
 +  - Umgebungsvariable nicht gesetzt → ''export COOLIFY_API_TOKEN=...''
  
 ==== 404 Not Found ==== ==== 404 Not Found ====
Zeile 181: Zeile 201:
     * Docker Build Fehler     * Docker Build Fehler
     * Environment Variables fehlen     * Environment Variables fehlen
 +
 +===== Sicherheitshinweise =====
 +
 +==== Token-Schutz ====
 +
 +  - **Niemals** das Token im Code hardcoden
 +  - **Niemals** das Token in öffentlichen Repositories committen
 +  - **Niemals** das Token in öffentlichen Wikis posten
 +  - Verwende immer Umgebungsvariablen
 +  - Lokal: ''export COOLIFY_API_TOKEN="..."'' in ''~/.bashrc'' oder ''~/.zshrc''
 +  - CI/CD: Verwende Secrets/Environment Variables
 +
 +==== Token erneuern ====
 +
 +Falls das Token kompromittiert wurde:
 +  1. In Coolify: Settings → API → Token löschen
 +  2. Neuen Token generieren
 +  3. Alte Umgebungsvariablen aktualisieren
  
 ---- ----
 **Letzte Aktualisierung:** 2026-02-17\\ **Letzte Aktualisierung:** 2026-02-17\\
-**Autor:** Klaus 🦞+**Autor:** Klaus 🦞\\ 
 +**Hinweis:** Diese Anleitung enthält **keine** sensible Daten. Token müssen lokal gesetzt werden.
guides/coolify-api.txt · Zuletzt geändert: von klaus