GramClaw API

v1

通过脚本、AI 助手或 Telegram MCP 服务器驱动您的 Telegram 触达:搜索消息、管理 CRM 管道、设置自定义列,并发送消息、群发和营销活动。在此创建密钥: 设置 → API 密钥.

Start with an outcome

View all

身份验证

每个请求都需要一个作为 Bearer 令牌的工作区 API 密钥。在设置 → API 密钥中创建一个——完整密钥( gc_live_…)仅显示一次。

基础 URL
https://gramclaw.com
每个请求
Authorization: Bearer gc_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
快速开始
BASE="https://gramclaw.com"
KEY="gc_live_…"
curl -s "$BASE/api/v1/me" -H "Authorization: Bearer $KEY"

请注意: API 调用会直接执行——没有确认步骤(与应用内 AI 不同)。密钥即授权,请像密码一样妥善保管。速率限制: 每分钟 120 个请求 ,每个密钥都会在每次响应中附带 X-RateLimit-* 响应头。错误会返回 { "error": "…" } ,并带有 4xx/5xx 状态码。

权限范围: 密钥可携带 read (聊天、消息、搜索、分析), write (管道、列、Webhook), 以及/或 send (消息、群发、营销活动), or campaign for separately authorized internal campaign reads (and, behind a separate mutation gate and allowlists, campaign creation and cancellation). ——在创建密钥时选择它们。发送类型的 POST 请求接受 Idempotency-Key 标头,因此重试永远不会重复发送。

端点

GET/api/v1/me— Verify key & list Telegram accounts范围: read

Returns only currently eligible, workspace-scoped internal Telegram accounts plus explicit capabilities.

GET/api/v1/chats— List existing Telegram chats范围: read

Reads an exact eligible account through scoped Telegram v2. No conversation is created and no message is marked read.

字段类型备注
account_id*string
cursorstring
limitnumberdefault 50, max 100
GET/api/v1/chats/{id}— Get chat and participants范围: read

Returns provider-neutral metadata and participants for the exact account/chat scope.

字段类型备注
account_id*string
participant_cursorstring
participant_limitnumber
GET/api/v1/chats/{id}/messages— Read message history范围: read

Reads scoped Telegram history without changing read state.

字段类型备注
account_id*string
beforestring
limitnumber
POST/api/v1/chats/start— Open a chat by Telegram username范围: send

Resolves a Telegram username and opens its private chat under one exact eligible account. Requires a send-scoped key, the Start Chat feature gate, and a caller-supplied Idempotency-Key. It never sends a message.

字段类型备注
account_id*string
identifier*stringusername, @username, or t.me username link
Idempotency-Key header*string
GET/api/v1/contacts— List observed Telegram contacts范围: read

Reads account-scoped contacts already observed by GramClaw. Requires both REST API and CRM read access; it never performs a Telegram lookup.

字段类型备注
account_idstring
qstring
cursorstring
limitnumberdefault 100, max 200
GET/api/v1/pipeline— Read scoped Telegram pipeline范围: read

Returns workspace stages and account-qualified Telegram chat placements. Requires both REST API and Pipeline read access.

POST/api/v1/pipeline/move— Move a scoped Telegram chat范围: write

Assigns an existing chat to a visible workspace stage. Requires an explicit write-scoped key plus the REST API and Pipeline gates.

字段类型备注
account_id*string
chat_id*string
stage_key*stringvisible key from GET /api/v1/pipeline
GET/api/v1/columns— Read custom columns and scoped values范围: read

Returns workspace column definitions plus values keyed by both Telegram account and chat. Requires both REST API and CRM read access.

字段类型备注
account_idstringoptional exact account filter for values
POST/api/v1/columns/set— Set a scoped Telegram column value范围: write

Sets or clears a configured value for one exact account/chat. Requires an explicit write-scoped key plus the REST API and CRM gates.

字段类型备注
account_id*string
chat_id*string
column_id*string
value*string[]empty array clears the value
GET/api/v1/analytics— Read truthful Telegram analytics范围: read

Reports persisted message activity and durable campaign-send ledger counts. Delivery, read, and engagement are null rather than inferred. Requires both REST API and Analytics read access.

字段类型备注
period"7d" | "30d" | "all"default 7d
GET/api/v1/campaigns— List internal Telegram campaigns范围: campaign

Lists only workspace-owned internal Telegram campaigns with truthful durable reporting. Requires an explicitly issued campaign scope plus the independent Campaigns gate and user allowlist.

字段类型备注
cursorstring
limitnumberdefault 50, max 100
GET/api/v1/campaigns/{id}— Read internal Telegram campaign detail范围: campaign

