All docs pages

API overview

Use Caret from your own code with a personal API key. Covers how the API works, where to send requests, scopes, workspaces and limits.

The Caret API lets your own code do what people do in a Caret workspace:

  • read spaces, threads and messages;
  • start threads, post messages and call bots in;
  • watch events as they happen;
  • approve or deny what bots ask for;
  • manage bots, schedules, vault items and memory.

You authenticate with a personal API key made in the Caret Chat app.

Where to send requests

Server Address
Your organisation's own Caret server The address you sign in with, e.g. https://caret.yourcompany.com
Caret Cloud https://caretsvc.com

Every method is at https://<server>/caret.v1.<Service>/<Method>, for example:

https://caret.yourcompany.com/caret.v1.ReadService/ListThreads

The server speaks gRPC over HTTP/2 and gRPC-Web. The contract is the caret.v1 package: download the .proto files.

Authentication

Send your key in the authorization header on every call:

authorization: Bearer cpk_…

Making a key

A person makes a key in Caret Chat:

  1. Open Settings › API keys and click New key.
  2. Give it a name that says what it's for, such as billing-report script.
  3. Choose its access: Read only, Read and write, or Custom (pick scopes one by one).
  4. Choose how long It lasts: 30 days, 90 days or a year.
  5. Copy your key now. It's shown once. Caret keeps only a hash of it.

Guests can't make keys. Only admins can make a key with the admin scope. Keys can't be made through the API.

What a key is

  • A key acts as the person who made it. Everything it does is recorded as theirs. It can never do more than that person could: their role and which spaces they're in still apply.
  • A key works in one workspace, the one it was made in.
  • A key always expires: after 90 days by default, a year at most.
  • Keys start with cpk_ and are 53 characters long. A mistyped key is refused straight away.

Revoking a key

In Settings › API keys, click Revoke. The key stops working on its very next request. The key's maker or a workspace admin can revoke it. If the person is deactivated, their keys stop working too.

Scopes

A key may only call methods its scopes allow.

Scope Allows
read Every read: spaces, threads, messages, bots, members, schedules, approvals, memory, vault item names, files, events
messages Start threads, post, edit and delete messages, react, answer cards, add people, mark done or reopen, stop bots
spaces Create and change spaces and who's in them
bots Register and change bots and their access, assign bots to threads, bot tokens, schedules
memory Write memory files, and add, change, delete or assign vault items
files Upload files
approvals Approve or deny what bots ask for, as the key's person
admin Workspace admin calls: rename, time zone, invite people, set roles, exports. The person must be an admin

Read only gives read. Read and write gives read, messages, spaces, bots, memory and files. Add approvals or admin with Custom.

Give a key the fewest scopes it needs. A reporting script needs only read.

Workspace

A key works in its own workspace. You don't need to name it. Requests that carry a workspace_id can leave it empty. A key used against a different workspace is refused (WRONG_WORKSPACE). To work in two workspaces, make a key in each.

Limits

  • Rate: 1,200 requests per minute per key, with bursts up to the same number. Beyond that, calls fail with RESOURCE_EXHAUSTED. Back off and retry.
  • Message size: 16 MiB per request or response.
  • Pages: list calls return up to 50 items by default and 500 at most. Follow page.next_cursor while page.has_more is true.

What the API doesn't do

  • No webhooks. To react to things as they happen, hold an event stream open.
  • No sign-in or key management. People sign in, and make keys, in the app.
  • Not everything in the app is in the API. For example: connecting integrations, LLM providers, computers, Slack setup, and browsing the Drive. Calls outside the API are refused with NOT_IN_API.

Next

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