DocubixDocs
Dashboard

Examples

Copy-paste samples for common integrations.

Replace rag_live_your_api_key_here with your key. Call these from a server — never from browser code.

cURL

curl
curl -X POST https://api.docubix.com/chat \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": "rag_live_your_api_key_here",
    "message": "What is ATP?"
  }'

JavaScript

javascript
const response = await fetch("https://api.docubix.com/chat", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    api_key: process.env.DRAGON_API_KEY,
    message: "What is ATP?"
  })
});

const data = await response.json();
console.log(data.answer);

Next.js API route

typescript
// app/api/ask/route.ts
import { NextRequest, NextResponse } from "next/server";

export async function POST(req: NextRequest) {
  const { message, conversation_id } = await req.json();

  const res = await fetch("https://api.docubix.com/chat", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      api_key: process.env.DRAGON_API_KEY,
      message,
      conversation_id
    })
  });

  if (!res.ok) {
    const err = await res.json();
    return NextResponse.json(err, { status: res.status });
  }

  return NextResponse.json(await res.json());
}

Python

python
import os
import requests

response = requests.post(
    "https://api.docubix.com/chat",
    json={
        "api_key": os.environ["DRAGON_API_KEY"],
        "message": "What is ATP?"
    },
    timeout=60,
)
response.raise_for_status()
print(response.json()["answer"])