Raintree Workspace Data API
The Raintree workspace data API is a read-only HTTP API. It lets an authorized agent or script read chat messages, list workspace files, and download files from one Raintree workspace.
Every workspace serves its own copy of the API under /api/v1/. The API accepts GET and HEAD only. HEAD is supported on /api/v1/, /api/v1/openapi.json, and file downloads.
Where the spec lives
- Canonical machine spec:
GET <origin>/api/v1/openapi.json. OpenAPI 3.1, no token needed. - In-workspace guide:
GET <origin>/api/v1/. Markdown, with the same endpoints and examples. - This page: the public overview for agents and developers. The markdown alternate has the same content.
Connect
Use the workspace origin, for example https://<name>.workspace.raintree.tech. Send a Bearer token that starts with rtw_.
export ORIGIN=https://<name>.workspace.raintree.tech
curl -H "Authorization: Bearer rtw_..." "$ORIGIN/api/v1/chat_log"Keep tokens out of logs and shared notes.
Endpoints
| Method | Path | Purpose |
|---|---|---|
| GET, HEAD | /api/v1/ | Markdown guide |
| GET, HEAD | /api/v1/openapi.json | OpenAPI 3.1 spec. No token needed. |
| GET | /api/v1/chat_log | List chats or read messages |
| GET | /api/v1/files | List one folder, or a whole tree with recursive=1 |
| GET, HEAD | /api/v1/files/<path> | Download one file |
Unknown or repeated query parameters return 400. Use only the parameters listed in the sections below.
Chat log
GET /api/v1/chat_log takes chat, text, sender, since, until, n, and cursor. The chat parameter takes a chat id, a unique case-insensitive name substring of at least 3 characters, or all. The n parameter is an integer from 1 to 200, and defaults to 50.
text is a case-insensitive substring of the message text. sender is a substring of the sender's name or id.
since and until are inclusive. A bare date (YYYY-MM-DD) covers its whole UTC day: since starts at 00:00:00Z and until ends at 23:59:59.999Z. A date-time needs Z or a UTC offset. Bare numbers and date-times without a zone return 400. Every time in a response is UTC ISO-8601 with Z.
With no chat (or chat=all) and none of text, sender, since, until, n, or cursor, the endpoint lists chats:
{
"chats": [
{
"id": "C9773370",
"name": "Team",
"type": "group",
"provider": "line",
"messages": 412,
"last_activity": "2026-11-01T08:30:00Z",
"participants": ["Alice", "Bob"],
"files_dir": "inbox/line/C9773370"
}
]
}messages counts messages in both directions. participants lists the known participant names. files_dir is the workspace path of the chat's attachment folder, or null.
A message query returns messages oldest first. When truncated is true, the response includes next_cursor. It is opaque: send it back unchanged as cursor and repeat every other parameter to read older messages. Pages never skip or repeat a message, even when messages share a timestamp.
{
"messages": [
{
"id": "412",
"time": "2026-11-01T08:30:00Z",
"chat": "C9773370",
"sender": "Alice",
"sender_id": "U100",
"direction": "inbound",
"text": "Shipment confirmed.",
"attachments": [
{"path": "inbox/line/C9773370/photo-1.jpg", "name": "photo-1.jpg", "mime": "image/jpeg", "size": 204800}
]
}
],
"truncated": true,
"next_cursor": "v1.eyJ0IjoxNzkzNTIxODAwMDAwLCJpZCI6NDEyfQ"
}idis a stable string that identifies one message. Use it to tell messages apart; do not parse it.sender_idis a stable id. It isnullfor outbound and unknown senders.directionisinboundoroutbound. Outbound messages showsenderasRaintree.- Each attachment
pathworks with/api/v1/files/<path>. It isnullwhen the file is not stored. The API has no newest-20 cap on attachments. truncatedistruewhen older matching messages exist. The API fetches one message more thannto set this value.
Files
GET /api/v1/files?path=<dir> lists one folder level. Omit path for the workspace root. Add recursive=1 or recursive=true to list the whole tree. recursive=0, recursive=false, or no recursive lists one level. Any other value returns 400.
A recursive listing is flat, sorted by path, and holds at most 5000 entries. It is gathered breadth-first, with names sorted within each level. truncated is true when more than 5000 entries exist, or when a directory path is longer than 1024 characters; that directory's children are skipped. When truncated is true, the list is not the full tree. To see the rest, list a subdirectory with path=. A one-level listing always sets truncated to false.
GET /api/v1/files/<path> returns the file body. HEAD returns the same headers with no body. Downloads are limited to files of at most 50 MiB.
- Responses up to 1 MiB include Content-Length. Larger responses stream with chunked transfer encoding and no Content-Length. HEAD always includes the full Content-Length. Range (206), ETag, Last-Modified, 304 and 416 apply to all sizes.
ETagisW/"<size>-<mtimeMs>". SendIf-None-Matchto get304when it matches.- One
Range: bytes=a-b,bytes=a-, orbytes=-nheader returns206. An unsatisfiable range returns416withContent-Range: bytes */<size>. - Multiple ranges are not supported. The API ignores the header and returns
200with the full file. Last-ModifiedandAccept-Ranges: bytesare set.- Responses use
Cache-Control: private, no-storeandX-Content-Type-Options: nosniff.
Errors
Errors return JSON with an error object that has a code and a message.
{"error": {"code": "invalid_request", "message": "unknown parameter 'x'; allowed: chat, text, sender, since, until, n, cursor"}}| Status | Code | When |
|---|---|---|
| 400 | invalid_request | Unknown or repeated parameter, bad n, bad since or until, malformed cursor, bad recursive |
| 400 | ambiguous_chat | The chat name matches more than one chat. The body lists candidates with id and name. |
| 401 | unauthorized | The token is missing, invalid, expired, or revoked. |
| 404 | chat_not_found | No chat matches chat. The body lists chats. |
| 404 | not_found | No such directory or file. |
| 405 | method_not_allowed | A method other than GET or HEAD. The response sends Allow: GET, HEAD. |
| 416 | range_not_satisfiable | The Range header cannot be satisfied. |
| 429 | rate_limited | Over a limit. The response sends Retry-After. See Limits. |
| 500 | chat_log_failed | The server could not read chat history. Retry later. |
Limits
- Per token: 5 requests per second, with a burst of 20.
- 2 requests in flight at once.
- 1 MiB/s per file download.
When you hit a limit, the response is 429 with Retry-After: 2 (seconds) from the edge. Wait that long and retry. Do not send requests in a tight loop.
Recipes
Read the newest 50 messages from one chat:
curl -H "Authorization: Bearer rtw_..." "$ORIGIN/api/v1/chat_log?chat=Team&n=50"Read the next older page, repeating the same filters:
curl -H "Authorization: Bearer rtw_..." "$ORIGIN/api/v1/chat_log?chat=Team&n=50&cursor=<next_cursor>"List a folder tree:
curl -H "Authorization: Bearer rtw_..." "$ORIGIN/api/v1/files?path=inbox&recursive=1"Download the first MiB of a file:
curl -H "Authorization: Bearer rtw_..." -H "Range: bytes=0-1048575" "$ORIGIN/api/v1/files/inbox/example.pdf" -o part.binRelated pages
- /developers — developer resources
- /developers.md — markdown alternate of the developer resources page
- /llms.txt — index for agents