REST API
Use the REST API to query a Denser chatbot from your own product, internal tools or automations. Everything you need is on the chatbot’s API channel: turn the API on, get a key, and run a real request before you write any code.

1. Open the API channel
Section titled “1. Open the API channel”Open the chatbot you want to query. On its Playground, select the API tab in the row of channels at the top.
Make sure Enable API is on. While it is off, every request to this chatbot’s API is refused.
2. Get an API key
Section titled “2. Get an API key”In the API Keys tab, click Generate API key. If the chatbot already has a key, you see its first and last characters and a Regenerate key button.
Copy the key and store it somewhere safe, such as your server’s environment variables. It is shown only once: afterwards only its first and last characters are.
A key you generate here is also filled into the request on the right, so you can try it straight away.
3. Run a request
Section titled “3. Run a request”The Try it panel holds a ready-made request for this chatbot: its chatbot ID, your key, a question, an example userId and the chatbot’s model.
Edit any field you like, such as the
question. If the key shows as zeros, paste your saved key intokey.Click Run request. The response shows the chatbot’s
answer, thepassagesit drew on, and theconversationIdandmessageIdof this exchange.To ask a follow-up, click Continue conversation, edit the question, and run it again. The chatbot answers with the earlier turns as context.
Test requests are recorded under the user test-user, so you can find them in Chat logs apart from real users. Reset restores the request. On a narrow screen, where the Try it panel is not shown beside the key, open it with Set up API.
4. Call it from your code
Section titled “4. Call it from your code”Click Copy curl to copy the request as a curl command, ready to run from a terminal or translate to your language:
curl -X POST "https://denser.ai/api/query" \ -H "Content-Type: application/json" \ -d '{ "question": "What can you help me with?", "chatbotId": "<chatbot-id>", "key": "<api-key>", "userId": "<your-user-id>" }'Send your own ID for the person asking as userId, and the conversationId from a response to continue that conversation. To read a user’s conversations back, copy the request under List a user’s conversations.
5. Stream the answer
Section titled “5. Stream the answer”To show the answer word by word as it is written, the way the chat widget does, add "stream": true to the request. The answer then arrives as Server-Sent Events: a delta event for each piece of text, then a done event with the same body as the JSON response.
In the Try it panel, set stream to true and click Run request to watch the answer arrive. Copy curl then adds -N, which stops curl from holding the output back:
curl -N -X POST "https://denser.ai/api/query" \ -H "Content-Type: application/json" \ -d '{ "question": "What can you help me with?", "chatbotId": "<chatbot-id>", "key": "<api-key>", "userId": "<your-user-id>", "stream": true }'See Streaming the answer for every event, and examples in JavaScript and Python.