Benutzer-Werkzeuge

Webseiten-Werkzeuge


guides:coolify-api

Dies ist eine alte Version des Dokuments!


Coolify API Guide - Automatisches Deployment

Diese Anleitung beschreibt die Nutzung der Coolify API für automatisierte Deployments der Telegram-Bots.

Übersicht

Coolify Instanz: https://app.coolify.io API Version: v1 Authentifizierung: Bearer Token

Authentifizierung

API Token

Das API Token wird in den Benutzereinstellungen von Coolify generiert:

  1. Einloggen auf https://app.coolify.io
  2. Settings → API
  3. „Generate New Token„ klicken
  4. Token kopieren und sicher speichern

API Requests

Alle API-Requests benötigen den Header:

Authorization: Bearer <TOKEN>
Content-Type: application/json

Wichtige Endpoints

1. Projekt-Übersicht

GET /api/v1/projects

Beispiel:

curl -s "https://app.coolify.io/api/v1/projects" \
  -H "Authorization: Bearer 2070|..." \
  -H "Content-Type: application/json"

Response:

[
  {
    "id": 1038,
    "uuid": "bso4sss",
    "name": "Anti Spam ohne Vornamenprüfung"
  }
]

2. Application Deploy

POST /api/v1/applications/{uuid}/restart

Beispiel - AntiSpam-ohneVorname:

# Application UUID: x4wco4k
curl -s -X POST \
  "https://app.coolify.io/api/v1/applications/x4wco4k/restart" \
  -H "Authorization: Bearer 2070|..." \
  -H "Content-Type: application/json"

Response:

{
  "message": "Restart request queued",
  "deployment_uuid": "dc4w4ss0ws0scscc0kc04wg4"
}

3. Deployment Status prüfen

GET /api/v1/deployments/{uuid}

Beispiel:

curl -s \
  "https://app.coolify.io/api/v1/deployments/dc4w4ss0ws0scscc0kc04wg4" \
  -H "Authorization: Bearer 2070|..." \
  -H "Content-Type: application/json" | \
  python3 -m json.tool

Wichtige Application UUIDs

Bot Application UUID Projekt ID
Anti Spam ohne Vornamenprüfung x4wco4k 1038
AntiSpamBot Recode V2.0 uokcw80 -
AntiSpamMessageScanBot wgcs8ss -
Anti Deleted Account System bsosk48 834

Automatisierung mit Git Webhooks

Gitea Webhook einrichten

URL: https://git.thepain.dev/ThePain/AntiSpam-ohneVorname/settings/hooks

Konfiguration:

  1. Target URL: https://app.coolify.io/api/v1/applications/x4wco4k/restart
  2. HTTP Method: POST
  3. Content Type: application/json
  4. Events: Push Events
  5. Branch Filter: main
  6. Is Active: ✅ Ja

Shell Script für manuelles Deploy

#!/bin/bash
# deploy-bot.sh - Manuelles Deployment eines Bots
 
APPLICATION_UUID="$1"  # z.B. x4wco4k
API_TOKEN="2070|3pyxbrABv5Q74GKIQVIBkuLnVq1LhOWp2677PqFz5dd9ac69"
 
if [ -z "$APPLICATION_UUID" ]; then
    echo "Usage: $0 <application-uuid>"
    echo "Beispiel: $0 x4wco4k"
    exit 1
fi
 
echo "Starting deployment for $APPLICATION_UUID..."
 
RESPONSE=$(curl -s -X POST \
    "https://app.coolify.io/api/v1/applications/$APPLICATION_UUID/restart" \
    -H "Authorization: Bearer $API_TOKEN" \
    -H "Content-Type: application/json")
 
DEPLOYMENT_UUID=$(echo $RESPONSE | python3 -c "import sys,json; print(json.load(sys.stdin)['deployment_uuid'])")
echo "Deployment queued: $DEPLOYMENT_UUID"
 
# Warte auf Abschluss (optional)
echo "Warte auf Deployment..."
for i in {1..30}; do
    STATUS=$(curl -s \
        "https://app.coolify.io/api/v1/deployments/$DEPLOYMENT_UUID" \
        -H "Authorization: Bearer $API_TOKEN" \
        -H "Content-Type: application/json" | \
        python3 -c "import sys,json; print(json.load(sys.stdin)['status'])")
 
    echo "Status: $STATUS"
 
    if [ "$STATUS" = "finished" ]; then
        echo "✅ Deployment erfolgreich!"
        exit 0
    elif [ "$STATUS" = "failed" ]; then
        echo "❌ Deployment fehlgeschlagen!"
        exit 1
    fi
 
    sleep 5
done
 
echo "⚠️ Timeout - prüfe manuell in Coolify Dashboard"

Fehlerbehebung

401 Unauthorized

  1. Token ist abgelaufen → Neu generieren in Coolify Settings
  2. Token falsch kopiert → Nochmal prüfen

404 Not Found

  1. Application UUID falsch → Mit /api/v1/applications prüfen
  2. Projekt existiert nicht mehr

Deployment Failed

  1. Logs in Coolify Dashboard prüfen
  2. Häufige Ursachen:
    • Git nicht erreichbar
    • Docker Build Fehler
    • Environment Variables fehlen

Letzte Aktualisierung: 2026-02-17
Autor: Klaus 🦞

guides/coolify-api.1771326786.txt.gz · Zuletzt geändert: von klaus