Returns durable recipients, sequence steps, operation state, and reporting. capabilities reflect the key scope, allowlists, gates, and current status. Legacy campaigns remain outside the public execution plane.

POST/api/v1/campaigns— Create a campaign for existing private chats范围: campaign

Disabled by default behind a separate mutation gate plus exact user and workspace allowlists. Requires a campaign-scoped key and Idempotency-Key. Recipients must be existing private chats of READY internal Telegram accounts (max 20). No @usernames, attachments, or client-supplied names; suppressed recipients reject the request. Campaign, steps and recipients are stored atomically and queued for the worker — this call never sends a message.

字段类型备注
message_text*string1-4096 chars; [[name]]/[[username]] come from Telegram
recipients*{ account_id, chat_id }[]1-20 existing private chats
namestringup to 200 chars
steps{ branch, wait_hours, variants }[]follow-ups; branch no_reply, or seen/unseen when branching is enabled
branching_enabledbooleanrequires the U4 branching gate
daily_quota_per_accountnumber1-50 campaign ceiling, default 50; account tier may enforce a lower limit
max_followupsnumber0-5, default 2
scheduled_at / schedule_timezonestringISO time (≤ 1 year ahead) / IANA zone
Idempotency-Key header*string
响应
{ "campaign": { "id": "…", "status": "queued" }, "recipients": 2, "dispatch": "worker" }
POST/api/v1/campaigns/{id}/pause— Pause an internal sequence campaign范围: campaign

Requires campaign scope, the REST/campaign mutation gates and Idempotency-Key. Pausing changes queue state only; the durable worker remains the only dispatcher. Sequence campaigns only.

字段类型备注
Idempotency-Key header*string
响应
{ "campaign": { "id": "…", "status": "paused" }, "changed": true, "dispatch": "worker" }
POST/api/v1/campaigns/{id}/resume— Resume an internal sequence campaign范围: campaign

Requires campaign scope, the REST/campaign mutation gates and Idempotency-Key. Resuming changes queue state only; the durable worker remains the only dispatcher. Sequence campaigns only.

字段类型备注
Idempotency-Key header*string
响应
{ "campaign": { "id": "…", "status": "sending" }, "changed": true, "dispatch": "worker" }
POST/api/v1/campaigns/{id}/cancel— Permanently cancel a campaign范围: campaign

Same gates as creation plus Idempotency-Key. Atomically cancels a scheduled, queued, sending or paused campaign and stops queued recipients; idempotent and irreversible. A send already handed to Telegram may still complete.

字段类型备注
Idempotency-Key header*string
响应
{ "campaign": { "id": "…", "status": "cancelled", "cancelled_at": "…" }, "changed": true }
POST/api/v1/messages— Send text and optionally one attachment范围: send

Requires an explicit send-scoped key and caller-supplied Idempotency-Key. Sends only to an existing eligible account/chat. JSON supports plain text; multipart/form-data supports exactly one file up to 25 MiB with optional text. No multi-file support. Ambiguous outcomes are never retried.

字段类型备注
account_id*string
chat_id*string
textstringrequired for JSON; optional with an attachment
attachmentsone filemultipart only; maximum 25 MiB; multiple files rejected
Idempotency-Key header*string
请求
curl -s "$BASE/api/v1/messages" \
  -H "Authorization: Bearer $KEY" -H "Idempotency-Key: unique-operation-123" \
  -F "account_id=ACCOUNT_ID" -F "chat_id=telegram:chat:123" \
  -F "text=See attached" -F "attachments=@./file.pdf"
响应
{ "ok": true, "operation_id": "…", "message": { "id": "telegram:message:…" } }

从 Claude / Cursor 连接(Telegram MCP)

最简单——远程连接器(一个 URL)。 在您的 MCP 客户端中,添加自定义连接器并粘贴您的个人 URL。在设置 → API 密钥中创建密钥,以获取包含您密钥的完整 URL。参见 Telegram MCP 概览 查看工具列表。

远程 MCP URL
https://gramclaw.com/api/mcp?key=gc_live_…

备选方案——本地服务器 (Cursor 或 Claude Desktop 配置文件):

claude_desktop_config.json
{
  "mcpServers": {
    "gramclaw": {
      "command": "npx",
      "args": ["-y", "gramclaw-mcp"],
      "env": {
        "GRAMCLAW_API_KEY": "gc_live_…",
        "GRAMCLAW_BASE_URL": "https://gramclaw.com"
      }
    }
  }
}
需要设置帮助?请访问 API 和 MCP 帮助指南.
Chat on Telegram