Zoho Mail Skill
Read, search, and manage Zoho Mail directly from Clawdbot.
Setup
- 1. Go to Zoho API Console and create a Self Client
- Note the Client ID and Client Secret
- Generate a grant code with scopes: INLINECODE0
- Exchange the grant code for a refresh token:
curl -s -X POST "https://accounts.zoho.com/oauth/v2/token" \
-d "code=YOUR_GRANT_CODE" \
-d "client_id=YOUR_CLIENT_ID" \
-d "client_secret=YOUR_CLIENT_SECRET" \
-d "grant_type=authorization_code" | jq
- 5. Set environment variables:
CODEBLOCK1
Authentication
Zoho uses OAuth 2.0. Access tokens expire after 1 hour, so always refresh before making API calls. The refresh token does not expire unless revoked.
Get an access token
CODEBLOCK2
Important: Run this command before every API session or when you get a 401 error. All commands below assume $ZOHO_ACCESS_TOKEN is set.
Usage
All commands use curl with the Zoho-oauthtoken authorization header. Note: Zoho uses Zoho-oauthtoken prefix, not Bearer.
Get account ID
CODEBLOCK3
Store the account ID for subsequent calls:
CODEBLOCK4
List folders
CODEBLOCK5
Get Inbox folder ID
CODEBLOCK6
List inbox messages
CODEBLOCK7
List messages in a specific folder
CODEBLOCK8
Read a specific email
CODEBLOCK9
Get email body content only
CODEBLOCK10
Search emails
CODEBLOCK11
Search syntax supports:
- - Simple text: INLINECODE5
- From filter: INLINECODE6
- Subject filter: INLINECODE7
- Date range: INLINECODE8
- Combined: INLINECODE9
List email threads
CODEBLOCK12
Get thread details (all messages in a thread)
CODEBLOCK13
List labels/tags
CODEBLOCK14
List attachments on an email
CODEBLOCK15
Get account info
CODEBLOCK16
Regional Endpoints
If your Zoho account is not in the US region, replace mail.zoho.com and accounts.zoho.com with:
| Region | Mail API | Auth |
|---|
| US | mail.zoho.com | accounts.zoho.com |
| EU |
mail.zoho.eu | accounts.zoho.eu |
| India | mail.zoho.in | accounts.zoho.in |
| Australia | mail.zoho.com.au | accounts.zoho.com.au |
| Japan | mail.zoho.jp | accounts.zoho.jp |
| Canada | mail.zohocloud.ca | accounts.zohocloud.ca |
Notes
- - Access tokens expire after 1 hour — refresh before each session
- The refresh token does not expire unless revoked
- Rate limit: 30 API requests per minute per account
- INLINECODE12 is in milliseconds since epoch — convert with: INLINECODE13
- INLINECODE14 field:
"0" = unread, "1" = read - Auth header uses
Zoho-oauthtoken prefix, not INLINECODE18 - Keep your Client Secret and Refresh Token secure!
Examples
CODEBLOCK17
Zoho Mail 技能
直接从 Clawdbot 读取、搜索和管理 Zoho Mail。
设置
- 1. 前往 Zoho API 控制台 并创建一个 自客户端
- 记下 客户端 ID 和 客户端密钥
- 使用以下作用域生成授权码:ZohoMail.messages.READ,ZohoMail.folders.READ,ZohoMail.accounts.READ
- 将授权码兑换为刷新令牌:
bash
curl -s -X POST https://accounts.zoho.com/oauth/v2/token \
-d code=YOUR
GRANTCODE \
-d client
id=YOURCLIENT_ID \
-d client
secret=YOURCLIENT_SECRET \
-d grant
type=authorizationcode | jq
- 5. 设置环境变量:
bash
export ZOHO
CLIENTID=your-client-id
export ZOHO
CLIENTSECRET=your-client-secret
export ZOHO
REFRESHTOKEN=your-refresh-token
认证
Zoho 使用 OAuth 2.0。访问令牌在 1 小时后过期,因此在调用 API 前务必刷新。除非被撤销,刷新令牌不会过期。
获取访问令牌
bash
ZOHO
ACCESSTOKEN=$(curl -s -X POST https://accounts.zoho.com/oauth/v2/token \
-d refresh
token=$ZOHOREFRESH_TOKEN \
-d client
id=$ZOHOCLIENT_ID \
-d client
secret=$ZOHOCLIENT_SECRET \
-d grant
type=refreshtoken | jq -r .access_token)
重要提示: 在每次 API 会话前或收到 401 错误时运行此命令。以下所有命令均假定已设置 $ZOHOACCESSTOKEN。
使用方法
所有命令均使用带有 Zoho-oauthtoken 授权头的 curl。注意:Zoho 使用 Zoho-oauthtoken 前缀,而非 Bearer。
获取账户 ID
bash
curl -s https://mail.zoho.com/api/accounts \
-H Authorization: Zoho-oauthtoken $ZOHO
ACCESSTOKEN | jq .data[0] | {accountId, mailboxAddress, firstName, lastName}
为后续调用存储账户 ID:
bash
ZOHOACCOUNTID=$(curl -s https://mail.zoho.com/api/accounts \
-H Authorization: Zoho-oauthtoken $ZOHOACCESSTOKEN | jq -r .data[0].accountId)
列出文件夹
bash
curl -s https://mail.zoho.com/api/accounts/$ZOHO
ACCOUNTID/folders \
-H Authorization: Zoho-oauthtoken $ZOHO
ACCESSTOKEN | jq .data[] | {folderName, folderId, unreadCount, messageCount}
获取收件箱文件夹 ID
bash
INBOX
ID=$(curl -s https://mail.zoho.com/api/accounts/$ZOHOACCOUNT_ID/folders \
-H Authorization: Zoho-oauthtoken $ZOHO
ACCESSTOKEN | jq -r .data[] | select(.folderName==Inbox) | .folderId)
列出收件箱邮件
bash
curl -s https://mail.zoho.com/api/accounts/$ZOHO
ACCOUNTID/messages/view?folderId=$INBOX_ID&limit=10&start=0 \
-H Authorization: Zoho-oauthtoken $ZOHO
ACCESSTOKEN | jq .data[] | {subject, sender, fromAddress, receivedTime, messageId, status2}
列出特定文件夹中的邮件
bash
curl -s https://mail.zoho.com/api/accounts/$ZOHO
ACCOUNTID/messages/view?folderId={folderId}&limit=10&start=0 \
-H Authorization: Zoho-oauthtoken $ZOHO
ACCESSTOKEN | jq .data[] | {subject, sender, receivedTime, messageId}
读取特定邮件
bash
curl -s https://mail.zoho.com/api/accounts/$ZOHO
ACCOUNTID/messages/{messageId} \
-H Authorization: Zoho-oauthtoken $ZOHO
ACCESSTOKEN | jq .data | {subject, sender, fromAddress, toAddress, ccAddress, receivedTime, content}
仅获取邮件正文内容
bash
curl -s https://mail.zoho.com/api/accounts/$ZOHO
ACCOUNTID/messages/{messageId}/content \
-H Authorization: Zoho-oauthtoken $ZOHO
ACCESSTOKEN | jq -r .data.content
搜索邮件
bash
curl -s https://mail.zoho.com/api/accounts/$ZOHO
ACCOUNTID/messages/search?searchKey={query}&limit=10 \
-H Authorization: Zoho-oauthtoken $ZOHO
ACCESSTOKEN | jq .data[] | {subject, sender, receivedTime, messageId, summary}
搜索语法支持:
- - 简单文本:searchKey=invoice
- 发件人筛选:searchKey=from:john@example.com
- 主题筛选:searchKey=subject:quarterly report
- 日期范围:searchKey=after:2024-01-01 before:2024-06-30
- 组合:searchKey=from:boss@company.com subject:meeting
列出邮件线程
bash
curl -s https://mail.zoho.com/api/accounts/$ZOHO
ACCOUNTID/threads/view?folderId=$INBOX_ID&limit=10&start=0 \
-H Authorization: Zoho-oauthtoken $ZOHO
ACCESSTOKEN | jq .data[] | {subject, threadId, messageCount}
获取线程详情(线程中的所有邮件)
bash
curl -s https://mail.zoho.com/api/accounts/$ZOHO
ACCOUNTID/threads/{threadId} \
-H Authorization: Zoho-oauthtoken $ZOHO
ACCESSTOKEN | jq
列出标签
bash
curl -s https://mail.zoho.com/api/accounts/$ZOHO
ACCOUNTID/tags \
-H Authorization: Zoho-oauthtoken $ZOHO
ACCESSTOKEN | jq .data[] | {tagName, tagId, color}
列出邮件附件
bash
curl -s https://mail.zoho.com/api/accounts/$ZOHO
ACCOUNTID/folders/{folderId}/messages/{messageId}/attachments \
-H Authorization: Zoho-oauthtoken $ZOHO
ACCESSTOKEN | jq .data[] | {attachmentName, attachmentId, fileSize}
获取账户信息
bash
curl -s https://mail.zoho.com/api/accounts/$ZOHO
ACCOUNTID \
-H Authorization: Zoho-oauthtoken $ZOHO
ACCESSTOKEN | jq .data | {firstName, lastName, mailboxAddress, usedStorage, planStorage}
区域端点
如果您的 Zoho 账户不在美国区域,请将 mail.zoho.com 和 accounts.zoho.com 替换为:
| 区域 | 邮件 API | 认证 |
|---|
| 美国 | mail.zoho.com | accounts.zoho.com |
| 欧洲 |
mail.zoho.eu | accounts.zoho.eu |
| 印度 | mail.zoho.in | accounts.zoho.in |
| 澳大利亚 | mail.zoho.com.au | accounts.zoho.com.au |
| 日本 | mail.zoho.jp | accounts.zoho.jp |
| 加拿大 | mail.zohocloud.ca | accounts.zohocloud.ca |
注意事项
- - 访问令牌在 1 小时 后过期 — 每次会话前请刷新
- 除非被撤销,刷新令牌 不会 过期
- 速率限制:每个账户 每分钟 30 次 API 请求
- receivedTime 是自纪元以来的毫秒数 — 使用以下命令转换:date -d @$((receivedTime/1000))
- status2 字段:0 = 未读,1 = 已读
- 认证头使用 Zoho-oauthtoken 前缀,而非 Bearer
-