Advanced Features

API Reference

Integrate hej! directly into your applications.

The hej! API allows you to programmatically interact with your AI chatbot. Send messages, retrieve responses, and integrate chat functionality into your own applications.

Base URL

https://api.hej.chat

Authentication

API requests are authenticated using your domain. For public widget requests, the domain is passed via the data attribute. For server-to-server requests, contact us for API key access.

API Keys

API key authentication is available on Enterprise plans. Contact sales for access.

Endpoints

WS/api/chat

Open a WebSocket connection to send messages and receive streaming AI responses.

Connection

wss://api.hej.chat/api/chat?domain=your-domain.com

Send Message

{
  "message": "What are your business hours?",
  "conversationId": "optional-conversation-id"
}

Response Events

The server sends streaming events over the WebSocket connection:

EventDescription
textStreaming text chunk from the AI
tool-callAI is invoking a tool (e.g. search, custom tool)
doneResponse complete
GET/api/site-public/:domain

Retrieve widget configuration for a domain.

Response

{
  "headerBgColor": "#ffffff",
  "headerTextColor": "#000000",
  "title": "Chat with us",
  "subtitle": "We're here to help",
  "position": "right"
}
POST/api/document

Retrieve the content of a specific indexed page.

Request Body

{
  "domain": "your-domain.com",
  "url": "https://your-domain.com/about"
}

Rate Limits

API requests are rate-limited based on your plan:

PlanRequests/minuteConversations/month
Starter605,000
Growth12010,000
Business30050,000
EnterpriseCustomUnlimited

Error Handling

{
  "error": {
    "code": "RATE_LIMIT_EXCEEDED",
    "message": "Too many requests. Please try again later.",
    "retryAfter": 60
  }
}
CodeDescription
DOMAIN_NOT_FOUNDDomain is not registered
RATE_LIMIT_EXCEEDEDToo many requests
QUOTA_EXCEEDEDMonthly conversation limit reached
SUBSCRIPTION_INACTIVESubscription is inactive