EVC Team Relay
REST API skill for reading and writing collaborative Obsidian vault documents via EVC Team Relay.
Environment variables
| Variable | Required | Description |
|---|
| INLINECODE0 | yes | Control plane URL, e.g. INLINECODE1 |
| INLINECODE2 |
yes | User email for authentication |
|
RELAY_PASSWORD | yes | User password |
|
RELAY_TOKEN | no | JWT token (set via
export RELAY_TOKEN=$(scripts/auth.sh)) |
Quick start
CODEBLOCK0
All scripts accept the token via RELAY_TOKEN env var (preferred) or as the first CLI argument (backward-compatible).
Two kinds of shares
| Doc share | Folder share |
|---|
| Contains | Single document | Multiple files |
| docid |
Same as shareid | Each file has its own doc_id (in folder metadata) |
|
Read |
read.sh <share_id> |
read-file.sh <share_id> "path/to/file.md" |
|
Write |
write.sh <share_id> <share_id> <content> |
upsert-file.sh <share_id> "path" <content> |
|
Delete | N/A |
delete-file.sh <share_id> "path" |
Most shares are folder shares. Use read-file.sh and upsert-file.sh — they handle path resolution automatically.
Warning: write.sh does NOT work for folder shares — it writes content but does not register the file in folder metadata, so Obsidian will never see it. The script detects folder shares and refuses with an error.
Scripts reference
| Script | Purpose | Args |
|---|
| INLINECODE15 | Get JWT token | — |
| INLINECODE16 |
List all shares |
[kind] [owned_only] |
|
list-files.sh | List files in folder share |
<share_id> |
|
read-file.sh |
Read file by path (folder share) |
<share_id> <file_path> |
|
read.sh | Read by doc_id (low-level) |
<share_id> [doc_id] |
|
upsert-file.sh |
Create/update file (folder share) |
<share_id> <file_path> <content> |
|
write.sh | Write by doc_id (doc shares only) |
<share_id> <doc_id> <content> |
|
delete-file.sh | Delete file from folder share |
<share_id> <file_path> |
|
create-file.sh | Create new file (low-level) |
<share_id> <file_path> <content> |
Bold = recommended for most use cases. All scripts use RELAY_TOKEN env var (or accept token as first arg).
Authentication
All API calls require a Bearer JWT token. Get one via login:
CODEBLOCK1
Response:
CODEBLOCK2
Use the access_token as Authorization: Bearer <token> header on all subsequent requests.
When the token expires (1 hour), refresh it:
CODEBLOCK3
Listing shares
Shares are the access units — each share maps to a document or folder in the Obsidian vault.
CODEBLOCK4
Response (array):
CODEBLOCK5
Key fields:
- -
id — share UUID, used as share_id in all operations kind — doc (single file) or folder (directory)path — Obsidian vault-relative pathuser_role — viewer (read-only), editor (read-write), or null (owner)
Filter options: ?kind=doc, ?owned_only=true, ?member_only=true, ?skip=0&limit=50.
Listing files in a folder share
CODEBLOCK6
Response:
CODEBLOCK7
Each key is the file's path within the folder. The doc_id field is the document identifier used for content operations. The share_id for content requests is always the folder share's ID.
Note: The API response uses id as the field name. This is the same as doc_id — use it wherever doc_id is needed.
Reading files
By path (recommended for folder shares)
CODEBLOCK8
This resolves the path to a doc_id internally and returns:
CODEBLOCK9
By doc_id (low-level)
CODEBLOCK10
For doc shares, omit docid (defaults to shareid). For folder shares, pass the file's doc_id from list-files.sh.
Writing files
Folder shares — use upsert-file.sh
CODEBLOCK11
Response includes an operation field: "created" or "updated".
Doc shares — use write.sh
CODEBLOCK12
write.sh refuses folder shares — if you accidentally pass a folder shareid as docid, it detects this and exits with an error directing you to upsert-file.sh.
Common workflows
Read a specific note by path (most common)
CODEBLOCK13
Create or update a file
CODEBLOCK14
Delete a file
CODEBLOCK15
Error codes
| Status | Meaning |
|---|
| 400 | Invalid share_id format |
| 401 |
Missing or expired token — re-authenticate |
| 403 | Insufficient permissions (viewer trying to write, or non-member) |
| 404 | Share or file not found (check path spelling, use list-files.sh to verify) |
| 422 | Missing required field (share_id, content) |
| 502 | Relay server unavailable — retry later |
Terminology
| Term | Meaning |
|---|
| INLINECODE58 | UUID of a share (doc or folder). Used for ACL checks in all requests. |
| INLINECODE59 |
UUID of an individual document. For doc shares, equals share
id. For folder shares, each file has its own docid. |
|
id | Same as
doc_id — the API response field name. Use interchangeably. |
|
file_path | Relative path within a folder share (e.g.
"Marketing/plan.md"). |
References
- -
references/api.md — full API reference with all endpoints
EVC 团队接力
通过 EVC 团队接力读取和写入协作 Obsidian 库文档的 REST API 技能。
环境变量
| 变量 | 必填 | 描述 |
|---|
| RELAYCPURL | 是 | 控制平面 URL,例如 https://cp.tr.entire.vc |
| RELAY_EMAIL |
是 | 用于身份验证的用户邮箱 |
| RELAY_PASSWORD | 是 | 用户密码 |
| RELAY
TOKEN | 否 | JWT 令牌(通过 export RELAYTOKEN=$(scripts/auth.sh) 设置) |
快速开始
bash
1. 身份验证 — 获取 JWT 令牌(存储在环境变量中,不在 ps 中可见)
export RELAY_TOKEN=$(scripts/auth.sh)
2. 列出共享以查找可用文档
scripts/list-shares.sh
3. 按路径从文件夹共享读取文件(最常见)
scripts/read-file.sh
shareid> Marketing/plan.md
4. 在文件夹共享中创建或更新文件
scripts/upsert-file.sh shareid> note.md # Content
5. 列出文件夹共享中的所有文件
scripts/list-files.sh shareid>
6. 从文件夹共享中删除文件
scripts/delete-file.sh shareid> old-note.md
7. 读取文档共享(单个文档,shareid = docid)
scripts/read.sh
8. 写入文档共享
scripts/write.sh id> id> # Updated content
所有脚本都通过 RELAY_TOKEN 环境变量(首选)或作为第一个 CLI 参数(向后兼容)接受令牌。
两种共享类型
与 shareid 相同 | 每个文件有自己的 doc_id(在文件夹元数据中) |
| 读取 | read.sh id> | read-file.sh id> path/to/file.md |
| 写入 | write.sh id> id> | upsert-file.sh path |
| 删除 | 不适用 | delete-file.sh path |
大多数共享是文件夹共享。 使用 read-file.sh 和 upsert-file.sh — 它们会自动处理路径解析。
警告:write.sh 不适用于文件夹共享 — 它会写入内容,但不会在文件夹元数据中注册文件,因此 Obsidian 永远不会看到它。该脚本会检测文件夹共享并拒绝操作,同时报错。
脚本参考
| 脚本 | 用途 | 参数 |
|---|
| auth.sh | 获取 JWT 令牌 | — |
| list-shares.sh |
列出所有共享 | [kind] [owned_only] |
| list-files.sh | 列出文件夹共享中的文件 | |
| read-file.sh | 按路径读取文件(文件夹共享) | id> path> |
| read.sh | 按 docid 读取(低级) | id> [doc_id] |
| upsert-file.sh | 创建/更新文件(文件夹共享) | id> path> |
| write.sh | 按 docid 写入(仅文档共享) | id> |
| delete-file.sh | 从文件夹共享中删除文件 | id> path> |
| create-file.sh | 创建新文件(低级) | id> path> |
加粗 = 推荐用于大多数用例。 所有脚本都使用 RELAY_TOKEN 环境变量(或接受令牌作为第一个参数)。
身份验证
所有 API 调用都需要 Bearer JWT 令牌。通过登录获取:
bash
curl -s -X POST $RELAYCPURL/v1/auth/login \
-H Content-Type: application/json \
-d {email: $RELAYEMAIL, password: $RELAYPASSWORD} \
| jq -r .access_token
响应:
json
{
access_token: eyJ...,
refresh_token: ...,
token_type: bearer,
expires_in: 3600
}
在所有后续请求中使用 access_token 作为 Authorization: Bearer 标头。
当令牌过期(1 小时)时,刷新它:
bash
curl -s -X POST $RELAYCPURL/v1/auth/refresh \
-H Content-Type: application/json \
-d {refreshtoken: $REFRESHTOKEN}
列出共享
共享是访问单元 — 每个共享映射到 Obsidian 库中的一个文档或文件夹。
bash
curl -s $RELAYCPURL/v1/shares \
-H Authorization: Bearer $TOKEN | jq
响应(数组):
json
[
{
id: a1b2c3d4-...,
kind: doc,
path: Projects/meeting-notes.md,
visibility: private,
is_owner: true,
user_role: null,
web_published: false
},
{
id: e5f6g7h8-...,
kind: folder,
path: Projects/,
visibility: private,
is_owner: false,
user_role: editor
}
]
关键字段:
- - id — 共享 UUID,在所有操作中用作 shareid
- kind — doc(单个文件)或 folder(目录)
- path — 相对于 Obsidian 库的路径
- user
role — viewer(只读)、editor(读写)或 null(所有者)
过滤选项:?kind=doc、?ownedonly=true、?memberonly=true、?skip=0&limit=50。
列出文件夹共享中的文件
bash
scripts/list-files.sh
响应:
json
{
doc_id: e5f6g7h8-...,
files: {
meeting-notes.md: {doc_id: abc123-..., type: markdown},
project-plan.md: {doc_id: def456-..., type: markdown}
}
}
每个键是文件在文件夹内的路径。docid 字段是用于内容操作的文档标识符。内容请求的 share
id 始终是文件夹共享的 ID。
注意:API 响应使用 id 作为字段名。这与 docid 相同 — 在需要 docid 的地方使用它。
读取文件
按路径(推荐用于文件夹共享)
bash
scripts/read-file.sh shareid> Marketing/plan.md
这会在内部将路径解析为 doc_id 并返回:
json
{
doc_id: abc123-...,
content: # Marketing Plan\n\nContent here...,
format: text,
path: Marketing/plan.md
}
按 doc_id(低级)
bash
scripts/read.sh id> [docid] [key]
对于文档共享,省略 docid(默认为 shareid)。对于文件夹共享,传递来自 list-files.sh 的文件的 doc_id。
写入文件
文件夹共享 — 使用 upsert-file.sh
bash
创建或更新 — 自动检测需要哪种操作
scripts/upsert-file.sh shareid> note.md # Updated content
从标准输入管道内容
echo # Content | scripts/upsert-file.sh shareid> note.md -
响应包含一个 operation 字段:created 或 updated。
文档共享 — 使用 write.sh
bash
scripts/write.sh id> id> # Updated Notes
write.sh 拒绝文件夹共享 — 如果您意外将文件夹 shareid 作为 docid 传递,它会检测到并退出并报错,指导您使用 upsert-file.sh。
常见工作流程
按路径读取特定笔记(最常见)
bash
如果您知道文件夹 share_id: