Dokumentation/API-Referenz/Authentifizierung

API Authentifizierung

Erfahren Sie, wie Sie sich mit JWT-Tokens bei der BotLaunch API authentifizieren. Sichern Sie Ihre Anfragen und verwalten Sie den Zugriff auf Ihre Ressourcen.

Personal API keys for AI (bl_live_)

To let an AI assistant (Claude, ChatGPT, Cursor) manage your bot and Mini App shop, create a personal API key in the dashboard (Settings → API & AI) and send it as Authorization: Bearer bl_live_…. Keys are scoped and rate-limited per plan, and can never reach billing or admin. The AI should call GET /context first to read your plan and permissions.

Prefer a native integration? Point any MCP-capable client (Cursor, Claude Code, or a custom MCP integration) at the live MCP server https://api.botlaunch.io/api/v1/mcp with the same key, and BotLaunch appears as a native tool set of 12 tools.

Prompts, templates and SDKs: github.com/BotLaunch/botlaunch-ai-companion

JWT-Tokens

Sichere zustandslose Authentifizierung mit JSON Web Tokens.

Token-Ablauf

Access-Tokens laufen nach 1 Stunde ab, Refresh-Tokens nach 7 Tagen.

Automatische Erneuerung

Verwenden Sie Refresh-Tokens, um nahtlos neue Access-Tokens zu erhalten.

Authentifizierungsablauf

Befolgen Sie diese Schritte, um sich zu authentifizieren und sichere API-Anfragen zu stellen.

1

Anmelden

Tokens mit Anmeldedaten erhalten

2

Tokens speichern

Beide Tokens sicher speichern

3

Anfragen stellen

Token in Header einfügen

4

Erneuern

Neuen Token bei Ablauf erhalten

Authentifizierungs-Endpunkte

POST/api/auth/login

Einen Benutzer authentifizieren und Access- sowie Refresh-Tokens erhalten.

Request body

FieldTypeRequiredDescription
emailstringUser's email address
passwordstringUser's password

Example request

curl -X POST "https://api.botlaunch.io/api/auth/login" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "user@example.com",
    "password": "your-secure-password"
  }'
bash

Example response

{
  "data": {
    "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "expiresIn": 3600,
    "user": {
      "id": "usr_abc123",
      "email": "user@example.com",
      "role": "CLIENT_OWNER"
    }
  },
  "message": "Login successful"
}
json
POST/api/auth/register

Ein neues Benutzerkonto und eine Organisation erstellen.

Request body

FieldTypeRequiredDescription
emailstringValid email address
passwordstringMin 8 chars, 1 uppercase, 1 number
namestringUser's full name
organizationNamestringOptionalOrganization name

Example request

curl -X POST "https://api.botlaunch.io/api/auth/register" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "newuser@example.com",
    "password": "SecureP@ssw0rd!",
    "name": "John Doe",
    "organizationName": "My Company"
  }'
bash
POST/api/auth/refresh

Einen Refresh-Token gegen einen neuen Access-Token eintauschen.

Example request

curl -X POST "https://api.botlaunch.io/api/auth/refresh" \
  -H "Content-Type: application/json" \
  -d '{
    "refreshToken": "your-refresh-token"
  }'
bash

Token-Rotation

Jede Erneuerungsanfrage gibt einen neuen Refresh-Token zurück. Speichern und verwenden Sie den neuesten Refresh-Token für nachfolgende Anfragen.

POST/api/auth/logout

Die aktuelle Sitzung ungültig machen und Tokens widerrufen.

Example request

curl -X POST "https://api.botlaunch.io/api/auth/logout" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json"
bash

Access-Tokens verwenden

Fügen Sie Ihren Access-Token im Authorization-Header für alle API-Anfragen ein.

// Include the access token in all API requests
const response = await fetch("https://api.botlaunch.io/api/bots", {
  headers: {
    "Authorization": "Bearer eyJhbGciOiJIUzI1NiIs...",
    "x-organization-id": "org_xyz789",
    "Content-Type": "application/json"
  }
});
javascript

Erforderliche Header

AuthorizationBearer token
x-organization-idOrganization ID
Content-Typeapplication/json

Sicherheits-Best-Practices

  • Tokens sicher speichern (niemals in localStorage für Web)
  • HTTPS für alle API-Anfragen verwenden
  • Token-Erneuerung vor Ablauf implementieren
  • Tokens bei Abmeldung oder Sicherheitsereignissen widerrufen

Authentifizierungsfehler

Häufige Authentifizierungsfehler und deren Behandlung.

StatusErrorDescriptionSolution
401UnauthorizedMissing or invalid tokenCheck Authorization header
401Token ExpiredAccess token has expiredUse refresh token to get new access token
403ForbiddenInsufficient permissionsCheck user role and organization access
429Too Many RequestsLogin rate limit exceededWait and retry after cooldown
400Invalid CredentialsWrong email or passwordVerify credentials and try again