Chat

Code Capsules provides an integrated chat window for Agent Capsules. In order for this to be fully functional, there are a few endpoints which the API needs to expose.

API Requirements

The deployed codebase needs to expose a few endpoints, each with their own pre-described payload. Data is always returned in the ApiResponse format. Errors are returned in the Error format.

Endpoints

Below describes the endpoints required to use the integrated chat window:

Endpoint
Purpose
Mandatory
Sample Docs

POST

/api/chat/message

Send a message to the agent with an instant response.

Yes*

POST

/api/chat/message/stream

Send a message to the agent, streaming back the response.

Yes*

GET

/api/chat/history

Get the chat history for the user.

Yes

POST

/api/context/text

Submit context to the agent using text.

No

POST

/api/context/url

Submit context to the agent using a URL.

No

*Only one of these are required

Request Headers from Code Capsules

All of the above endpoints will also be passed the following headers. This allows for some simple security when testing the agent using the integrated chat window:

Header
Description
Mandatory

X-CC-API-KEY

This value will be the value as generated in the INTERNAL_API_KEY environment variable on creation of the Agent capsule.

No

X-CC-EMAIL

This value will be the email of the user who has logged into Code Capsules, allowing for testing with unique chat sessions and chat history.

No

Last updated

Was this helpful?