Skip to main content
Docuchat.in

Website setup and Developer API

Build on the chatbots you already run.

Add a chatbot to your website, or use the developer API from your server. Website embeds use the code generated in the app, not your private API key.

v1 / REST / JSON

API beta

Server-side API example

curl https://api.docuchat.in/v1/chatbots \
  -H "Authorization: Bearer $DOCUCHAT_API_KEY"

v1 covers reading chatbots and running metered queries. Write management and streaming responses are planned follow-ups.

Website setup

Choose a chatbot

Open Chatbots in the app and select the chatbot you want to add to your website. Review its provisioning and source-sync notices before installing it. A Live badge or successful Copy code action alone does not confirm that the chatbot is ready to answer.

Choose where it may be embedded

To restrict browser embedding, open Configuration, then Edit on the Embed Settings card. Enable Restrict embedding to listed origins.

Enter an exact origin, such as https://example.com. Click Add or press Enter, then click Save. Text left in the input without Add or Enter is not saved.

Use a scheme and hostname, with a non-default port only when needed. Do not include a page path, trailing slash, query, fragment or wildcard. Add https://www.example.com separately if you also use that origin. The saved list supports up to 20 entries.

For current hosted embeds, an enabled restriction with no usable origins prevents browser framing. These origin controls are not API authentication or a private-access system.

Floating widget

Open Share for the selected chatbot. Under Embed type, choose Floating widget and select Copy code. If clipboard access fails, copy the displayed code manually.

Paste the complete generated script before the closing body tag in your website's HTML. Keep defer and the supplied chatbot ID, script URL, chat base and embed base together. Install it once; do not also add the renderer script or replace the chat base with a developer /v1 API URL.

Your website platform must permit the required script, stylesheet and frame. Inspect its content-security-policy or browser console when a resource is blocked rather than disabling the site's policy.

If the generated floating snippet includes optional analytics, the website owner is responsible for obtaining any necessary visitor consent before enabling them. The widget does not provide a visitor-consent banner.

Inline iframe

Open Share, choose Inline iframe, and set Frame height (px). The app defaults to 600 pixels and accepts a whole number from 320 to 1200. These are the generator's choices, not universal iframe or server limits.

Copy the complete iframe and paste it where the chat should appear. Preserve its generated src, sandbox and referrer policy. Keep a descriptive title and size the surrounding page so the frame remains usable.

The inline frame fills its assigned width and height; it does not automatically resize the parent page. It does not forward analytics events to the parent page.

The generated iframe URL does not need an added surface parameter: the backend's omitted-surface default is inline mode. Do not change it into a floating-widget URL, which expects a loader handshake.

Embed troubleshooting

Origin entered but not saved:

Click Add or press Enter before Save. Use a concrete canonical origin, not a page URL. Review any save error instead of assuming the change applied.

No floating launcher:

Confirm that the complete loader script is present once and that the site's policy permits its resources. If Visible URLs is configured, it filters initial launcher display; it is not a server access rule or automatic single-page-app route integration.

Inline frame blocked or blank:

Check browser framing/CSP diagnostics and the exact saved parent-site origin. Keep the generated sandbox/referrer policy. Do not add private keys, spoof headers or broadly disable origin restrictions as a workaround.

"Open this chat from its website":

Test the hosted chat inside the intended website. Opening its URL as a top-level page is not an installation test.

Chatbot unavailable:

Confirm that the code belongs to the intended chatbot and review its active, provisioning and source-sync state. A successful iframe HTML response does not prove that session initialization or answering is ready.

Verification, network or temporary-limit errors:

Follow the displayed verification or retry instruction. Browser policy can block the challenge, frame or network resource. Inspect the specific blocked request and contact support for persistent errors; do not promise invisible CAPTCHA, automatic recovery or effective enforcement in every configuration.

Conversation continuity differs between browsers:

Browser privacy and storage settings can affect session continuity. Browser support is best-effort; this guide does not promise universal storage, history retention or accessibility conformance.

01 / Connection

Base URL

All endpoints are served under the /v1 prefix, which is permanent for the life of v1. Requests and responses are JSON.

https://api.docuchat.in/v1

02 / Access

Authentication

API keys created under Settings > API are for the separate developer API. Keep them in server-side integrations. Never paste them into website HTML, widget attributes or iframe URLs. Do not expose widget internal session endpoints as new public /v1 reference operations.

