---
title: "API reference | Owlbee"
description: "The Owlbee chat API: every public endpoint, request and response fields, widget and booking actions, errors and examples."
canonical: "https://owlbee.ai/developers/api"
updated: "2026-11-09"
---

Developers

# API reference

Every public Owlbee endpoint and how to call it. To work with your own account from an AI tool, use the [MCP servers](https://owlbee.ai/developers/mcp).

Contents

1. [Endpoints](https://owlbee.ai/developers/api#endpoints)
2. [Quick start](https://owlbee.ai/developers/api#quick-start)
3. [What this API is, and is not](https://owlbee.ai/developers/api#what-this-api-is-and-is-not)
4. [CORS](https://owlbee.ai/developers/api#cors)
5. [Request body](https://owlbee.ai/developers/api#request-body)
6. [Actions](https://owlbee.ai/developers/api#actions)
7. [Response body](https://owlbee.ai/developers/api#response-body)
8. [The booking flow](https://owlbee.ai/developers/api#the-booking-flow)
9. [Errors](https://owlbee.ai/developers/api#errors)
10. [Usage tracking](https://owlbee.ai/developers/api#usage-tracking)
11. [Examples](https://owlbee.ai/developers/api#examples)

## Endpoints

| Method | Path | What it does | Needs |
| --- | --- | --- | --- |
| POST | `/api/chat/{embedCode}` | Send a chat turn or a widget/booking action to one chatbot | Embed code (public) |
| POST | `/api/track-usage/{embedCode}` | Record a website that embeds the chatbot | Embed code (public) |
| GET | `/health` | Service health | Nothing |
| GET | `/openapi.json` | This API as an OpenAPI 3.1 document | Nothing |

## Quick start

Every Owlbee chatbot answers on one public endpoint, the same one the embedded chat widget uses:

```
POST https://owlbee.ai/api/chat/{embedCode}
Content-Type: application/json
```

`{embedCode}` is the chatbot's embed code, the UUID shown under **Get Embed Code** on the chatbot's page (see [Embedding the chat widget](https://owlbee.ai/integrations)).

A machine-readable OpenAPI 3.1 description of this API is published at <https://owlbee.ai/openapi.json>. It covers this endpoint, usage tracking and `/health`. This guide says the same in prose, with the booking flow step by step.

Try it from a terminal, using your chatbot's embed code:

```
curl -X POST https://owlbee.ai/api/chat/YOUR_EMBED_CODE \
  -H "Content-Type: application/json" \
  -d '{"message": "What are your opening hours?"}'
```

## What this API is, and is not

- **The embed code is public, not a secret.** It sits in the page source of every website that embeds the bot. It identifies the chatbot. It is not an account API key and grants nothing beyond chatting with that one bot.
- **There is no authentication on this endpoint.** There are no API keys, tokens or OAuth here. Anyone who has the embed code can chat with the bot, exactly as a website visitor can.
- **This is not an account API.** Creating chatbots and managing billing are done only in the Owlbee web app at https://owlbee.ai, signed in as the account owner. An owner can read conversations and analytics, and make some changes, through [the account MCP server](https://owlbee.ai/developers/mcp#account) with an API key.
- **Every reply is billed to the bot's owner.** Model calls count toward the owner's monthly AI token allowance (see [Plans, limits and trials](https://owlbee.ai/plans)). Be considerate with automated traffic.

## CORS

Every path under `/api/` allows cross-origin requests from any origin. Methods `GET`, `POST` and `OPTIONS` and request headers `Content-Type` and `Authorization` are allowed. The response's `Access-Control-Allow-Origin` echoes the caller's `Origin` (with `Vary: Origin`), so browsers can call the endpoint from any website. No credentials are needed or used.

## Request body

A JSON object. Every field is optional on its own, but a plain chat turn needs `message`.

| Field | Type | Meaning |
| --- | --- | --- |
| `message` | string | What the visitor typed. Leading and trailing whitespace is trimmed. While a booking is in progress, typed text is treated as an answer to the current booking step (for example "next Tuesday afternoon" or the visitor's name) rather than as a question for the bot. |
| `conversation_id` | string | The id from a previous response. Send it back on every later turn of the same conversation. Leave it out on the first turn and the server creates one. |
| `action` | string | One of the actions below. Leave it out for a plain chat turn. |
| `ui` | array of strings | What the client can draw. `"calendar"` means it can render the booking calendar card. Without it, the time step offers a short list of slot buttons instead. `"products"` means it can render product cards for a bot connected to a Shopify store. Without it, the reply still links each product. The official widget always sends `["calendar", "products"]`. |
| `value` | string | The value of a pressed button. Used with `schedule_slot` to send the chosen slot. |
| `values` | object | The fields of a submitted in-chat form. Used with `schedule_details`: `{"name": "...", "email": "...", "phone": "..."}`. |
| `resolved` | boolean | Used with `end_conversation`: `true` if the visitor's question was answered, `false` if not. Defaults to `false`. |

## Actions

These are every value of `action` the endpoint acts on, in the order a widget meets them:

| Action | When to send it | What comes back |
| --- | --- | --- |
| `widget_config` | On page load, before anyone opens the chat. | `{"open_by_default": true\|false}`. It is `true` only when the owner turned on "Open the chat window automatically", the bot is trained or has a system prompt, and the owner's trial has not ended. Nothing is tracked and no tokens are used. |
| `widget_hello` | When the chat window opens. The greeting itself is written by the widget, not the server. | `conversation_id` and `actions`. `actions` holds the "Book a call" button when the bot offers booking, and is empty otherwise. No tokens are used. |
| `end_conversation` | When the visitor closes or rates the conversation. Needs `conversation_id`, and takes `resolved`. | `{"success": true, "message": "Conversation status updated", "updated": <rows>, "conversation_id": "..."}`. It marks that conversation resolved or unresolved in the owner's analytics. It still works after a trial has ended or the token limit is reached. |
| `schedule_start` | When the visitor presses "Book a call" (the button's `id` is `schedule_start`). | The first booking step (see below), or "Sorry, booking isn't available right now." with `booking.active` false if the bot does not offer booking. |
| `schedule_slot` | A time was picked from the calendar card or a slot button. Send its `value`. | The next step. The value must be one of the slots the server offered. Anything else is treated as no choice, and the times are offered again. |
| `schedule_details` | The in-chat contact form was submitted. Send `values`. | The booking confirmation, or the form again with an `error` on each field that needs fixing. |
| `schedule_confirm` | "Confirm booking" was pressed on the summary step. | The booking confirmation. |
| `schedule_change_time` | "Change time" was pressed. | The time step again, with the chosen time cleared. |
| `schedule_abort` | "Never mind" was pressed. | "No problem - I've cancelled that." and the booking draft is deleted. |

The five actions after `schedule_start` only mean something while a booking is in progress for this `conversation_id`. Without one they are ignored and the turn is handled as an ordinary chat turn, which needs a `message`.

A visitor who types a booking request ("I'd like to schedule a call") instead of pressing the button gets the same booking flow, if the bot offers booking.

## Response body

Every successful chat or booking turn returns HTTP 200 with this shape:

| Field | Type | Meaning |
| --- | --- | --- |
| `response` | string | The reply as plain text. |
| `response_html` | string | The same reply as sanitized HTML, for display. Only `a`, `b`, `strong`, `i`, `em`, `u`, `br`, `p`, `ul`, `ol`, `li`, `code` and `span` are kept, with only `class`, `title` and `href` attributes, and links are http(s), mailto or tel only. |
| `conversation_id` | string | Send it back on the next turn. |
| `actions` | array | Buttons and cards to show under the reply. Each has an `id`, which is the `action` to send when it is used. Simple buttons have `label` and `style`, and a slot button also has `value`. A card has a `type`: `calendar` (weeks of days, each with its time slots, every slot with a `label` and a `value` for `schedule_slot`) or `form` (the contact `fields` for `schedule_details`). Cards also carry `secondary` buttons. A `products` card (only when `ui` includes `"products"`) lists up to four `items`, each with `title`, `url`, `image`, `price` and `compare_at` (`{amount, currency}`), `available`, and `variants` (`id`, `title`, `available`, `price`), plus the store's myshopify `shop`. It sends no `action`: Add to cart runs in the browser against the store's own cart. |
| `booking` | object | Only on booking turns: `{"active": true\|false, "step": "time" \| "details" \| "confirm" \| "done" \| null}`. While `active` is true, the next typed message answers the booking step. |
| `limit_reached` | boolean | Only present, and `true`, when the owner has used up this month's AI token allowance. `response` is a short notice for the visitor, not an answer. The "Book a call" button is still offered, because booking needs no model. |
| `trial_expired` | boolean | Only present, and `true`, when the owner's free trial has ended. `response` says the bot is unavailable, `actions` is empty, and booking is off too. |

A `widget_hello` reply has only `conversation_id` and `actions`. A `widget_config` reply has only `open_by_default`.

## The booking flow

When the bot offers booking (see [Booking calls and calendar links](https://owlbee.ai/features/appointment-booking)), a booking runs as a fixed sequence of steps. It never needs the model, except to understand a time typed in words:

1. **time:** the visitor picks a slot (`schedule_slot` with its `value`) or types a time in their own words. Times are in the business's timezone, which is named in the reply.
2. **details:** the visitor fills in name, email and phone in the in-chat form (`schedule_details` with `values`). They can also type the answers one at a time.
3. **confirm:** when the details arrived as typed answers, or were already filled in before a change of time, the server shows a summary and waits for `schedule_confirm`. A valid submitted form books the call straight away.
4. **done:** the call is booked, and `booking.active` is false. The visitor and the business both get a confirmation email.

`schedule_change_time` and `schedule_abort` work at every step. If the chosen time was taken in the meantime, the reply says so and goes back to the time step. A booking left unfinished for an hour may be discarded. Each bot accepts at most 40 new booking attempts and 12 confirmed bookings per hour. Beyond that, the reply asks the visitor to try again shortly.

## Errors

Errors are JSON objects with an `error` string.

| Status | When |
| --- | --- |
| 404 | No chatbot has this embed code: `{"error": "Chatbot not found. Please check the embed code."}` |
| 400 | The bot is not trained and its system prompt has been emptied (every action except `widget_config`). New bots start with a default system prompt, so this is rare. |
| 400 | The JSON body is empty (`{}` or `null`): `{"error": "No data received"}` |
| 400 | `end_conversation` without `conversation_id`. |
| 400 | No `message` on a plain chat turn: `{"error": "Message is required"}` |
| 500 | Anything else that fails, including a body that is not valid JSON or not sent as `application/json`: `{"error": "Sorry, I encountered an error. Please try again."}` |

The monthly token limit and an ended trial are **not** errors. They come back as HTTP 200 with `limit_reached` or `trial_expired` set, so a widget that only reads `response` still shows the visitor a message.

## Usage tracking

```
POST https://owlbee.ai/api/track-usage/{embedCode}
Content-Type: application/json

{"website_url": "https://example.com/pricing"}
```

This records the domain of `website_url`, or of the `Referer` header if the JSON body has no `website_url`, in the chatbot's "Used On" list. The body must be sent as `application/json` (`{}` is fine); anything else gives a 500. Localhost addresses are skipped. A chat request that sends a `Referer` header is tracked the same way automatically, so the widget never needs to call this. It returns `{"success": true, "message": "Usage tracked successfully"}`. It returns 404 for an unknown embed code, and 400 if no URL is given.

## Examples

A first chat turn:

```
POST /api/chat/0b6f3c1e-1111-2222-3333-444455556666
{"message": "What are your opening hours?", "ui": ["calendar"]}

200
{"response": "We're open 9 to 5, Monday to Friday.",
 "response_html": "<p>We're open 9 to 5, Monday to Friday.</p>",
 "conversation_id": "5f0c2a9e-...",
 "actions": [{"id": "schedule_start", "label": "Book a call", "style": "primary"}]}
```

Starting a booking in the same conversation:

```
POST /api/chat/0b6f3c1e-1111-2222-3333-444455556666
{"action": "schedule_start", "conversation_id": "5f0c2a9e-...", "ui": ["calendar"]}

200
{"response": "When would suit you? Pick a day below, ...",
 "conversation_id": "5f0c2a9e-...",
 "actions": [{"type": "calendar", "id": "schedule_slot", "weeks": [...], ...}],
 "booking": {"active": true, "step": "time"}, ...}
```

Closing it:

```
POST /api/chat/0b6f3c1e-1111-2222-3333-444455556666
{"action": "end_conversation", "conversation_id": "5f0c2a9e-...", "resolved": true}
```

Questions or problems? Email [support@owlbee.ai](mailto:support@owlbee.ai).
