All docs pages

API quickstart

Make a key, install the Python SDK or grpcurl, and make your first calls. Covers listing spaces, starting a thread, calling a bot and reading its answer.

1. Get a key

In Caret Chat, go to Settings › API keys › New key. For this quickstart choose Read and write, then copy the key. See Authentication.

Keep it in an environment variable:

export CARET_API_KEY='cpk_…'
export CARET_SERVER='https://caret.yourcompany.com'   # your organisation's address

For Caret Cloud, use https://caretsvc.com.

2a. With Python

Install the SDK. It needs Python 3.10 or later:

pip install https://caretbot.com/api/caret-sdk-0.1.0.zip

Then:

import caret

c = caret.Caret()          # reads CARET_API_KEY and CARET_SERVER

print(c.workspace().name)

for s in c.spaces.list():
    print(s.space.name, s.space.id)

# Start a thread and call a bot in by its handle
thread = c.threads.create("billing", "Weekly denials", "@denials summarise last week's denials by payer")

# Wait for the bot's answer
for event in c.events(thread=thread.id, kinds=["message_posted"]):
    m = event.message_posted.message
    if m.author.kind == caret.pb.SUBJECT_KIND_BOT:
        print(m.body)
        break

A bot is called in when its handle is in the message (@denials), or when you pass mention=["denials"].

More in Python SDK.

2b. With grpcurl (any language)

Download the .proto files and unzip them. You get a caret/v1/ folder. Install grpcurl, for example brew install grpcurl.

unzip caret-proto-v1.zip -d caret-proto
HOST=caret.yourcompany.com:443          # or caretsvc.com:443

# Your workspace
grpcurl -import-path caret-proto -proto caret/v1/admin.proto \
  -H "authorization: Bearer $CARET_API_KEY" \
  -d '{}' $HOST caret.v1.AdminService/GetWorkspace

# Its spaces
grpcurl -import-path caret-proto -proto caret/v1/read.proto \
  -H "authorization: Bearer $CARET_API_KEY" \
  -d '{}' $HOST caret.v1.ReadService/ListSpaces

# Start a thread in a space, calling a bot in by name
grpcurl -import-path caret-proto -proto caret/v1/commands.proto \
  -H "authorization: Bearer $CARET_API_KEY" \
  -d '{
        "idempotency_key": "my-script-2026-12-01-1",
        "command": { "create_thread": {
          "space_id": "<space id>",
          "title": "Weekly denials",
          "initial_message": "@denials summarise last week'"'"'s denials by payer"
        } }
      }' \
  $HOST caret.v1.CommandService/Execute

The response lists the events the command made. thread_created carries the new thread's id.

Read the thread's messages:

grpcurl -import-path caret-proto -proto caret/v1/read.proto \
  -H "authorization: Bearer $CARET_API_KEY" \
  -d '{"thread_id": "<thread id>"}' $HOST caret.v1.ReadService/ListMessages

Server reflection is off, so always pass -import-path and -proto.

3. Other languages

Generate a client from the .proto files with your language's gRPC tools, such as protoc, buf generate, grpc-tools for Node, or tonic-build for Rust. Then set the authorization: Bearer … metadata on every call. Browsers can use gRPC-Web.

Next

Updated · Something wrong or missing? Write to support@caretbot.com.