Create an API key in the Docuchat.in app under Settings → API. The full key (dc_ak_<keyId>_<secret>) is shown once at creation. Store it securely because you cannot see it again.

Send it on every request using either header:

Authorization: Bearer dc_ak_<keyId>_<secret>
# or
X-API-Key: dc_ak_<keyId>_<secret>

Keys are account-scoped: every request acts within the resources of the account that owns the key. Revoked keys stop working immediately.

03 / Quickstart

From key to first answer.

Server-side API example

1. Create a key

In the app, open Settings → API and create a named key. Copy it once.

2. List your chatbots

curl https://api.docuchat.in/v1/chatbots \
  -H "Authorization: Bearer $DOCUCHAT_API_KEY"

3. Ask a question

curl -X POST https://api.docuchat.in/v1/chatbots/<chatbotId>/query \
  -H "Authorization: Bearer $DOCUCHAT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"message": "What is the refund policy?"}'

04 / Reference

Endpoints

GET/v1/chatbotsFree

Lists your chatbots, newest first, paginated (see Pagination).

{
  "data": [
    {
      "chatbotId": "cb_123",
      "name": "Support bot",
      "description": "Answers from our help center",
      "provisioningStatus": "active",
      "isActive": true,
      "llmModel": "gpt-4o-mini",
      "answerLength": "medium",
      "showCitations": true,
      "documentCount": 12,
      "webUrlCount": 3,
      "createdAt": 1737400000000,
      "updatedAt": 1737500000000
    }
  ],
  "nextCursor": null
}
GET/v1/chatbots/{id}Free

Returns a single chatbot you own. Responds 404 if the id is unknown or not owned by your account.

POST/v1/chatbots/{id}/queryMetered

Runs retrieval + answer generation for a chatbot you own and debits credits for the tokens used. Guardrails run in order: authenticate, rate limit, credit and plan gate, per-chatbot spend cap, generate, then debit.

Request body

{
  "message": "What is the refund policy?",
  "sessionId": "optional-caller-supplied"
}

Example response

{
  "answer": "Our refund policy is ...",
  "chatbotId": "cb_123",
  "sessionId": "api-<requestId>",
  "model": "gpt-4o-mini",
  "usage": { "inputTokens": 812, "outputTokens": 143, "creditsDebited": 0.42 },
  "sources": [
    { "title": "Refund policy", "source": "refunds.pdf", "page": 2, "score": 0.87 }
  ]
}

Streaming (stream: true) is not supported yet and returns 400. Omit it for buffered JSON.

05 / Reliability

Rate limits

Requests are rate limited per key (60 requests per minute by default). Every response includes the current window state:

X-RateLimit-Limit: 60
X-RateLimit-Remaining: 59
X-RateLimit-Reset: 1737500060

When exceeded you receive 429 RATE_LIMITED with a Retry-After header (seconds). Rate limiting is separate from your credit balance and the per-chatbot spend cap.

Errors

Every non-2xx response uses a consistent JSON envelope:

{ "error": "UNAUTHORIZED", "message": "Invalid or revoked API key." }
CodeHTTPMeaning
UNAUTHORIZED401Missing, malformed, unknown, or revoked API key.
ACCOUNT_READ_ONLY403The account is deactivated and cannot perform this action.
VALIDATION_ERROR400The request was invalid (e.g. empty message, or stream:true).
NOT_FOUND404The chatbot was not found or is not owned by the calling account.
USAGE_BLOCKED402Insufficient credits / account blocked (when enforcement is on).
RATE_LIMITED429Per-key rate limit exceeded. Honor the Retry-After header.
CHATBOT_RATE_LIMITED429The chatbot's spend cap tripped for the current window.
INTERNAL500An unexpected server error.

Pagination

List endpoints accept ?limit= (1 to 100, default 25) and an opaque ?cursor=. The response includes nextCursor; pass it back to fetch the next page. A null cursor means the last page.

curl "https://api.docuchat.in/v1/chatbots?limit=50&cursor=<nextCursor>" \
  -H "Authorization: Bearer $DOCUCHAT_API_KEY"

06 / Tooling

OpenAPI spec

The machine-readable OpenAPI 3.1 description is available for import into Postman, code generators, and other tooling.

Ready to build?

Create your first API key in the Docuchat.in app and start querying in minutes.