API प्रमाणीकरण

JWT टोकन का उपयोग करके BotLaunch API के साथ प्रमाणित करना सीखें। अपने अनुरोधों को सुरक्षित करें और अपने संसाधनों तक पहुंच प्रबंधित करें।

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 टोकन

JSON Web Tokens का उपयोग करके सुरक्षित स्टेटलेस प्रमाणीकरण।

टोकन समाप्ति

Access टोकन 1 घंटे में समाप्त होते हैं, refresh टोकन 7 दिनों में।

ऑटो रिफ्रेश

नए access टोकन सहजता से प्राप्त करने के लिए refresh टोकन का उपयोग करें।

प्रमाणीकरण प्रवाह

प्रमाणित करने और सुरक्षित API अनुरोध करने के लिए इन चरणों का पालन करें।

1

लॉगिन

क्रेडेंशियल्स के साथ टोकन प्राप्त करें

2

टोकन स्टोर करें

दोनों टोकन सुरक्षित रूप से स्टोर करें

3

अनुरोध करें

Headers में टोकन शामिल करें

4

रिफ्रेश

समाप्त होने पर नया टोकन प्राप्त करें

प्रमाणीकरण Endpoints

POST/api/auth/login

उपयोगकर्ता को प्रमाणित करें और access और refresh टोकन प्राप्त करें।

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

नया उपयोगकर्ता खाता और संगठन बनाएं।

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

नया access टोकन प्राप्त करने के लिए refresh टोकन का आदान-प्रदान करें।

Example request

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

टोकन रोटेशन

प्रत्येक refresh अनुरोध एक नया refresh टोकन लौटाता है। बाद के अनुरोधों के लिए नवीनतम refresh टोकन स्टोर करें और उपयोग करें।

POST/api/auth/logout

वर्तमान सत्र को अमान्य करें और टोकन रद्द करें।

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 टोकन का उपयोग

सभी API अनुरोधों के लिए Authorization header में अपना access टोकन शामिल करें।

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

आवश्यक Headers

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

सुरक्षा सर्वोत्तम प्रथाएं

  • टोकन सुरक्षित रूप से स्टोर करें (वेब के लिए कभी localStorage में नहीं)
  • सभी API अनुरोधों के लिए HTTPS का उपयोग करें
  • समाप्ति से पहले टोकन refresh लागू करें
  • लॉगआउट या सुरक्षा घटनाओं पर टोकन रद्द करें

प्रमाणीकरण त्रुटियां

सामान्य प्रमाणीकरण त्रुटियां और उन्हें कैसे संभालें।

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