For Developers

REST API

Embed AI-powered answers directly in your website, app, or internal tool. Simple REST API. API key authentication. JSON in, JSON out.

Get started in 3 steps

1

Sign Up

Create an account and get your API key from the platform dashboard.

2

Set Your Header

Include the X-API-Key header in every request.

3

Send JSON, Get Answers

POST a question, receive an AI-powered answer grounded in your corpus.

POST /api/v2/chat.php
Quick Start
curl -X POST https://ai.bluenotelogic.com/api/v2/chat.php \
  -H "Content-Type: application/json" \
  -H "X-API-Key: bnl_your_api_key" \
  -d '{"message": "What is our return policy?"}'

Authentication

All API requests require an X-API-Key header. Keys are unique to your account and scoped to your corpus.

Prefixed for Identification

All keys start with bnl_ so you can easily identify them in your code and config files.

Hashed on Our Servers

Keys are hashed (SHA-256) at rest. We never store them in plaintext. If you lose your key, generate a new one.

Generate & Revoke from Dashboard

Manage your keys from the platform dashboard. Revoke compromised keys instantly.

Request Header
X-API-Key: bnl_sk_abc123def456...

Rate Limits by Plan

Trial No API access
Starter 500 requests/month
Professional 2,000 requests/month
Enterprise Custom

Endpoints

Base URL: https://ai.bluenotelogic.com

POST /api/v2/chat.php AI Chat

Ask a question and get an AI-powered answer from your document corpus. The response includes the generated answer, source citations, model information, and performance metrics.

Request Body (JSON)

message
string required

The question to ask your AI assistant.

use_corpus
boolean default: true

Whether to search your document corpus for context. Set to false for general AI chat.

model
string optional

Specific model to use for generation. Defaults to the best available model.

Response (JSON)

answer
string

The AI-generated answer grounded in your documents.

model
string

The model used for generation (e.g. "qwen2.5:72b").

sources
array

Source documents referenced in the answer, with title and relevance score.

response_time_ms
integer

Total processing time in milliseconds.

tokens_used
integer

Number of tokens consumed by the request.

Example Request & Response curl
# Request
curl -X POST https://ai.bluenotelogic.com/api/v2/chat.php \
  -H "Content-Type: application/json" \
  -H "X-API-Key: bnl_sk_abc123def456" \
  -d '{
    "message": "What is our return policy?",
    "use_corpus": true
  }'

# Response
{
  "answer": "According to your Terms of Service (Section 7.1), customers may request a full refund within 14 days of purchase, provided the product has not been downloaded or activated. Refund requests should be submitted through the customer portal.",
  "model": "qwen2.5:72b",
  "sources": [
    {
      "title": "terms-of-service-v3.2.pdf",
      "score": 0.94,
      "excerpt": "Section 7.1 — Refund Policy: Customers are entitled to..."
    }
  ],
  "response_time_ms": 2340,
  "tokens_used": 847
}
$ch = curl_init('https://ai.bluenotelogic.com/api/v2/chat.php');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
        'X-API-Key: bnl_your_api_key',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'message' => 'What is our return policy?',
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
echo $response['answer'];
POST /api/v2/documents.php Document Management

Upload, list, and delete documents in your corpus programmatically. Use this endpoint to integrate document management into your own workflows and automation pipelines.

LIST List Documents

Returns all documents in your corpus with metadata including title, upload date, chunk count, and status.

{"action": "list"}
UPLOAD Upload Document

Upload a new document to your corpus. Uses multipart/form-data. Supported formats: PDF, DOCX, TXT, HTML.

multipart/form-data
DELETE Remove Document

Remove a document and all its chunks from your corpus. This action is irreversible.

{"action": "delete", "document_id": 142}
LIST List all documents
curl
curl -X POST https://ai.bluenotelogic.com/api/v2/documents.php \
  -H "Content-Type: application/json" \
  -H "X-API-Key: bnl_sk_abc123def456" \
  -d '{"action": "list"}'

# Response
{
  "documents": [
    {
      "id": 142,
      "title": "hr-onboarding-guide.pdf",
      "chunks": 24,
      "uploaded_at": "2026-03-01T10:30:00Z",
      "status": "ready"
    },
    {
      "id": 98,
      "title": "employee-handbook-2025.pdf",
      "chunks": 87,
      "uploaded_at": "2026-02-15T14:22:00Z",
      "status": "ready"
    }
  ],
  "total": 2
}
UPLOAD Upload a document
curl
curl -X POST https://ai.bluenotelogic.com/api/v2/documents.php \
  -H "X-API-Key: bnl_sk_abc123def456" \
  -F "action=upload" \
  -F "file=@/path/to/document.pdf"

# Response
{
  "success": true,
  "document_id": 210,
  "title": "document.pdf",
  "chunks": 15,
  "message": "Document uploaded and processed successfully."
}

Error Handling

The API uses standard HTTP status codes. Errors return a JSON object with a human-readable message and a machine-readable code.

HTTP Status Codes

200 Success
400 Bad request — missing or invalid parameters
401 Unauthorized — invalid or missing API key
403 Forbidden — feature not available on your plan
429 Rate limit exceeded
500 Server error — please try again or contact support
Error Response Format
{
  "error": "Rate limit exceeded",
  "code": "RATE_LIMIT",
  "retry_after": 3600
}
Authentication Error
{
  "error": "Invalid or missing API key",
  "code": "UNAUTHORIZED"
}
Validation Error
{
  "error": "The 'message' field is required",
  "code": "VALIDATION_ERROR"
}

Rate Limits & Usage

Rate limits are enforced per API key on a monthly billing cycle. Every API response includes headers so you can track your usage in real time.

Response Headers

X-RateLimit-Limit

Total requests allowed in the current billing period.

X-RateLimit-Remaining

Requests remaining in the current billing period.

X-RateLimit-Reset

Unix timestamp when the rate limit resets (start of next billing period).

Example Response Headers
HTTP/1.1 200 OK
Content-Type: application/json
X-RateLimit-Limit: 2000
X-RateLimit-Remaining: 1847
X-RateLimit-Reset: 1743465600

What Counts as a Request

Chat requests

Each call to /api/v2/chat.php counts as 1 request.

Search requests

Each call to /api/v2/search.php counts as 1 request.

Document management

List, upload, and delete operations are free and do not count against your limit.

Failed requests

Requests that return 4xx/5xx errors are not counted against your limit.

Ready to integrate CorpusAI?

Get your API key and start building. Three lines of code to AI-powered answers from your own documents.