API reference
Every method a personal API key can call, grouped by what it's for, with the scope each needs and its main fields.
Methods are at https://<server>/caret.v1.<Service>/<Method>. The full request and response types are in the .proto files. This page lists what you'll use most.
Conventions
- Ids are 26-character ULIDs.
- Times are Unix milliseconds.
workspace_idcan be left empty. It means the key's own workspace.- List calls take
page: { limit, cursor }and returnpage: { next_cursor, has_more }.
Reading
ReadService, scope read.
| Method | Request | Returns |
|---|---|---|
ListSpaces |
workspace_id |
spaces[]: each a space (id, name, purpose, visibility), with member_ids, archived |
ListThreads |
space_id (empty: every space), statuses[], page |
threads[] (id, space_id, title, status, created_by), unread_thread_ids |
GetThread |
thread_id |
thread, participants, artifacts, notes, open_gates, plan |
ListMessages |
thread_id, page, newest_first |
messages[] (id, author, body, kind, reply_to_id, created_at, card) |
Search |
query, space_id, page |
hits[] (kind, id, thread_id, title, snippet, at) |
GetInbox |
workspace_id |
needs_you[], running[], done[] for the key's person |
ListBots |
workspace_id |
bots[] (id, handle, name, status, model, instructions, respond_when) |
ListGates |
statuses[], for_me, page |
Approvals: gates[] (id, thread_id, bot_id, action, status, opened_at) |
ListSchedules |
workspace_id |
schedules[]: each a schedule with last_run_at, next_run_at |
ListEvents |
from_seq, limit |
Workspace events after from_seq. See Events |
AdminService, scope read:
| Method | Returns |
|---|---|
GetWorkspace |
id, name, slug, role, time_zone, time_format |
ListMembers |
members[] (id, handle, display_name, role, status, title) |
ListRoles |
The workspace's roles |
Commands
Everything that changes a thread, space, bot or schedule goes through CommandService/Execute:
{
"workspace_id": "",
"idempotency_key": "any-unique-string",
"command": { "<command name>": { …fields… } }
}
- It returns
events[]: what the command did. For example,thread_createdcarries the new thread. - Idempotency: send a unique
idempotency_keywith every command. If you retry with the same key, the command isn't run again, and the response saysreplayed: true. ExecuteBatchtakescommands[]and runs them all or none. Every command's scope is checked before any of them runs.
Threads and messages
Scope messages.
| Command | Fields | Notes |
|---|---|---|
create_thread |
space_id, title, initial_message, mention_bot_ids[] |
Bots named with @handle in the message, or listed by id, are called in |
post_message |
thread_id, body, kind (MESSAGE_KIND_TEXT), reply_to_id, client_message_id |
client_message_id: a ULID you make, which becomes the message's id. @handle calls a bot in |
edit_message |
message_id, body, delete |
Your own messages |
react_to_message |
message_id, emoji, on |
|
respond_to_card |
message_id, action_id, values (JSON string), response_id |
Press a button on a bot's card |
add_participant / remove_participant |
thread_id, subject_kind, subject_id |
|
mark_done / reopen |
thread_id |
|
stop_bots |
thread_id |
Stops every bot working in the thread |
set_thread_notes |
thread_id, notes |
The thread's shared notes (admins) |
add_artifact |
artifact: thread_id, kind (file or link), title, file_id or url |
Share an uploaded file or a link in a thread |
open_dm |
member_id |
A direct conversation with a person |
Spaces
Scope spaces.
| Command | Fields |
|---|---|
create_space |
name, purpose, visibility (open or private) |
update_space |
space: the space with its id and the fields to change (name, purpose) |
change_space_membership |
space_id, subject_kind (SUBJECT_KIND_MEMBER or SUBJECT_KIND_BOT), subject_id, add |
archive_space |
space_id, archived |
Bots and schedules
Scope bots.
| Command | Fields | Notes |
|---|---|---|
register_bot |
handle, name, instructions, respond_when, host_kind |
Use host_kind: "external" for a bot you run with the SDK |
update_bot |
bot: the bot with its id and the fields to change |
Bots the key's person may change |
update_bot_grants |
bot_id, grants[] (kind: space_read, space_write…; target) |
Which spaces a bot may read or work in |
create_schedule |
schedule: bot_id, space_id, prompt, cadence, time_zone (e.g. America/New_York), enabled |
cadence: "hourly", "every 6h", "daily 09:00", "weekdays 09:00", "weekly mon 09:00" |
update_schedule |
schedule (with its id) |
|
delete_schedule |
schedule_id |
Bot tokens, for a bot you run yourself, are on AuthService with scope bots: CreateBotToken (bot_id, name, expires_in_days; the token is returned once), ListBotTokens, RevokeBotToken.
Approvals
Scope approvals.
| Command | Fields |
|---|---|
resolve_gate |
gate_id, decision (GATE_STATUS_APPROVED, GATE_STATUS_DENIED, or GATE_STATUS_ANSWERED for a question), reason, answer |
The key's person must be allowed to decide it. Permission and action requests need an admin. Anyone in the thread can answer a question. Approving a request for a new bot also needs bots.
Workspace administration
Scope admin, and the person must be an admin. These are on AdminService:
RenameWorkspace, SetWorkspaceTimeZone, SetWorkspaceTimeFormat, InviteMember, SetMemberRole, SaveRole, DeleteRole, StartExport, GetExport.
Vault
VaultService. Secrets are never returned by the API. You can store them, but not read them back.
| Method | Scope | Request | Notes |
|---|---|---|---|
List |
read |
workspace_id |
items[]: id, name, kind (login, api_key, note), site, username, bot_ids, has_totp, needs_approval |
Put |
memory |
item, secret, totp_secret, needs_approval |
Add or change an item |
Delete |
memory |
id |
|
Assign |
memory |
item_ids[], bot_ids[], give |
Give items to bots, or take them away |
The same rules as in the app apply: only the person who added an item, or an admin, may give it to a bot. See The vault.
Memory
MemoryService. Bots' memory files. Paths look like Shared/glossary.md or <bot handle>/notes.md.
| Method | Scope | Request |
|---|---|---|
List |
read |
area, with_content |
Read |
read |
path |
Search |
read |
query, scope (shared, all, …), limit |
History |
read |
path |
Write |
memory |
path, content, expected_sha256 ("new" for a new file; the current hash to avoid overwriting someone's change), reason |
Edit |
memory |
path, old_text, new_text |
Append |
memory |
path, text |
Delete / Rename / Revert |
memory |
Files
Upload. Scope files. This one is plain HTTP, so it works with curl:
curl -X POST \
-H "authorization: Bearer $CARET_API_KEY" \
-H "content-type: application/pdf" \
--data-binary @report.pdf \
"$CARET_SERVER/v1/files?thread_id=<thread id>&name=report.pdf&content_type=application/pdf"
It returns {"blob_id": "…", "bytes": 12345}. Files can be up to 2 GB. To show the file in a thread, run the add_artifact command with kind: "file" and file_id: <blob_id>.
Errors come back as an HTTP status (400, 401, 403, 404 or 413) with {"error": "…"}.
Large files can also go up in parts through gRPC: BlobService/StartUpload, PartUrls, then FinishUpload.
Download. Scope read. BlobService/DownloadUrl (blob_id) returns a short-lived url you can fetch directly. BlobService/Download streams the bytes.
Events
SyncService/Subscribe streams the workspace's events as they happen. See Events.