API reference

Ask your chatbot questions from your own applications, without the widget. Business and Enterprise plans.

Authentication

Create a key per chatbot under Settings, API. Send it as a Bearer token. Keep it secret: it can drive your bot and counts against your daily quota.

Authorization: Bearer awk_YOUR_KEY

POST /api/v1/chat

Body fields: bot_id (required), message (required), session_id (optional). Pass the session_id from a previous response to continue the same conversation with full history.

Response

{
  "response": "We are open Monday to Friday, 9 to 5.",
  "sources": [{ "title": "Opening hours", "url": "https://yoursite.com/hours" }],
  "session_id": "api-7f3c..."
}

Rate limit: 1000 requests per day per key. Over the limit returns HTTP 429. Invalid or revoked keys return 401.

Examples

cURL

curl https://chat.astroworldmc.com/api/v1/chat \
  -H "Authorization: Bearer awk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"bot_id":"YOUR_BOT_ID","message":"What are your opening hours?"}'

Python

import requests

r = requests.post(
    "https://chat.astroworldmc.com/api/v1/chat",
    headers={"Authorization": "Bearer awk_YOUR_KEY"},
    json={"bot_id": "YOUR_BOT_ID", "message": "What are your opening hours?"},
)
data = r.json()
print(data["response"])
# pass data["session_id"] back on the next call to continue the conversation

JavaScript

const res = await fetch("https://chat.astroworldmc.com/api/v1/chat", {
  method: "POST",
  headers: {
    "Authorization": "Bearer awk_YOUR_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ bot_id: "YOUR_BOT_ID", message: "What are your opening hours?" }),
});
const data = await res.json();
console.log(data.response);

PHP

<?php
$ch = curl_init("https://chat.astroworldmc.com/api/v1/chat");
curl_setopt_array($ch, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer awk_YOUR_KEY",
    "Content-Type: application/json",
  ],
  CURLOPT_POSTFIELDS => json_encode([
    "bot_id" => "YOUR_BOT_ID",
    "message" => "What are your opening hours?",
  ]),
]);
$data = json_decode(curl_exec($ch), true);
echo $data["response"];

Webhook (optional)

Set a webhook URL on a key in the dashboard. Every API request and its response is also POSTed to that URL as JSON, so you can mirror conversations into your own systems.

API reference | Astroworld Chat